js-cloudimage-hotspot 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +294 -0
- package/dist/a11y/aria.d.ts +7 -0
- package/dist/a11y/aria.d.ts.map +1 -0
- package/dist/a11y/focus.d.ts +9 -0
- package/dist/a11y/focus.d.ts.map +1 -0
- package/dist/a11y/keyboard.d.ts +14 -0
- package/dist/a11y/keyboard.d.ts.map +1 -0
- package/dist/core/CIHotspot.d.ts +48 -0
- package/dist/core/CIHotspot.d.ts.map +1 -0
- package/dist/core/ci-hotspot.d.ts +95 -0
- package/dist/core/ci-hotspot.d.ts.map +1 -0
- package/dist/core/config.d.ts +15 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/types.d.ts +227 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/editor/ci-hotspot-editor.d.ts +58 -0
- package/dist/editor/ci-hotspot-editor.d.ts.map +1 -0
- package/dist/editor/drag-manager.d.ts +18 -0
- package/dist/editor/drag-manager.d.ts.map +1 -0
- package/dist/editor/editor-toolbar.d.ts +26 -0
- package/dist/editor/editor-toolbar.d.ts.map +1 -0
- package/dist/editor/index.d.ts +3 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/js-cloudimage-hotspot-editor.cjs.js +4 -0
- package/dist/editor/js-cloudimage-hotspot-editor.cjs.js.map +1 -0
- package/dist/editor/js-cloudimage-hotspot-editor.esm.js +1981 -0
- package/dist/editor/js-cloudimage-hotspot-editor.esm.js.map +1 -0
- package/dist/editor/js-cloudimage-hotspot-editor.min.js +4 -0
- package/dist/editor/js-cloudimage-hotspot-editor.min.js.map +1 -0
- package/dist/editor/property-panel.d.ts +17 -0
- package/dist/editor/property-panel.d.ts.map +1 -0
- package/dist/editor/selection-manager.d.ts +15 -0
- package/dist/editor/selection-manager.d.ts.map +1 -0
- package/dist/editor/types.d.ts +32 -0
- package/dist/editor/types.d.ts.map +1 -0
- package/dist/editor/undo-manager.d.ts +16 -0
- package/dist/editor/undo-manager.d.ts.map +1 -0
- package/dist/fullscreen/fullscreen.d.ts +14 -0
- package/dist/fullscreen/fullscreen.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/js-cloudimage-hotspot.cjs.js +2 -0
- package/dist/js-cloudimage-hotspot.cjs.js.map +1 -0
- package/dist/js-cloudimage-hotspot.esm.js +1408 -0
- package/dist/js-cloudimage-hotspot.esm.js.map +1 -0
- package/dist/js-cloudimage-hotspot.min.js +2 -0
- package/dist/js-cloudimage-hotspot.min.js.map +1 -0
- package/dist/markers/Marker.d.ts +10 -0
- package/dist/markers/Marker.d.ts.map +1 -0
- package/dist/markers/pulse.d.ts +9 -0
- package/dist/markers/pulse.d.ts.map +1 -0
- package/dist/popover/Popover.d.ts +41 -0
- package/dist/popover/Popover.d.ts.map +1 -0
- package/dist/popover/position.d.ts +6 -0
- package/dist/popover/position.d.ts.map +1 -0
- package/dist/popover/sanitize.d.ts +6 -0
- package/dist/popover/sanitize.d.ts.map +1 -0
- package/dist/popover/template.d.ts +9 -0
- package/dist/popover/template.d.ts.map +1 -0
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.js +1617 -0
- package/dist/react/index.js.map +1 -0
- package/dist/utils/cloudimage.d.ts +16 -0
- package/dist/utils/cloudimage.d.ts.map +1 -0
- package/dist/utils/coordinates.d.ts +17 -0
- package/dist/utils/coordinates.d.ts.map +1 -0
- package/dist/utils/dom.d.ts +13 -0
- package/dist/utils/dom.d.ts.map +1 -0
- package/dist/utils/events.d.ts +15 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/zoom/ScrollHint.d.ts +8 -0
- package/dist/zoom/ScrollHint.d.ts.map +1 -0
- package/dist/zoom/ZoomPan.d.ts +51 -0
- package/dist/zoom/ZoomPan.d.ts.map +1 -0
- package/dist/zoom/controls.d.ts +14 -0
- package/dist/zoom/controls.d.ts.map +1 -0
- package/dist/zoom/gestures.d.ts +28 -0
- package/dist/zoom/gestures.d.ts.map +1 -0
- package/dist/zoom/scroll-hint.d.ts +8 -0
- package/dist/zoom/scroll-hint.d.ts.map +1 -0
- package/dist/zoom/zoom-pan.d.ts +53 -0
- package/dist/zoom/zoom-pan.d.ts.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,1981 @@
|
|
|
1
|
+
const $ = "ci-hotspot-styles";
|
|
2
|
+
function K() {
|
|
3
|
+
return typeof window < "u" && typeof document < "u";
|
|
4
|
+
}
|
|
5
|
+
function st(a) {
|
|
6
|
+
if (typeof a == "string") {
|
|
7
|
+
const t = document.querySelector(a);
|
|
8
|
+
if (!t) throw new Error(`CIHotspot: element "${a}" not found`);
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
return a;
|
|
12
|
+
}
|
|
13
|
+
function h(a, t, e) {
|
|
14
|
+
const i = document.createElement(a);
|
|
15
|
+
if (t && (i.className = t), e)
|
|
16
|
+
for (const [o, r] of Object.entries(e))
|
|
17
|
+
i.setAttribute(o, r);
|
|
18
|
+
return i;
|
|
19
|
+
}
|
|
20
|
+
function v(a, ...t) {
|
|
21
|
+
a.classList.add(...t);
|
|
22
|
+
}
|
|
23
|
+
function y(a, ...t) {
|
|
24
|
+
a.classList.remove(...t);
|
|
25
|
+
}
|
|
26
|
+
function Q(a) {
|
|
27
|
+
if (!K() || document.getElementById($)) return;
|
|
28
|
+
const t = document.createElement("style");
|
|
29
|
+
t.id = $, t.textContent = a, document.head.appendChild(t);
|
|
30
|
+
}
|
|
31
|
+
class rt {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
34
|
+
}
|
|
35
|
+
on(t, e) {
|
|
36
|
+
this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(e);
|
|
37
|
+
}
|
|
38
|
+
off(t, e) {
|
|
39
|
+
var i;
|
|
40
|
+
(i = this.listeners.get(t)) == null || i.delete(e);
|
|
41
|
+
}
|
|
42
|
+
emit(t, ...e) {
|
|
43
|
+
var i;
|
|
44
|
+
(i = this.listeners.get(t)) == null || i.forEach((o) => o(...e));
|
|
45
|
+
}
|
|
46
|
+
removeAll() {
|
|
47
|
+
this.listeners.clear();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function f(a, t, e, i) {
|
|
51
|
+
return a.addEventListener(t, e, i), () => a.removeEventListener(t, e, i);
|
|
52
|
+
}
|
|
53
|
+
const nt = {
|
|
54
|
+
alt: "",
|
|
55
|
+
trigger: "hover",
|
|
56
|
+
zoom: !1,
|
|
57
|
+
zoomMax: 4,
|
|
58
|
+
zoomMin: 1,
|
|
59
|
+
theme: "light",
|
|
60
|
+
pulse: !0,
|
|
61
|
+
zoomControls: !0,
|
|
62
|
+
placement: "top",
|
|
63
|
+
lazyLoad: !0,
|
|
64
|
+
sceneTransition: "fade",
|
|
65
|
+
scrollHint: !0,
|
|
66
|
+
invertMarkerTheme: !1,
|
|
67
|
+
fullscreenButton: !0,
|
|
68
|
+
zoomControlsPosition: "bottom-right"
|
|
69
|
+
}, at = {
|
|
70
|
+
"data-ci-hotspot-src": { key: "src", type: "string" },
|
|
71
|
+
"data-ci-hotspot-alt": { key: "alt", type: "string" },
|
|
72
|
+
"data-ci-hotspot-items": { key: "hotspots", type: "json" },
|
|
73
|
+
"data-ci-hotspot-trigger": { key: "trigger", type: "string" },
|
|
74
|
+
"data-ci-hotspot-zoom": { key: "zoom", type: "boolean" },
|
|
75
|
+
"data-ci-hotspot-zoom-max": { key: "zoomMax", type: "number" },
|
|
76
|
+
"data-ci-hotspot-zoom-min": { key: "zoomMin", type: "number" },
|
|
77
|
+
"data-ci-hotspot-theme": { key: "theme", type: "string" },
|
|
78
|
+
"data-ci-hotspot-pulse": { key: "pulse", type: "boolean" },
|
|
79
|
+
"data-ci-hotspot-placement": { key: "placement", type: "string" },
|
|
80
|
+
"data-ci-hotspot-lazy-load": { key: "lazyLoad", type: "boolean" },
|
|
81
|
+
"data-ci-hotspot-zoom-controls": { key: "zoomControls", type: "boolean" },
|
|
82
|
+
"data-ci-hotspot-scroll-hint": { key: "scrollHint", type: "boolean" },
|
|
83
|
+
"data-ci-hotspot-ci-token": { key: "token", type: "string", nested: "cloudimage" },
|
|
84
|
+
"data-ci-hotspot-ci-api-version": { key: "apiVersion", type: "string", nested: "cloudimage" },
|
|
85
|
+
"data-ci-hotspot-ci-domain": { key: "domain", type: "string", nested: "cloudimage" },
|
|
86
|
+
"data-ci-hotspot-ci-limit-factor": { key: "limitFactor", type: "number", nested: "cloudimage" },
|
|
87
|
+
"data-ci-hotspot-ci-params": { key: "params", type: "string", nested: "cloudimage" },
|
|
88
|
+
"data-ci-hotspot-scenes": { key: "scenes", type: "json" },
|
|
89
|
+
"data-ci-hotspot-initial-scene": { key: "initialScene", type: "string" },
|
|
90
|
+
"data-ci-hotspot-scene-transition": { key: "sceneTransition", type: "string" },
|
|
91
|
+
"data-ci-hotspot-scene-aspect-ratio": { key: "sceneAspectRatio", type: "string" },
|
|
92
|
+
"data-ci-hotspot-invert-marker-theme": { key: "invertMarkerTheme", type: "boolean" },
|
|
93
|
+
"data-ci-hotspot-fullscreen-button": { key: "fullscreenButton", type: "boolean" },
|
|
94
|
+
"data-ci-hotspot-zoom-controls-position": { key: "zoomControlsPosition", type: "string" }
|
|
95
|
+
};
|
|
96
|
+
function ct(a) {
|
|
97
|
+
const t = {}, e = {};
|
|
98
|
+
for (const [i, o] of Object.entries(at)) {
|
|
99
|
+
const r = a.getAttribute(i);
|
|
100
|
+
if (r === null) continue;
|
|
101
|
+
const s = lt(r, o.type);
|
|
102
|
+
o.nested === "cloudimage" ? e[o.key] = s : t[o.key] = s;
|
|
103
|
+
}
|
|
104
|
+
return Object.keys(e).length > 0 && (t.cloudimage = e), t;
|
|
105
|
+
}
|
|
106
|
+
function lt(a, t) {
|
|
107
|
+
switch (t) {
|
|
108
|
+
case "boolean":
|
|
109
|
+
return a === "true";
|
|
110
|
+
case "number": {
|
|
111
|
+
const e = parseFloat(a);
|
|
112
|
+
if (isNaN(e)) {
|
|
113
|
+
console.warn(`CIHotspot: invalid number value "${a}"`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
return e;
|
|
117
|
+
}
|
|
118
|
+
case "json":
|
|
119
|
+
try {
|
|
120
|
+
return JSON.parse(a);
|
|
121
|
+
} catch {
|
|
122
|
+
console.warn(`CIHotspot: failed to parse JSON value "${a}"`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
default:
|
|
126
|
+
return a;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function X(a) {
|
|
130
|
+
return {
|
|
131
|
+
...nt,
|
|
132
|
+
...a,
|
|
133
|
+
src: a.src || "",
|
|
134
|
+
hotspots: a.hotspots || []
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function j(a) {
|
|
138
|
+
if (a.scenes && a.scenes.length > 0) {
|
|
139
|
+
const t = /* @__PURE__ */ new Set();
|
|
140
|
+
for (const e of a.scenes) {
|
|
141
|
+
if (!e.id) throw new Error('CIHotspot: each scene must have an "id"');
|
|
142
|
+
if (t.has(e.id))
|
|
143
|
+
throw new Error(`CIHotspot: duplicate scene ID "${e.id}"`);
|
|
144
|
+
if (t.add(e.id), !e.src) throw new Error(`CIHotspot: scene "${e.id}" must have a "src"`);
|
|
145
|
+
}
|
|
146
|
+
for (const e of a.scenes)
|
|
147
|
+
for (const i of e.hotspots || [])
|
|
148
|
+
if (i.navigateTo && !t.has(i.navigateTo))
|
|
149
|
+
throw new Error(`CIHotspot: hotspot "${i.id}" navigateTo "${i.navigateTo}" is not a valid scene ID`);
|
|
150
|
+
if (a.initialScene && !t.has(a.initialScene))
|
|
151
|
+
throw new Error(`CIHotspot: initialScene "${a.initialScene}" not found in scenes`);
|
|
152
|
+
} else if (!a.src)
|
|
153
|
+
throw new Error('CIHotspot: "src" is required');
|
|
154
|
+
}
|
|
155
|
+
function Z(a) {
|
|
156
|
+
if (typeof a == "string") {
|
|
157
|
+
const t = a.trim();
|
|
158
|
+
return t.endsWith("%") ? { value: parseFloat(t), isPercent: !0 } : { value: parseFloat(t), isPercent: !1 };
|
|
159
|
+
}
|
|
160
|
+
return { value: a, isPercent: !1 };
|
|
161
|
+
}
|
|
162
|
+
function V(a, t, e, i) {
|
|
163
|
+
const o = Z(a), r = Z(t);
|
|
164
|
+
return {
|
|
165
|
+
x: o.isPercent ? o.value : o.value / e * 100,
|
|
166
|
+
y: r.isPercent ? r.value : r.value / i * 100
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function dt(a, t) {
|
|
170
|
+
const e = h("button", "ci-hotspot-marker", {
|
|
171
|
+
"aria-label": a.label,
|
|
172
|
+
"aria-expanded": "false",
|
|
173
|
+
"data-hotspot-id": a.id,
|
|
174
|
+
tabindex: "0"
|
|
175
|
+
});
|
|
176
|
+
if (e.style.left = `${a.x}%`, e.style.top = `${a.y}%`, a.className) {
|
|
177
|
+
const i = a.className.trim().split(/\s+/).filter(Boolean);
|
|
178
|
+
i.length && v(e, ...i);
|
|
179
|
+
}
|
|
180
|
+
return a.hidden && v(e, "ci-hotspot-marker--hidden"), t && v(e, "ci-hotspot-marker--pulse"), a.icon && ut(e, a.icon), e;
|
|
181
|
+
}
|
|
182
|
+
function ht(a) {
|
|
183
|
+
if (typeof DOMParser > "u") return "";
|
|
184
|
+
const e = new DOMParser().parseFromString(a, "image/svg+xml").documentElement;
|
|
185
|
+
return e.querySelector("parsererror") ? "" : (tt(e), new XMLSerializer().serializeToString(e));
|
|
186
|
+
}
|
|
187
|
+
const pt = /* @__PURE__ */ new Set([
|
|
188
|
+
"script",
|
|
189
|
+
"foreignobject",
|
|
190
|
+
"iframe",
|
|
191
|
+
"object",
|
|
192
|
+
"embed",
|
|
193
|
+
"animate",
|
|
194
|
+
"animatetransform",
|
|
195
|
+
"animatemotion",
|
|
196
|
+
"set",
|
|
197
|
+
"style",
|
|
198
|
+
"a",
|
|
199
|
+
"use",
|
|
200
|
+
"image",
|
|
201
|
+
"feimage"
|
|
202
|
+
]);
|
|
203
|
+
function tt(a) {
|
|
204
|
+
for (const t of Array.from(a.attributes)) {
|
|
205
|
+
const e = t.name.toLowerCase();
|
|
206
|
+
(e.startsWith("on") || e === "style" || (e === "href" || e === "xlink:href") && /^\s*javascript\s*:/i.test(t.value)) && a.removeAttribute(t.name);
|
|
207
|
+
}
|
|
208
|
+
for (const t of Array.from(a.children)) {
|
|
209
|
+
if (pt.has(t.tagName.toLowerCase())) {
|
|
210
|
+
t.remove();
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
tt(t);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function ut(a, t) {
|
|
217
|
+
const e = t.trim();
|
|
218
|
+
if (/^<svg[\s>]/i.test(e) || /^<\?xml/i.test(e))
|
|
219
|
+
a.innerHTML = ht(t);
|
|
220
|
+
else if (t.match(/\.(png|jpg|jpeg|gif|svg|webp)$/i) || t.startsWith("http") || t.startsWith("/")) {
|
|
221
|
+
const i = h("img", void 0, {
|
|
222
|
+
src: t,
|
|
223
|
+
alt: "",
|
|
224
|
+
"aria-hidden": "true"
|
|
225
|
+
});
|
|
226
|
+
i.style.width = "100%", i.style.height = "100%", i.style.objectFit = "contain", a.appendChild(i);
|
|
227
|
+
} else {
|
|
228
|
+
const i = h("span", t, { "aria-hidden": "true" });
|
|
229
|
+
a.appendChild(i);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function g(a, t) {
|
|
233
|
+
t ? (v(a, "ci-hotspot-marker--active"), a.setAttribute("aria-expanded", "true")) : (y(a, "ci-hotspot-marker--active"), a.setAttribute("aria-expanded", "false"));
|
|
234
|
+
}
|
|
235
|
+
function ft(a, t) {
|
|
236
|
+
t ? v(a, "ci-hotspot-marker--hidden") : y(a, "ci-hotspot-marker--hidden");
|
|
237
|
+
}
|
|
238
|
+
function I(a) {
|
|
239
|
+
a.remove();
|
|
240
|
+
}
|
|
241
|
+
function gt(a, t, e, i) {
|
|
242
|
+
const o = a.getBoundingClientRect(), r = e.getBoundingClientRect(), s = t.offsetWidth, n = t.offsetHeight, c = o.left + o.width / 2 - r.left, l = o.top + o.height / 2 - r.top, d = o.top - r.top, u = o.bottom - r.top, p = o.left - r.left, m = o.right - r.left, b = e.offsetWidth, k = e.offsetHeight, x = 8, H = {
|
|
243
|
+
top: d - x,
|
|
244
|
+
bottom: k - u - x,
|
|
245
|
+
left: p - x,
|
|
246
|
+
right: b - m - x
|
|
247
|
+
};
|
|
248
|
+
let w = i.placement;
|
|
249
|
+
w === "auto" && (w = mt(H)), w = vt(w, s, n, H);
|
|
250
|
+
let T, S, N = 0;
|
|
251
|
+
switch (w) {
|
|
252
|
+
case "top":
|
|
253
|
+
T = c - s / 2, S = d - x - n;
|
|
254
|
+
break;
|
|
255
|
+
case "bottom":
|
|
256
|
+
T = c - s / 2, S = u + x;
|
|
257
|
+
break;
|
|
258
|
+
case "left":
|
|
259
|
+
T = p - x - s, S = l - n / 2;
|
|
260
|
+
break;
|
|
261
|
+
case "right":
|
|
262
|
+
T = m + x, S = l - n / 2;
|
|
263
|
+
break;
|
|
264
|
+
default:
|
|
265
|
+
T = c - s / 2, S = d - x - n;
|
|
266
|
+
}
|
|
267
|
+
const L = bt(T, S, s, n, b, k);
|
|
268
|
+
return N = w === "top" || w === "bottom" ? T - L.x : S - L.y, {
|
|
269
|
+
x: L.x,
|
|
270
|
+
y: L.y,
|
|
271
|
+
placement: w,
|
|
272
|
+
arrowOffset: N
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function mt(a) {
|
|
276
|
+
const t = Math.max(a.top, a.bottom, a.left, a.right);
|
|
277
|
+
return t === a.top ? "top" : t === a.bottom ? "bottom" : t === a.right ? "right" : "left";
|
|
278
|
+
}
|
|
279
|
+
function vt(a, t, e, i) {
|
|
280
|
+
const o = a;
|
|
281
|
+
switch (o) {
|
|
282
|
+
case "top":
|
|
283
|
+
if (i.top < e && i.bottom > i.top) return "bottom";
|
|
284
|
+
break;
|
|
285
|
+
case "bottom":
|
|
286
|
+
if (i.bottom < e && i.top > i.bottom) return "top";
|
|
287
|
+
break;
|
|
288
|
+
case "left":
|
|
289
|
+
if (i.left < t && i.right > i.left) return "right";
|
|
290
|
+
break;
|
|
291
|
+
case "right":
|
|
292
|
+
if (i.right < t && i.left > i.right) return "left";
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
return o;
|
|
296
|
+
}
|
|
297
|
+
function bt(a, t, e, i, o, r) {
|
|
298
|
+
let n = a, c = t;
|
|
299
|
+
return e > o - 2 * 4 ? n = (o - e) / 2 : (n < 4 && (n = 4), n + e > o - 4 && (n = o - 4 - e)), i > r - 2 * 4 ? c = (r - i) / 2 : (c < 4 && (c = 4), c + i > r - 4 && (c = r - 4 - i)), { x: n, y: c };
|
|
300
|
+
}
|
|
301
|
+
const yt = /* @__PURE__ */ new Set([
|
|
302
|
+
"a",
|
|
303
|
+
"b",
|
|
304
|
+
"br",
|
|
305
|
+
"div",
|
|
306
|
+
"em",
|
|
307
|
+
"h1",
|
|
308
|
+
"h2",
|
|
309
|
+
"h3",
|
|
310
|
+
"h4",
|
|
311
|
+
"h5",
|
|
312
|
+
"h6",
|
|
313
|
+
"i",
|
|
314
|
+
"img",
|
|
315
|
+
"li",
|
|
316
|
+
"ol",
|
|
317
|
+
"p",
|
|
318
|
+
"span",
|
|
319
|
+
"strong",
|
|
320
|
+
"ul"
|
|
321
|
+
]), xt = /* @__PURE__ */ new Set([
|
|
322
|
+
"class",
|
|
323
|
+
"href",
|
|
324
|
+
"src",
|
|
325
|
+
"alt",
|
|
326
|
+
"title",
|
|
327
|
+
"target",
|
|
328
|
+
"rel"
|
|
329
|
+
]), kt = /^(?:https?:|mailto:)/i, wt = /^(?:https?:|data:image\/(?!svg[+%]))/i, Et = /* @__PURE__ */ new Set([
|
|
330
|
+
"noopener",
|
|
331
|
+
"noreferrer",
|
|
332
|
+
"nofollow",
|
|
333
|
+
"external",
|
|
334
|
+
"author",
|
|
335
|
+
"help",
|
|
336
|
+
"license",
|
|
337
|
+
"next",
|
|
338
|
+
"prev",
|
|
339
|
+
"search",
|
|
340
|
+
"tag",
|
|
341
|
+
"bookmark"
|
|
342
|
+
]);
|
|
343
|
+
function Ct(a) {
|
|
344
|
+
const i = new DOMParser().parseFromString(`<body>${a}</body>`, "text/html").body;
|
|
345
|
+
return et(i), i.innerHTML;
|
|
346
|
+
}
|
|
347
|
+
function et(a) {
|
|
348
|
+
const t = Array.from(a.childNodes);
|
|
349
|
+
for (const e of t)
|
|
350
|
+
if (e.nodeType !== Node.TEXT_NODE)
|
|
351
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
352
|
+
const i = e, o = i.tagName.toLowerCase();
|
|
353
|
+
if (!yt.has(o)) {
|
|
354
|
+
i.remove();
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const r = Array.from(i.attributes);
|
|
358
|
+
for (const s of r) {
|
|
359
|
+
const n = s.name.toLowerCase();
|
|
360
|
+
if (n.startsWith("on")) {
|
|
361
|
+
i.removeAttribute(s.name);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (!xt.has(n)) {
|
|
365
|
+
i.removeAttribute(s.name);
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (n === "href" && !kt.test(s.value.trim()))
|
|
369
|
+
i.removeAttribute(s.name);
|
|
370
|
+
else if (n === "src" && !wt.test(s.value.trim()))
|
|
371
|
+
i.removeAttribute(s.name);
|
|
372
|
+
else if (n === "rel") {
|
|
373
|
+
const c = s.value.trim().toLowerCase().split(/\s+/).filter((l) => Et.has(l));
|
|
374
|
+
c.length === 0 ? i.removeAttribute(s.name) : i.setAttribute(s.name, c.join(" "));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
et(i);
|
|
378
|
+
} else
|
|
379
|
+
e.remove();
|
|
380
|
+
}
|
|
381
|
+
function Tt(a) {
|
|
382
|
+
const t = [];
|
|
383
|
+
a.image && t.push(`<img class="ci-hotspot-popover-image" src="${F(a.image)}" alt="${F(a.title || "")}">`);
|
|
384
|
+
const e = [];
|
|
385
|
+
if (a.title && e.push(`<h3 class="ci-hotspot-popover-title">${P(a.title)}</h3>`), a.price && e.push(`<span class="ci-hotspot-popover-price">${P(a.price)}</span>`), a.description && e.push(`<p class="ci-hotspot-popover-description">${P(a.description)}</p>`), a.url && zt(a.url)) {
|
|
386
|
+
const i = a.ctaText || "View details";
|
|
387
|
+
e.push(
|
|
388
|
+
`<a class="ci-hotspot-popover-cta" href="${F(a.url)}">${P(String(i))}</a>`
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
return e.length > 0 && t.push(`<div class="ci-hotspot-popover-body">${e.join("")}</div>`), t.join("");
|
|
392
|
+
}
|
|
393
|
+
function St(a, t) {
|
|
394
|
+
return t ? t(a) : a.content ? Ct(a.content) : a.data ? Tt(a.data) : "";
|
|
395
|
+
}
|
|
396
|
+
function P(a) {
|
|
397
|
+
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
398
|
+
}
|
|
399
|
+
function zt(a) {
|
|
400
|
+
const t = a.replace(/[\s\x00-\x1f]/g, "");
|
|
401
|
+
return /^https?:\/\//i.test(t) || /^\/(?!\/)/.test(t) || /^#/.test(t);
|
|
402
|
+
}
|
|
403
|
+
function F(a) {
|
|
404
|
+
return a.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
405
|
+
}
|
|
406
|
+
class W {
|
|
407
|
+
constructor(t, e) {
|
|
408
|
+
this.visible = !1, this.markerEl = null, this.containerEl = null, this.hoverCleanups = [], this.hotspot = t, this.options = e;
|
|
409
|
+
const i = e.triggerMode === "click" || e.triggerMode === "load";
|
|
410
|
+
this.element = h("div", "ci-hotspot-popover", {
|
|
411
|
+
role: i ? "dialog" : "tooltip",
|
|
412
|
+
id: `ci-hotspot-popover-${t.id}`,
|
|
413
|
+
"aria-hidden": "true",
|
|
414
|
+
"data-placement": e.placement === "auto" ? "top" : e.placement,
|
|
415
|
+
...i && t.label ? { "aria-label": t.label } : {}
|
|
416
|
+
}), this.arrowEl = h("div", "ci-hotspot-popover-arrow"), this.contentEl = h("div", "ci-hotspot-popover-content"), this.element.appendChild(this.arrowEl), this.element.appendChild(this.contentEl);
|
|
417
|
+
const o = St(t, e.renderFn);
|
|
418
|
+
if (typeof o == "string" ? this.contentEl.innerHTML = o : o instanceof HTMLElement && this.contentEl.appendChild(o), e.triggerMode === "hover") {
|
|
419
|
+
const r = () => this.clearHideTimer(), s = () => this.scheduleHide();
|
|
420
|
+
this.element.addEventListener("mouseenter", r), this.element.addEventListener("mouseleave", s), this.hoverCleanups.push(
|
|
421
|
+
() => this.element.removeEventListener("mouseenter", r),
|
|
422
|
+
() => this.element.removeEventListener("mouseleave", s)
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
/** Mount the popover to a container, associating it with a marker */
|
|
427
|
+
mount(t, e) {
|
|
428
|
+
this.containerEl = t, this.markerEl = e, t.appendChild(this.element), this.options.triggerMode === "click" || this.options.triggerMode === "load" ? (e.setAttribute("aria-haspopup", "dialog"), e.setAttribute("aria-controls", this.element.id)) : e.setAttribute("aria-describedby", this.element.id);
|
|
429
|
+
}
|
|
430
|
+
/** Show the popover */
|
|
431
|
+
show() {
|
|
432
|
+
var t, e;
|
|
433
|
+
this.clearHideTimer(), !this.visible && (this.visible = !0, v(this.element, "ci-hotspot-popover--visible"), this.element.setAttribute("aria-hidden", "false"), this.updatePosition(), (e = (t = this.options).onOpen) == null || e.call(t, this.hotspot));
|
|
434
|
+
}
|
|
435
|
+
/** Schedule hide with delay (for hover mode) */
|
|
436
|
+
scheduleHide(t = 200) {
|
|
437
|
+
this.clearHideTimer(), this.hideTimer = setTimeout(() => {
|
|
438
|
+
this.hide();
|
|
439
|
+
}, t);
|
|
440
|
+
}
|
|
441
|
+
/** Hide the popover immediately */
|
|
442
|
+
hide() {
|
|
443
|
+
var t, e;
|
|
444
|
+
this.clearHideTimer(), this.visible && (this.visible = !1, y(this.element, "ci-hotspot-popover--visible"), this.element.setAttribute("aria-hidden", "true"), (e = (t = this.options).onClose) == null || e.call(t, this.hotspot));
|
|
445
|
+
}
|
|
446
|
+
/** Clear any pending hide timer */
|
|
447
|
+
clearHideTimer() {
|
|
448
|
+
this.hideTimer !== void 0 && (clearTimeout(this.hideTimer), this.hideTimer = void 0);
|
|
449
|
+
}
|
|
450
|
+
/** Update popover position relative to marker */
|
|
451
|
+
updatePosition() {
|
|
452
|
+
if (!this.markerEl || !this.containerEl || !this.visible) return;
|
|
453
|
+
const t = gt(
|
|
454
|
+
this.markerEl,
|
|
455
|
+
this.element,
|
|
456
|
+
this.containerEl,
|
|
457
|
+
{ placement: this.options.placement }
|
|
458
|
+
);
|
|
459
|
+
this.element.style.left = `${t.x}px`, this.element.style.top = `${t.y}px`, this.element.setAttribute("data-placement", t.placement), this.positionArrow(t.placement, t.arrowOffset);
|
|
460
|
+
}
|
|
461
|
+
positionArrow(t, e) {
|
|
462
|
+
const i = this.arrowEl;
|
|
463
|
+
i.style.left = "", i.style.top = "", t === "top" || t === "bottom" ? i.style.left = `calc(50% - var(--ci-hotspot-arrow-size) + ${e}px)` : i.style.top = `calc(50% - var(--ci-hotspot-arrow-size) + ${e}px)`;
|
|
464
|
+
}
|
|
465
|
+
/** Check if popover is currently visible */
|
|
466
|
+
isVisible() {
|
|
467
|
+
return this.visible;
|
|
468
|
+
}
|
|
469
|
+
/** Get the hotspot associated with this popover */
|
|
470
|
+
getHotspot() {
|
|
471
|
+
return this.hotspot;
|
|
472
|
+
}
|
|
473
|
+
/** Destroy the popover and clean up */
|
|
474
|
+
destroy() {
|
|
475
|
+
var t, e, i;
|
|
476
|
+
this.clearHideTimer(), this.hoverCleanups.forEach((o) => o()), this.hoverCleanups = [], (t = this.markerEl) == null || t.removeAttribute("aria-describedby"), (e = this.markerEl) == null || e.removeAttribute("aria-controls"), (i = this.markerEl) == null || i.removeAttribute("aria-haspopup"), this.element.remove(), this.markerEl = null, this.containerEl = null;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
class Mt {
|
|
480
|
+
constructor(t, e, i) {
|
|
481
|
+
this.lastTouchEnd = 0, this.initialPinchDistance = 0, this.initialPinchScale = 1, this.panStartX = 0, this.panStartY = 0, this.isPinching = !1, this.isPanning = !1, this.wasPinching = !1, this.cleanups = [], this.el = t, this.callbacks = e, this.initialPinchScale = i();
|
|
482
|
+
const o = (n) => this.handleTouchStart(n, i), r = (n) => this.handleTouchMove(n), s = (n) => this.handleTouchEnd(n);
|
|
483
|
+
t.addEventListener("touchstart", o, { passive: !1 }), t.addEventListener("touchmove", r, { passive: !1 }), t.addEventListener("touchend", s, { passive: !0 }), this.cleanups.push(
|
|
484
|
+
() => t.removeEventListener("touchstart", o),
|
|
485
|
+
() => t.removeEventListener("touchmove", r),
|
|
486
|
+
() => t.removeEventListener("touchend", s)
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
handleTouchStart(t, e) {
|
|
490
|
+
t.touches.length === 2 ? (t.preventDefault(), this.isPinching = !0, this.wasPinching = !1, this.initialPinchDistance = this.getTouchDistance(t.touches), this.initialPinchScale = e()) : t.touches.length === 1 && (this.panStartX = t.touches[0].clientX, this.panStartY = t.touches[0].clientY, this.wasPinching = !1);
|
|
491
|
+
}
|
|
492
|
+
handleTouchMove(t) {
|
|
493
|
+
var e, i, o, r, s, n;
|
|
494
|
+
if (t.touches.length === 2 && this.isPinching) {
|
|
495
|
+
t.preventDefault();
|
|
496
|
+
const c = this.getTouchDistance(t.touches), l = this.initialPinchScale * (c / this.initialPinchDistance), d = (t.touches[0].clientX + t.touches[1].clientX) / 2, u = (t.touches[0].clientY + t.touches[1].clientY) / 2;
|
|
497
|
+
(i = (e = this.callbacks).onPinch) == null || i.call(e, l, d, u);
|
|
498
|
+
} else if (t.touches.length === 1 && !this.isPinching && !this.wasPinching) {
|
|
499
|
+
this.isPanning || (this.isPanning = !0, (r = (o = this.callbacks).onPanStart) == null || r.call(o));
|
|
500
|
+
const c = t.touches[0].clientX - this.panStartX, l = t.touches[0].clientY - this.panStartY;
|
|
501
|
+
(n = (s = this.callbacks).onPan) == null || n.call(s, c, l);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
handleTouchEnd(t) {
|
|
505
|
+
var e, i, o, r;
|
|
506
|
+
if (this.isPinching && t.touches.length < 2 && (this.isPinching = !1, this.wasPinching = !0, t.touches.length === 1 && (this.panStartX = t.touches[0].clientX, this.panStartY = t.touches[0].clientY)), this.isPanning && (this.isPanning = !1, (i = (e = this.callbacks).onPanEnd) == null || i.call(e)), t.changedTouches.length === 1 && t.touches.length === 0) {
|
|
507
|
+
if (this.wasPinching) {
|
|
508
|
+
this.wasPinching = !1, this.lastTouchEnd = 0;
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
const s = Date.now();
|
|
512
|
+
if (s - this.lastTouchEnd < 300) {
|
|
513
|
+
const n = t.changedTouches[0];
|
|
514
|
+
(r = (o = this.callbacks).onDoubleTap) == null || r.call(o, n.clientX, n.clientY);
|
|
515
|
+
}
|
|
516
|
+
this.lastTouchEnd = s;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
getTouchDistance(t) {
|
|
520
|
+
const e = t[0].clientX - t[1].clientX, i = t[0].clientY - t[1].clientY;
|
|
521
|
+
return Math.sqrt(e * e + i * i);
|
|
522
|
+
}
|
|
523
|
+
destroy() {
|
|
524
|
+
this.cleanups.forEach((t) => t()), this.cleanups = [];
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
class Ht {
|
|
528
|
+
constructor(t, e, i) {
|
|
529
|
+
this.zoom = 1, this.panX = 0, this.panY = 0, this.enabled = !0, this.isDragging = !1, this.dragStartX = 0, this.dragStartY = 0, this.lastPanX = 0, this.lastPanY = 0, this.gestures = null, this.isGesturing = !1, this.gestureStartZoom = 1, this.touchStartPanX = 0, this.touchStartPanY = 0, this.cleanups = [], this.viewport = t, this.container = e, this.options = i, this.bindEvents();
|
|
530
|
+
}
|
|
531
|
+
bindEvents() {
|
|
532
|
+
const t = (s) => {
|
|
533
|
+
var p, m;
|
|
534
|
+
if (!this.enabled) return;
|
|
535
|
+
if (this.isGesturing) {
|
|
536
|
+
s.preventDefault();
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
if (!s.ctrlKey) {
|
|
540
|
+
(m = (p = this.options).onScrollWithoutZoom) == null || m.call(p);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
s.preventDefault();
|
|
544
|
+
const n = this.container.getBoundingClientRect(), c = s.clientX - n.left, l = s.clientY - n.top;
|
|
545
|
+
let d = s.deltaY;
|
|
546
|
+
s.deltaMode === 1 && (d *= 20);
|
|
547
|
+
const u = -d * 0.01;
|
|
548
|
+
this.setZoom(this.zoom + u, c, l);
|
|
549
|
+
};
|
|
550
|
+
this.container.addEventListener("wheel", t, { passive: !1 }), this.cleanups.push(() => this.container.removeEventListener("wheel", t)), this.bindSafariGestures();
|
|
551
|
+
const e = (s) => {
|
|
552
|
+
if (!this.enabled) return;
|
|
553
|
+
const n = this.container.getBoundingClientRect(), c = s.clientX - n.left, l = s.clientY - n.top;
|
|
554
|
+
this.zoom > 1 ? this.resetZoom() : this.setZoom(2, c, l);
|
|
555
|
+
};
|
|
556
|
+
this.container.addEventListener("dblclick", e), this.cleanups.push(() => this.container.removeEventListener("dblclick", e));
|
|
557
|
+
const i = (s) => {
|
|
558
|
+
!this.enabled || this.zoom <= 1 || s.button === 0 && (this.isDragging = !0, this.dragStartX = s.clientX, this.dragStartY = s.clientY, this.lastPanX = this.panX, this.lastPanY = this.panY, v(this.viewport, "ci-hotspot-viewport--dragging"), this.container.style.cursor = "grabbing", s.preventDefault());
|
|
559
|
+
}, o = (s) => {
|
|
560
|
+
if (!this.isDragging) return;
|
|
561
|
+
const n = (s.clientX - this.dragStartX) / this.zoom, c = (s.clientY - this.dragStartY) / this.zoom;
|
|
562
|
+
this.panX = this.lastPanX + n, this.panY = this.lastPanY + c, this.clampPan(), this.applyTransform();
|
|
563
|
+
}, r = () => {
|
|
564
|
+
this.isDragging && (this.isDragging = !1, y(this.viewport, "ci-hotspot-viewport--dragging"), this.container.style.cursor = this.zoom > 1 ? "grab" : "");
|
|
565
|
+
};
|
|
566
|
+
this.container.addEventListener("mousedown", i), document.addEventListener("mousemove", o), document.addEventListener("mouseup", r), this.cleanups.push(
|
|
567
|
+
() => this.container.removeEventListener("mousedown", i),
|
|
568
|
+
() => document.removeEventListener("mousemove", o),
|
|
569
|
+
() => document.removeEventListener("mouseup", r)
|
|
570
|
+
), this.gestures = new Mt(
|
|
571
|
+
this.container,
|
|
572
|
+
{
|
|
573
|
+
onPinch: (s, n, c) => {
|
|
574
|
+
const l = this.container.getBoundingClientRect();
|
|
575
|
+
this.setZoom(s, n - l.left, c - l.top);
|
|
576
|
+
},
|
|
577
|
+
onPanStart: () => {
|
|
578
|
+
this.touchStartPanX = this.panX, this.touchStartPanY = this.panY;
|
|
579
|
+
},
|
|
580
|
+
onPan: (s, n) => {
|
|
581
|
+
this.zoom <= 1 || (this.panX = this.touchStartPanX + s / this.zoom, this.panY = this.touchStartPanY + n / this.zoom, this.clampPan(), this.applyTransform());
|
|
582
|
+
},
|
|
583
|
+
onDoubleTap: (s, n) => {
|
|
584
|
+
const c = this.container.getBoundingClientRect();
|
|
585
|
+
this.zoom > 1 ? this.resetZoom() : this.setZoom(2, s - c.left, n - c.top);
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
() => this.zoom
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
bindSafariGestures() {
|
|
592
|
+
if (typeof window > "u" || !("GestureEvent" in window)) return;
|
|
593
|
+
const t = (o) => {
|
|
594
|
+
o.preventDefault(), this.isGesturing = !0, this.gestureStartZoom = this.zoom;
|
|
595
|
+
}, e = (o) => {
|
|
596
|
+
if (o.preventDefault(), !this.enabled) return;
|
|
597
|
+
const r = o, s = this.container.getBoundingClientRect(), n = o, c = n.clientX != null ? n.clientX - s.left : s.width / 2, l = n.clientY != null ? n.clientY - s.top : s.height / 2;
|
|
598
|
+
this.setZoom(this.gestureStartZoom * r.scale, c, l);
|
|
599
|
+
}, i = (o) => {
|
|
600
|
+
o.preventDefault(), this.isGesturing = !1;
|
|
601
|
+
};
|
|
602
|
+
this.container.addEventListener("gesturestart", t), this.container.addEventListener("gesturechange", e), this.container.addEventListener("gestureend", i), this.cleanups.push(
|
|
603
|
+
() => this.container.removeEventListener("gesturestart", t),
|
|
604
|
+
() => this.container.removeEventListener("gesturechange", e),
|
|
605
|
+
() => this.container.removeEventListener("gestureend", i)
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
setZoom(t, e, i) {
|
|
609
|
+
var r, s;
|
|
610
|
+
const o = this.zoom;
|
|
611
|
+
if (this.zoom = Math.max(this.options.zoomMin, Math.min(this.options.zoomMax, t)), e !== void 0 && i !== void 0 && o !== this.zoom) {
|
|
612
|
+
const n = this.container.offsetWidth, c = this.container.offsetHeight, l = this.zoom / o, d = e / n, u = i / c;
|
|
613
|
+
this.panX = this.panX - n * d * (l - 1) / this.zoom, this.panY = this.panY - c * u * (l - 1) / this.zoom;
|
|
614
|
+
}
|
|
615
|
+
this.clampPan(), this.applyTransform(), this.updateCursor(), (s = (r = this.options).onZoom) == null || s.call(r, this.zoom);
|
|
616
|
+
}
|
|
617
|
+
getZoom() {
|
|
618
|
+
return this.zoom;
|
|
619
|
+
}
|
|
620
|
+
resetZoom() {
|
|
621
|
+
var t, e;
|
|
622
|
+
this.zoom = 1, this.panX = 0, this.panY = 0, this.applyTransform(), this.updateCursor(), (e = (t = this.options).onZoom) == null || e.call(t, 1);
|
|
623
|
+
}
|
|
624
|
+
pan(t, e) {
|
|
625
|
+
this.zoom <= 1 || (this.panX += t / this.zoom, this.panY += e / this.zoom, this.clampPan(), this.applyTransform());
|
|
626
|
+
}
|
|
627
|
+
enable() {
|
|
628
|
+
this.enabled = !0;
|
|
629
|
+
}
|
|
630
|
+
disable() {
|
|
631
|
+
this.enabled = !1;
|
|
632
|
+
}
|
|
633
|
+
clampPan() {
|
|
634
|
+
const t = this.container.offsetWidth, e = this.container.offsetHeight, i = t * (this.zoom - 1) / this.zoom, o = e * (this.zoom - 1) / this.zoom;
|
|
635
|
+
this.panX = Math.max(-i, Math.min(0, this.panX)), this.panY = Math.max(-o, Math.min(0, this.panY)), this.zoom <= 1 && (this.panX = 0, this.panY = 0);
|
|
636
|
+
}
|
|
637
|
+
applyTransform() {
|
|
638
|
+
this.viewport.style.transform = `scale(${this.zoom}) translate(${this.panX}px, ${this.panY}px)`, this.viewport.style.setProperty("--zoom", String(this.zoom));
|
|
639
|
+
}
|
|
640
|
+
updateCursor() {
|
|
641
|
+
this.isDragging || (this.container.style.cursor = this.zoom > 1 ? "grab" : "");
|
|
642
|
+
}
|
|
643
|
+
destroy() {
|
|
644
|
+
var t;
|
|
645
|
+
this.cleanups.forEach((e) => e()), this.cleanups = [], (t = this.gestures) == null || t.destroy(), this.gestures = null, this.viewport.style.transform = "", this.viewport.style.removeProperty("--zoom"), this.container.style.cursor = "";
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function Lt(a, t, e) {
|
|
649
|
+
const i = e.zoomStep || 0.5, o = h("div", "ci-hotspot-zoom-controls");
|
|
650
|
+
o.dataset.position = e.position || "bottom-right";
|
|
651
|
+
const r = h("button", "ci-hotspot-zoom-in", {
|
|
652
|
+
"aria-label": "Zoom in",
|
|
653
|
+
type: "button"
|
|
654
|
+
});
|
|
655
|
+
r.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>';
|
|
656
|
+
const s = h("button", "ci-hotspot-zoom-out", {
|
|
657
|
+
"aria-label": "Zoom out",
|
|
658
|
+
type: "button"
|
|
659
|
+
});
|
|
660
|
+
s.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>';
|
|
661
|
+
const n = h("button", "ci-hotspot-zoom-reset", {
|
|
662
|
+
"aria-label": "Reset zoom",
|
|
663
|
+
type: "button"
|
|
664
|
+
});
|
|
665
|
+
n.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>', o.appendChild(r), o.appendChild(s), o.appendChild(n), r.addEventListener("click", (l) => {
|
|
666
|
+
l.stopPropagation(), t.setZoom(t.getZoom() + i), c();
|
|
667
|
+
}), s.addEventListener("click", (l) => {
|
|
668
|
+
l.stopPropagation(), t.setZoom(t.getZoom() - i), c();
|
|
669
|
+
}), n.addEventListener("click", (l) => {
|
|
670
|
+
l.stopPropagation(), t.resetZoom(), c();
|
|
671
|
+
});
|
|
672
|
+
function c() {
|
|
673
|
+
const l = t.getZoom();
|
|
674
|
+
r.disabled = l >= e.zoomMax, s.disabled = l <= e.zoomMin, n.disabled = Math.abs(l - 1) < 1e-3;
|
|
675
|
+
}
|
|
676
|
+
return a.appendChild(o), c(), {
|
|
677
|
+
element: o,
|
|
678
|
+
update: c,
|
|
679
|
+
destroy: () => o.remove()
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
const It = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/i.test(navigator.userAgent), Pt = It ? "⌘ Scroll or pinch to zoom" : "Ctrl + scroll to zoom", At = 1500;
|
|
683
|
+
class Dt {
|
|
684
|
+
constructor(t) {
|
|
685
|
+
this.hideTimer = null, this.el = document.createElement("div"), this.el.className = "ci-hotspot-scroll-hint", this.el.textContent = Pt, this.el.setAttribute("aria-hidden", "true"), t.appendChild(this.el);
|
|
686
|
+
}
|
|
687
|
+
show() {
|
|
688
|
+
this.hideTimer !== null && clearTimeout(this.hideTimer), this.el.classList.add("ci-hotspot-scroll-hint--visible"), this.hideTimer = setTimeout(() => {
|
|
689
|
+
this.el.classList.remove("ci-hotspot-scroll-hint--visible"), this.hideTimer = null;
|
|
690
|
+
}, At);
|
|
691
|
+
}
|
|
692
|
+
destroy() {
|
|
693
|
+
this.hideTimer !== null && (clearTimeout(this.hideTimer), this.hideTimer = null), this.el.remove();
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
const Bt = "cloudimg.io", Ft = "v7", B = 100;
|
|
697
|
+
function Rt(a, t = B) {
|
|
698
|
+
return Math.ceil(a / t) * t;
|
|
699
|
+
}
|
|
700
|
+
function it(a, t = 1, e = 1, i = B) {
|
|
701
|
+
const o = a * t * e;
|
|
702
|
+
return Rt(o, i);
|
|
703
|
+
}
|
|
704
|
+
function z(a, t, e, i = 1, o = 1) {
|
|
705
|
+
const r = t.domain || Bt, s = t.apiVersion || Ft, n = t.limitFactor || B, c = it(e, o, i, n), l = encodeURI(a);
|
|
706
|
+
let d = `https://${t.token}.${r}/${s}/${l}?width=${c}`;
|
|
707
|
+
return t.params && (d += `&${t.params}`), d;
|
|
708
|
+
}
|
|
709
|
+
function Ot(a, t, e, i) {
|
|
710
|
+
const o = e.limitFactor || B;
|
|
711
|
+
let r = 0;
|
|
712
|
+
const s = new ResizeObserver((n) => {
|
|
713
|
+
for (const c of n) {
|
|
714
|
+
const l = c.contentRect.width;
|
|
715
|
+
if (l === 0) continue;
|
|
716
|
+
const d = typeof window < "u" && window.devicePixelRatio || 1, u = it(l, d, i(), o);
|
|
717
|
+
u !== r && (r = u, a.src = z(t, e, l, i(), d));
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
return {
|
|
721
|
+
observer: s,
|
|
722
|
+
destroy: () => s.disconnect()
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
const A = 50, U = 0.5;
|
|
726
|
+
class Yt {
|
|
727
|
+
constructor(t) {
|
|
728
|
+
this.cleanups = [];
|
|
729
|
+
const { container: e, getZoomPan: i, onEscape: o, onFullscreenToggle: r } = t, s = f(e, "keydown", (n) => {
|
|
730
|
+
const c = n.target;
|
|
731
|
+
if (c.tagName === "INPUT" || c.tagName === "TEXTAREA" || c.tagName === "SELECT")
|
|
732
|
+
return;
|
|
733
|
+
const l = i();
|
|
734
|
+
switch (n.key) {
|
|
735
|
+
case "Escape":
|
|
736
|
+
o == null || o();
|
|
737
|
+
break;
|
|
738
|
+
case "ArrowUp":
|
|
739
|
+
l && l.getZoom() > 1 && (n.preventDefault(), l.pan(0, A));
|
|
740
|
+
break;
|
|
741
|
+
case "ArrowDown":
|
|
742
|
+
l && l.getZoom() > 1 && (n.preventDefault(), l.pan(0, -A));
|
|
743
|
+
break;
|
|
744
|
+
case "ArrowLeft":
|
|
745
|
+
l && l.getZoom() > 1 && (n.preventDefault(), l.pan(A, 0));
|
|
746
|
+
break;
|
|
747
|
+
case "ArrowRight":
|
|
748
|
+
l && l.getZoom() > 1 && (n.preventDefault(), l.pan(-A, 0));
|
|
749
|
+
break;
|
|
750
|
+
case "+":
|
|
751
|
+
case "=":
|
|
752
|
+
l && (n.preventDefault(), l.setZoom(l.getZoom() + U));
|
|
753
|
+
break;
|
|
754
|
+
case "-":
|
|
755
|
+
l && (n.preventDefault(), l.setZoom(l.getZoom() - U));
|
|
756
|
+
break;
|
|
757
|
+
case "0":
|
|
758
|
+
l && (n.preventDefault(), l.resetZoom());
|
|
759
|
+
break;
|
|
760
|
+
case "f":
|
|
761
|
+
r && (n.preventDefault(), r());
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
this.cleanups.push(s);
|
|
766
|
+
}
|
|
767
|
+
destroy() {
|
|
768
|
+
this.cleanups.forEach((t) => t()), this.cleanups = [];
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
const Nt = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
772
|
+
function _(a) {
|
|
773
|
+
return Array.from(a.querySelectorAll(Nt));
|
|
774
|
+
}
|
|
775
|
+
function O(a, t) {
|
|
776
|
+
let e = !1, i = null;
|
|
777
|
+
function o() {
|
|
778
|
+
if (e) return;
|
|
779
|
+
e = !0;
|
|
780
|
+
const n = _(a);
|
|
781
|
+
n.length !== 0 && (n[0].focus(), i = f(a, "keydown", (c) => {
|
|
782
|
+
if (c.key !== "Tab") return;
|
|
783
|
+
const l = _(a);
|
|
784
|
+
if (l.length === 0) return;
|
|
785
|
+
const d = l[0], u = l[l.length - 1];
|
|
786
|
+
c.shiftKey && document.activeElement === d ? (c.preventDefault(), u.focus()) : !c.shiftKey && document.activeElement === u && (c.preventDefault(), d.focus());
|
|
787
|
+
}));
|
|
788
|
+
}
|
|
789
|
+
function r() {
|
|
790
|
+
e && (e = !1, i == null || i(), i = null, t.focus());
|
|
791
|
+
}
|
|
792
|
+
function s() {
|
|
793
|
+
r();
|
|
794
|
+
}
|
|
795
|
+
return { activate: o, deactivate: r, destroy: s };
|
|
796
|
+
}
|
|
797
|
+
let E = null, D = 0;
|
|
798
|
+
function $t(a) {
|
|
799
|
+
K() && (E || (E = h("div", void 0, {
|
|
800
|
+
"aria-live": "polite",
|
|
801
|
+
"aria-atomic": "true",
|
|
802
|
+
role: "status"
|
|
803
|
+
}), E.style.cssText = "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", document.body.appendChild(E)), E.textContent = "", requestAnimationFrame(() => {
|
|
804
|
+
E && (E.textContent = a);
|
|
805
|
+
}));
|
|
806
|
+
}
|
|
807
|
+
function q() {
|
|
808
|
+
D++;
|
|
809
|
+
}
|
|
810
|
+
function Xt() {
|
|
811
|
+
D = Math.max(0, D - 1), D === 0 && E && (E.remove(), E = null);
|
|
812
|
+
}
|
|
813
|
+
const G = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" x2="14" y1="3" y2="10"/><line x1="3" x2="10" y1="21" y2="14"/></svg>', jt = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" x2="21" y1="10" y2="3"/><line x1="3" x2="10" y1="21" y2="14"/></svg>';
|
|
814
|
+
function Zt() {
|
|
815
|
+
return !!(document.fullscreenEnabled || document.webkitFullscreenEnabled);
|
|
816
|
+
}
|
|
817
|
+
function Vt() {
|
|
818
|
+
return document.fullscreenElement || document.webkitFullscreenElement || null;
|
|
819
|
+
}
|
|
820
|
+
function J(a) {
|
|
821
|
+
return a.requestFullscreen ? a.requestFullscreen() : a.webkitRequestFullscreen ? (a.webkitRequestFullscreen(), Promise.resolve()) : Promise.reject(new Error("Fullscreen API not supported"));
|
|
822
|
+
}
|
|
823
|
+
function R() {
|
|
824
|
+
return document.exitFullscreen ? document.exitFullscreen() : document.webkitExitFullscreen ? (document.webkitExitFullscreen(), Promise.resolve()) : Promise.reject(new Error("Fullscreen API not supported"));
|
|
825
|
+
}
|
|
826
|
+
function Wt(a, t = {}) {
|
|
827
|
+
if (!Zt()) return null;
|
|
828
|
+
const e = h("button", "ci-hotspot-fullscreen-btn", {
|
|
829
|
+
"aria-label": "Enter fullscreen",
|
|
830
|
+
"aria-pressed": "false",
|
|
831
|
+
type: "button"
|
|
832
|
+
});
|
|
833
|
+
e.innerHTML = G;
|
|
834
|
+
const i = [];
|
|
835
|
+
function o() {
|
|
836
|
+
return Vt() === a;
|
|
837
|
+
}
|
|
838
|
+
function r() {
|
|
839
|
+
var m;
|
|
840
|
+
const p = o();
|
|
841
|
+
e.innerHTML = p ? jt : G, e.setAttribute("aria-label", p ? "Exit fullscreen" : "Enter fullscreen"), e.setAttribute("aria-pressed", String(p)), p ? v(a, "ci-hotspot-container--fullscreen") : y(a, "ci-hotspot-container--fullscreen"), (m = t.onChange) == null || m.call(t, p);
|
|
842
|
+
}
|
|
843
|
+
function s() {
|
|
844
|
+
o() ? R().catch(() => {
|
|
845
|
+
}) : J(a).catch(() => {
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
function n() {
|
|
849
|
+
o() || J(a).catch(() => {
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
function c() {
|
|
853
|
+
o() && R().catch(() => {
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
const l = f(document, "fullscreenchange", r);
|
|
857
|
+
i.push(l), document.addEventListener("webkitfullscreenchange", r), i.push(() => document.removeEventListener("webkitfullscreenchange", r));
|
|
858
|
+
const d = f(e, "click", (p) => {
|
|
859
|
+
p.stopPropagation(), s();
|
|
860
|
+
});
|
|
861
|
+
i.push(d), a.appendChild(e);
|
|
862
|
+
function u() {
|
|
863
|
+
o() && R().catch(() => {
|
|
864
|
+
}), y(a, "ci-hotspot-container--fullscreen"), i.forEach((p) => p()), i.length = 0, e.remove();
|
|
865
|
+
}
|
|
866
|
+
return {
|
|
867
|
+
element: e,
|
|
868
|
+
isFullscreen: o,
|
|
869
|
+
toggle: s,
|
|
870
|
+
enter: n,
|
|
871
|
+
exit: c,
|
|
872
|
+
destroy: u
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
const ot = '.ci-hotspot-container{--ci-hotspot-marker-size: 24px;--ci-hotspot-marker-color: #ffffff;--ci-hotspot-marker-bg: rgba(0, 0, 0, .6);--ci-hotspot-marker-border-width: 2px;--ci-hotspot-marker-border-color: rgba(255, 255, 255, .8);--ci-hotspot-marker-border: var(--ci-hotspot-marker-border-width) solid var(--ci-hotspot-marker-border-color);--ci-hotspot-marker-border-radius: 50%;--ci-hotspot-marker-shadow: 0 2px 8px rgba(0, 0, 0, .3);--ci-hotspot-pulse-color: rgba(0, 0, 0, .2);--ci-hotspot-pulse-size: 40px;--ci-hotspot-pulse-duration: 1.8s;--ci-hotspot-popover-bg: #ffffff;--ci-hotspot-popover-color: #1a1a1a;--ci-hotspot-popover-border: 1px solid rgba(0, 0, 0, .1);--ci-hotspot-popover-border-radius: 12px;--ci-hotspot-popover-shadow: 0 8px 32px rgba(0, 0, 0, .12);--ci-hotspot-popover-padding: 16px;--ci-hotspot-popover-max-width: 320px;--ci-hotspot-popover-max-height: 400px;--ci-hotspot-popover-font-family: inherit;--ci-hotspot-popover-font-size: 14px;--ci-hotspot-popover-line-height: 1.5;--ci-hotspot-popover-z-index: 1000;--ci-hotspot-arrow-size: 8px;--ci-hotspot-arrow-color: var(--ci-hotspot-popover-bg);--ci-hotspot-title-font-size: 16px;--ci-hotspot-title-font-weight: 600;--ci-hotspot-title-color: #1a1a1a;--ci-hotspot-price-color: #2d8c3c;--ci-hotspot-price-font-size: 18px;--ci-hotspot-price-font-weight: 700;--ci-hotspot-description-color: #666666;--ci-hotspot-cta-bg: #0058a3;--ci-hotspot-cta-color: #ffffff;--ci-hotspot-cta-border-radius: 8px;--ci-hotspot-cta-padding: 8px 16px;--ci-hotspot-hover-transition: .2s ease;--ci-hotspot-popover-transition: .3s ease;--ci-hotspot-scene-transition-duration: .4s;--ci-hotspot-zoom-controls-bg: rgba(255, 255, 255, .9);--ci-hotspot-zoom-controls-color: #333333;--ci-hotspot-zoom-controls-border-radius: 8px;--ci-hotspot-zoom-controls-shadow: 0 2px 8px rgba(0, 0, 0, .15)}.ci-hotspot-container *,.ci-hotspot-container *:before,.ci-hotspot-container *:after{box-sizing:border-box}.ci-hotspot-container{position:relative;overflow:hidden;width:100%;line-height:0;user-select:none;-webkit-user-select:none}.ci-hotspot-viewport{position:relative;width:100%;transform-origin:0 0;will-change:transform;transition:transform .3s ease}.ci-hotspot-viewport--dragging{transition:none}.ci-hotspot-image{display:block;width:100%;height:auto;pointer-events:none}.ci-hotspot-markers{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none}.ci-hotspot-marker{position:absolute;width:var(--ci-hotspot-marker-size);height:var(--ci-hotspot-marker-size);padding:0;border:var(--ci-hotspot-marker-border);border-radius:var(--ci-hotspot-marker-border-radius);background:var(--ci-hotspot-marker-bg);color:var(--ci-hotspot-marker-color);box-shadow:var(--ci-hotspot-marker-shadow);cursor:pointer;pointer-events:auto;transform:translate(-50%,-50%) scale(calc(1 / var(--zoom, 1)));transition:transform var(--ci-hotspot-hover-transition),box-shadow var(--ci-hotspot-hover-transition);z-index:1;display:flex;align-items:center;justify-content:center;font-size:12px;line-height:1;outline:none}.ci-hotspot-marker:hover{transform:translate(-50%,-50%) scale(calc(1.2 / var(--zoom, 1)));box-shadow:0 4px 12px #0006}.ci-hotspot-marker:focus-visible{outline:3px solid var(--ci-hotspot-focus-ring, #4A90D9);outline-offset:2px}.ci-hotspot-marker--active{transform:translate(-50%,-50%) scale(calc(1.2 / var(--zoom, 1)));z-index:2}.ci-hotspot-marker--hidden{display:none}.ci-hotspot-marker--pulse:before{content:"";position:absolute;top:50%;left:50%;width:var(--ci-hotspot-pulse-size);height:var(--ci-hotspot-pulse-size);border-radius:50%;background:var(--ci-hotspot-pulse-color);transform:translate(-50%,-50%) scale(1);animation:ci-hotspot-pulse var(--ci-hotspot-pulse-duration) ease-out infinite;pointer-events:none}@keyframes ci-hotspot-pulse{0%{transform:translate(-50%,-50%) scale(1);opacity:1}to{transform:translate(-50%,-50%) scale(1.8);opacity:0}}.ci-hotspot-marker--pulse{animation:ci-hotspot-breathe 2.4s ease-in-out infinite}.ci-hotspot-marker--pulse:hover,.ci-hotspot-marker--pulse.ci-hotspot-marker--active{animation:none}@keyframes ci-hotspot-breathe{0%,to{transform:translate(-50%,-50%) scale(calc(1 / var(--zoom, 1)))}50%{transform:translate(-50%,-50%) scale(calc(1.15 / var(--zoom, 1)))}}.ci-hotspot-popover{position:absolute;z-index:var(--ci-hotspot-popover-z-index);max-width:var(--ci-hotspot-popover-max-width);background:var(--ci-hotspot-popover-bg);color:var(--ci-hotspot-popover-color);border:var(--ci-hotspot-popover-border);border-radius:var(--ci-hotspot-popover-border-radius);box-shadow:var(--ci-hotspot-popover-shadow);font-family:var(--ci-hotspot-popover-font-family);font-size:var(--ci-hotspot-popover-font-size);line-height:var(--ci-hotspot-popover-line-height);opacity:0;pointer-events:none;transform:translateY(4px);transition:opacity var(--ci-hotspot-popover-transition),transform var(--ci-hotspot-popover-transition)}.ci-hotspot-popover--visible{opacity:1;pointer-events:auto;transform:translateY(0);animation:ci-hotspot-popover-in var(--ci-hotspot-popover-transition) forwards}@keyframes ci-hotspot-popover-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.ci-hotspot-popover-arrow{position:absolute;width:calc(var(--ci-hotspot-arrow-size) * 2);height:calc(var(--ci-hotspot-arrow-size) * 2);background:var(--ci-hotspot-arrow-color);transform:rotate(45deg);pointer-events:none}.ci-hotspot-popover[data-placement=top] .ci-hotspot-popover-arrow{bottom:calc(var(--ci-hotspot-arrow-size) * -1)}.ci-hotspot-popover[data-placement=bottom] .ci-hotspot-popover-arrow{top:calc(var(--ci-hotspot-arrow-size) * -1)}.ci-hotspot-popover[data-placement=left] .ci-hotspot-popover-arrow{right:calc(var(--ci-hotspot-arrow-size) * -1)}.ci-hotspot-popover[data-placement=right] .ci-hotspot-popover-arrow{left:calc(var(--ci-hotspot-arrow-size) * -1)}.ci-hotspot-popover-content{padding:var(--ci-hotspot-popover-padding);max-height:var(--ci-hotspot-popover-max-height);overflow-y:auto;overflow-x:hidden;border-radius:var(--ci-hotspot-popover-border-radius)}.ci-hotspot-popover-image{display:block;width:100%;height:auto;border-radius:calc(var(--ci-hotspot-popover-border-radius) - 4px) calc(var(--ci-hotspot-popover-border-radius) - 4px) 0 0;margin:calc(var(--ci-hotspot-popover-padding) * -1);margin-bottom:12px;width:calc(100% + var(--ci-hotspot-popover-padding) * 2)}.ci-hotspot-popover-body{line-height:1.5}.ci-hotspot-popover-title{margin:0 0 4px;font-size:var(--ci-hotspot-title-font-size);font-weight:var(--ci-hotspot-title-font-weight);color:var(--ci-hotspot-title-color)}.ci-hotspot-popover-price{display:inline-block;margin-bottom:8px;font-size:var(--ci-hotspot-price-font-size);font-weight:var(--ci-hotspot-price-font-weight);color:var(--ci-hotspot-price-color)}.ci-hotspot-popover-description{margin:0 0 12px;color:var(--ci-hotspot-description-color)}.ci-hotspot-popover-cta{display:inline-block;padding:var(--ci-hotspot-cta-padding);background:var(--ci-hotspot-cta-bg);color:var(--ci-hotspot-cta-color);border-radius:var(--ci-hotspot-cta-border-radius);text-decoration:none;font-weight:600;font-size:14px;transition:opacity .2s ease}.ci-hotspot-popover-cta:hover{opacity:.9}.ci-hotspot-popover-cta:focus-visible{outline:3px solid var(--ci-hotspot-focus-ring, #4A90D9);outline-offset:2px}.ci-hotspot-zoom-controls{position:absolute;display:flex;gap:2px;background:var(--ci-hotspot-zoom-controls-bg);border-radius:var(--ci-hotspot-zoom-controls-border-radius);box-shadow:var(--ci-hotspot-zoom-controls-shadow);z-index:10;overflow:hidden}.ci-hotspot-zoom-controls button{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;background:transparent;color:var(--ci-hotspot-zoom-controls-color);cursor:pointer;font-size:18px;line-height:1;padding:0;transition:background .15s ease}.ci-hotspot-zoom-controls button:hover{background:#0000000d}.ci-hotspot-zoom-controls button:disabled{opacity:.3;cursor:default}.ci-hotspot-zoom-controls button:disabled:hover{background:transparent}.ci-hotspot-zoom-controls button svg{width:18px;height:18px}.ci-hotspot-zoom-controls button:focus-visible{outline:3px solid var(--ci-hotspot-focus-ring, #4A90D9);outline-offset:-3px}.ci-hotspot-zoom-controls[data-position=bottom-right]{bottom:16px;right:16px}.ci-hotspot-zoom-controls[data-position=bottom-left]{bottom:16px;left:16px}.ci-hotspot-zoom-controls[data-position=bottom-center]{bottom:16px;left:50%;transform:translate(-50%)}.ci-hotspot-zoom-controls[data-position=top-right]{top:16px;right:16px}.ci-hotspot-zoom-controls[data-position=top-left]{top:16px;left:16px}.ci-hotspot-zoom-controls[data-position=top-center]{top:16px;left:50%;transform:translate(-50%)}.ci-hotspot-cluster{position:absolute;display:flex;align-items:center;justify-content:center;min-width:32px;height:32px;padding:0 8px;border-radius:16px;border:2px solid rgba(255,255,255,.8);background:var(--ci-hotspot-marker-bg);color:var(--ci-hotspot-marker-color);font-size:13px;font-weight:700;cursor:pointer;pointer-events:auto;transform:translate(-50%,-50%) scale(calc(1 / var(--zoom, 1)));box-shadow:var(--ci-hotspot-marker-shadow)}.ci-hotspot-loading .ci-hotspot-image{opacity:0;transition:opacity .3s ease}.ci-hotspot-loading .ci-hotspot-markers{display:none}.ci-hotspot-theme-dark{--ci-hotspot-marker-bg: rgba(255, 255, 255, .8);--ci-hotspot-marker-color: #1a1a1a;--ci-hotspot-marker-border-color: rgba(255, 255, 255, .4);--ci-hotspot-pulse-color: rgba(255, 255, 255, .2);--ci-hotspot-popover-bg: #1a1a1a;--ci-hotspot-popover-color: #f0f0f0;--ci-hotspot-popover-border: 1px solid rgba(255, 255, 255, .1);--ci-hotspot-popover-shadow: 0 8px 32px rgba(0, 0, 0, .4);--ci-hotspot-title-color: #f0f0f0;--ci-hotspot-description-color: #aaaaaa;--ci-hotspot-zoom-controls-bg: rgba(30, 30, 30, .9);--ci-hotspot-zoom-controls-color: #f0f0f0}.ci-hotspot-marker-inverted{--ci-hotspot-marker-bg: rgba(255, 255, 255, .8);--ci-hotspot-marker-color: #1a1a1a;--ci-hotspot-marker-border-color: rgba(0, 0, 0, .3);--ci-hotspot-marker-shadow: 0 2px 8px rgba(0, 0, 0, .15);--ci-hotspot-pulse-color: rgba(0, 0, 0, .15)}.ci-hotspot-theme-dark.ci-hotspot-marker-inverted{--ci-hotspot-marker-bg: rgba(0, 0, 0, .6);--ci-hotspot-marker-color: #ffffff;--ci-hotspot-marker-border-color: rgba(255, 255, 255, .3);--ci-hotspot-pulse-color: rgba(255, 255, 255, .15)}.ci-hotspot-scroll-hint{position:absolute;bottom:16px;left:50%;transform:translate(-50%) translateY(4px);padding:8px 16px;border-radius:20px;background:#000000b3;color:#fff;font-size:13px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;line-height:1;white-space:nowrap;z-index:100;opacity:0;pointer-events:none;transition:opacity .3s ease,transform .3s ease}.ci-hotspot-scroll-hint--visible{opacity:1;transform:translate(-50%) translateY(0)}.ci-hotspot-container--fixed-ratio .ci-hotspot-viewport{overflow:hidden}.ci-hotspot-container--fixed-ratio .ci-hotspot-image{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain}.ci-hotspot-container--fixed-ratio .ci-hotspot-markers{z-index:1}.ci-hotspot-scene-incoming{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain;pointer-events:none;z-index:0}.ci-hotspot-scene-fade-in{animation:ci-hotspot-scene-fade-in var(--ci-hotspot-scene-transition-duration) ease forwards;z-index:1}.ci-hotspot-scene-fade-out{animation:ci-hotspot-scene-fade-out var(--ci-hotspot-scene-transition-duration) ease forwards}@keyframes ci-hotspot-scene-fade-in{0%{opacity:0}to{opacity:1}}@keyframes ci-hotspot-scene-fade-out{0%{opacity:1}to{opacity:0}}.ci-hotspot-scene-slide-in{animation:ci-hotspot-scene-slide-in var(--ci-hotspot-scene-transition-duration) ease forwards;z-index:1}.ci-hotspot-scene-slide-out{animation:ci-hotspot-scene-slide-out var(--ci-hotspot-scene-transition-duration) ease forwards}@keyframes ci-hotspot-scene-slide-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes ci-hotspot-scene-slide-out{0%{transform:translate(0)}to{transform:translate(-100%)}}.ci-hotspot-scene-slide-in-reverse{animation:ci-hotspot-scene-slide-in-reverse var(--ci-hotspot-scene-transition-duration) ease forwards;z-index:1}.ci-hotspot-scene-slide-out-reverse{animation:ci-hotspot-scene-slide-out-reverse var(--ci-hotspot-scene-transition-duration) ease forwards}@keyframes ci-hotspot-scene-slide-in-reverse{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes ci-hotspot-scene-slide-out-reverse{0%{transform:translate(0)}to{transform:translate(100%)}}.ci-hotspot-marker--navigate{--ci-hotspot-marker-bg: rgba(0, 88, 163, .7)}.ci-hotspot-navigate-icon{width:75%;height:75%;display:block}.ci-hotspot-scene-transitioning .ci-hotspot-markers{opacity:0;pointer-events:none;transition:opacity .1s ease}.ci-hotspot-scene-loading:after{content:"";position:absolute;top:50%;left:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid rgba(0,0,0,.1);border-top-color:#00000080;border-radius:50%;animation:ci-hotspot-spin .6s linear infinite;z-index:10;pointer-events:none}.ci-hotspot-theme-dark .ci-hotspot-scene-loading:after,.ci-hotspot-scene-loading.ci-hotspot-theme-dark:after{border-color:#ffffff1a;border-top-color:#ffffff80}@keyframes ci-hotspot-spin{to{transform:rotate(360deg)}}.ci-hotspot-fullscreen-btn{position:absolute;top:16px;right:16px;display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:var(--ci-hotspot-zoom-controls-border-radius);background:var(--ci-hotspot-zoom-controls-bg);color:var(--ci-hotspot-zoom-controls-color);box-shadow:var(--ci-hotspot-zoom-controls-shadow);cursor:pointer;padding:0;z-index:10;transition:background .15s ease}.ci-hotspot-fullscreen-btn:hover{background:#0000000d}.ci-hotspot-fullscreen-btn svg{width:18px;height:18px}.ci-hotspot-fullscreen-btn:focus-visible{outline:3px solid var(--ci-hotspot-focus-ring, #4A90D9);outline-offset:2px}.ci-hotspot-container--fullscreen{background:#000;width:100vw;height:100vh;display:flex;align-items:center;justify-content:center}.ci-hotspot-container--fullscreen .ci-hotspot-viewport{width:fit-content;max-width:100%;max-height:100%}.ci-hotspot-container--fullscreen .ci-hotspot-image{max-height:100vh;width:auto;max-width:100%;object-fit:contain}.ci-hotspot-container--fullscreen.ci-hotspot-container--fixed-ratio .ci-hotspot-viewport{width:100%;height:100%}.ci-hotspot-container--fullscreen.ci-hotspot-container--fixed-ratio .ci-hotspot-image{width:100%;height:100%;max-height:none}.ci-hotspot-theme-dark .ci-hotspot-fullscreen-btn,.ci-hotspot-container--fullscreen .ci-hotspot-fullscreen-btn{background:#1e1e1ee6;color:#f0f0f0}.ci-hotspot-theme-dark .ci-hotspot-fullscreen-btn:hover,.ci-hotspot-container--fullscreen .ci-hotspot-fullscreen-btn:hover{background:#ffffff1a}@media (prefers-reduced-motion: reduce){.ci-hotspot-marker,.ci-hotspot-marker:before,.ci-hotspot-popover{animation:none!important;transition-duration:.01ms!important}.ci-hotspot-viewport,.ci-hotspot-scroll-hint{transition-duration:.01ms!important}.ci-hotspot-scene-fade-in,.ci-hotspot-scene-fade-out,.ci-hotspot-scene-slide-in,.ci-hotspot-scene-slide-out,.ci-hotspot-scene-slide-in-reverse,.ci-hotspot-scene-slide-out-reverse{animation-duration:.01ms!important}.ci-hotspot-scene-transitioning .ci-hotspot-markers{transition-duration:.01ms!important}.ci-hotspot-scene-loading:after{animation-duration:.01ms!important}.ci-hotspot-fullscreen-btn{transition-duration:.01ms!important}}', M = class M {
|
|
876
|
+
constructor(t, e) {
|
|
877
|
+
this.markers = /* @__PURE__ */ new Map(), this.popovers = /* @__PURE__ */ new Map(), this.normalizedHotspots = /* @__PURE__ */ new Map(), this.scrollHint = null, this.zoomPan = null, this.zoomControls = null, this.cloudimageHandler = null, this.resizeObserver = null, this.keyboardHandler = null, this.fullscreenControl = null, this.focusTraps = /* @__PURE__ */ new Map(), this.cleanups = [], this.hotspotCleanups = /* @__PURE__ */ new Map(), this.imageLoaded = !1, this.destroyed = !1, this.scenesMap = /* @__PURE__ */ new Map(), this.isTransitioning = !1, this.activeTimers = /* @__PURE__ */ new Set(), this.sceneHotspotOverrides = /* @__PURE__ */ new Map(), this.preloadedScenes = /* @__PURE__ */ new Set(), this.rootEl = st(t), this.config = X(e), j(this.config), this.config.scenes && this.config.scenes.length > 0 && this.initScenes(), q(), Q(ot), this.buildDOM(), this.applyTheme(), this.setupImage(), this.initHotspots(), this.config.zoom && this.initZoom(), this.initKeyboard(), this.initFullscreen(), this.setupResponsive();
|
|
878
|
+
}
|
|
879
|
+
/** Auto-initialize all elements with data-ci-hotspot-src or data-ci-hotspot-scenes attribute */
|
|
880
|
+
static autoInit(t) {
|
|
881
|
+
const i = (t || document).querySelectorAll(
|
|
882
|
+
"[data-ci-hotspot-src], [data-ci-hotspot-scenes]"
|
|
883
|
+
), o = [];
|
|
884
|
+
return i.forEach((r) => {
|
|
885
|
+
const s = ct(r);
|
|
886
|
+
(s.src || s.scenes) && o.push(new M(r, s));
|
|
887
|
+
}), o;
|
|
888
|
+
}
|
|
889
|
+
buildDOM() {
|
|
890
|
+
this.containerEl = h("div", "ci-hotspot-container"), this.viewportEl = h("div", "ci-hotspot-viewport"), this.imgEl = h("img", "ci-hotspot-image", {
|
|
891
|
+
alt: this.config.alt || "",
|
|
892
|
+
draggable: "false"
|
|
893
|
+
}), this.markersEl = h("div", "ci-hotspot-markers"), this.viewportEl.appendChild(this.imgEl), this.viewportEl.appendChild(this.markersEl), this.containerEl.appendChild(this.viewportEl), this.containerEl.setAttribute("role", "group"), this.containerEl.setAttribute("aria-label", this.config.alt || "Image with hotspots"), this.config.sceneAspectRatio && (v(this.containerEl, "ci-hotspot-container--fixed-ratio"), this.viewportEl.style.aspectRatio = this.config.sceneAspectRatio), this.rootEl.innerHTML = "", this.rootEl.appendChild(this.containerEl), this.config.lazyLoad && v(this.containerEl, "ci-hotspot-loading");
|
|
894
|
+
}
|
|
895
|
+
applyTheme() {
|
|
896
|
+
this.config.theme === "dark" && v(this.containerEl, "ci-hotspot-theme-dark"), this.config.invertMarkerTheme && v(this.containerEl, "ci-hotspot-marker-inverted");
|
|
897
|
+
}
|
|
898
|
+
setupImage() {
|
|
899
|
+
const t = () => {
|
|
900
|
+
y(this.containerEl, "ci-hotspot-loading"), this.imageLoaded = !0, this.renormalizePixelCoordinates(), this.syncMarkersToImage(), this.showLoadTriggerPopovers();
|
|
901
|
+
};
|
|
902
|
+
if (this.imgEl.addEventListener("load", t), this.cleanups.push(() => this.imgEl.removeEventListener("load", t)), this.config.lazyLoad && typeof IntersectionObserver < "u") {
|
|
903
|
+
const e = new IntersectionObserver(
|
|
904
|
+
(i) => {
|
|
905
|
+
var o;
|
|
906
|
+
(o = i[0]) != null && o.isIntersecting && (this.loadImage(), e.disconnect());
|
|
907
|
+
},
|
|
908
|
+
{ threshold: 0.1 }
|
|
909
|
+
);
|
|
910
|
+
e.observe(this.containerEl), this.cleanups.push(() => e.disconnect());
|
|
911
|
+
} else
|
|
912
|
+
this.loadImage();
|
|
913
|
+
}
|
|
914
|
+
loadImage() {
|
|
915
|
+
var t, e;
|
|
916
|
+
if ((t = this.config.cloudimage) != null && t.token) {
|
|
917
|
+
const i = this.containerEl.offsetWidth || 300, o = window.devicePixelRatio || 1, r = ((e = this.zoomPan) == null ? void 0 : e.getZoom()) || 1;
|
|
918
|
+
this.imgEl.src = z(
|
|
919
|
+
this.config.src,
|
|
920
|
+
this.config.cloudimage,
|
|
921
|
+
i,
|
|
922
|
+
r,
|
|
923
|
+
o
|
|
924
|
+
), this.cloudimageHandler = Ot(
|
|
925
|
+
this.imgEl,
|
|
926
|
+
this.config.src,
|
|
927
|
+
this.config.cloudimage,
|
|
928
|
+
() => {
|
|
929
|
+
var s;
|
|
930
|
+
return ((s = this.zoomPan) == null ? void 0 : s.getZoom()) || 1;
|
|
931
|
+
}
|
|
932
|
+
), this.cloudimageHandler.observer.observe(this.containerEl), this.cleanups.push(() => {
|
|
933
|
+
var s;
|
|
934
|
+
return (s = this.cloudimageHandler) == null ? void 0 : s.destroy();
|
|
935
|
+
});
|
|
936
|
+
} else
|
|
937
|
+
this.imgEl.src = this.config.src;
|
|
938
|
+
}
|
|
939
|
+
initHotspots() {
|
|
940
|
+
for (const t of this.config.hotspots)
|
|
941
|
+
this.addHotspotInternal(t);
|
|
942
|
+
}
|
|
943
|
+
addHotspotInternal(t) {
|
|
944
|
+
var d, u;
|
|
945
|
+
if (this.markers.has(t.id)) {
|
|
946
|
+
const p = this.markers.get(t.id);
|
|
947
|
+
I(p), this.markers.delete(t.id), (d = this.popovers.get(t.id)) == null || d.destroy(), this.popovers.delete(t.id);
|
|
948
|
+
const m = this.hotspotCleanups.get(t.id);
|
|
949
|
+
m && (m.forEach((k) => k()), this.hotspotCleanups.delete(t.id));
|
|
950
|
+
const b = this.focusTraps.get(t.id);
|
|
951
|
+
b && (b.destroy(), this.focusTraps.delete(t.id));
|
|
952
|
+
}
|
|
953
|
+
const { x: e, y: i } = V(
|
|
954
|
+
t.x,
|
|
955
|
+
t.y,
|
|
956
|
+
this.imgEl.naturalWidth || 1e3,
|
|
957
|
+
this.imgEl.naturalHeight || 1e3
|
|
958
|
+
), o = { ...t, x: e, y: i };
|
|
959
|
+
this.normalizedHotspots.set(t.id, o);
|
|
960
|
+
const r = this.config.pulse !== !1, s = dt(o, r);
|
|
961
|
+
this.markers.set(t.id, s), this.markersEl.appendChild(s);
|
|
962
|
+
const n = t.trigger || this.config.trigger || "hover";
|
|
963
|
+
if (t.navigateTo) {
|
|
964
|
+
const p = this.enrichNavigateHotspot(t);
|
|
965
|
+
if (!!(p.data || p.content || this.config.renderPopover)) {
|
|
966
|
+
const b = t.placement || this.config.placement || "top", k = new W(p, {
|
|
967
|
+
placement: b,
|
|
968
|
+
triggerMode: "hover",
|
|
969
|
+
renderFn: this.config.renderPopover,
|
|
970
|
+
onOpen: this.config.onOpen,
|
|
971
|
+
onClose: this.config.onClose
|
|
972
|
+
});
|
|
973
|
+
this.popovers.set(t.id, k), k.mount(this.containerEl, s), this.bindNavigateTrigger(t, s, k);
|
|
974
|
+
} else
|
|
975
|
+
this.bindNavigateTrigger(t, s);
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const c = t.placement || this.config.placement || "top", l = new W(t, {
|
|
979
|
+
placement: c,
|
|
980
|
+
triggerMode: n,
|
|
981
|
+
renderFn: this.config.renderPopover,
|
|
982
|
+
onOpen: this.config.onOpen,
|
|
983
|
+
onClose: this.config.onClose
|
|
984
|
+
});
|
|
985
|
+
this.popovers.set(t.id, l), l.mount(this.containerEl, s), this.bindTrigger(t, s, l, n), n === "load" && this.imageLoaded && (this.closeAll(), l.show(), g(s, !0), this.ensureFocusTrap(t.id, l.element, s), (u = this.focusTraps.get(t.id)) == null || u.activate());
|
|
986
|
+
}
|
|
987
|
+
/** For navigateTo hotspots without explicit data/content, generate popover content from the destination scene */
|
|
988
|
+
enrichNavigateHotspot(t) {
|
|
989
|
+
if (t.data || t.content) return t;
|
|
990
|
+
const e = this.scenesMap.get(t.navigateTo);
|
|
991
|
+
return e ? {
|
|
992
|
+
...t,
|
|
993
|
+
data: { title: t.label || e.alt || e.id }
|
|
994
|
+
} : t;
|
|
995
|
+
}
|
|
996
|
+
bindNavigateTrigger(t, e, i) {
|
|
997
|
+
if (v(e, "ci-hotspot-marker--navigate"), e.innerHTML = M.NAVIGATE_ARROW_SVG, t.arrowDirection != null) {
|
|
998
|
+
const n = e.querySelector("svg");
|
|
999
|
+
n && (n.style.transform = `rotate(${t.arrowDirection}deg)`);
|
|
1000
|
+
}
|
|
1001
|
+
const o = t.label || t.navigateTo;
|
|
1002
|
+
if (e.setAttribute("aria-label", `Navigate to ${o}`), e.setAttribute("aria-roledescription", "navigation hotspot"), i) {
|
|
1003
|
+
const n = f(e, "mouseenter", () => {
|
|
1004
|
+
this.preloadSceneImage(t.navigateTo), i.clearHideTimer(), i.show(), g(e, !0);
|
|
1005
|
+
}), c = f(e, "mouseleave", () => {
|
|
1006
|
+
i.scheduleHide(200), this.trackedTimeout(() => {
|
|
1007
|
+
i.isVisible() || g(e, !1);
|
|
1008
|
+
}, 250);
|
|
1009
|
+
}), l = f(e, "focus", () => {
|
|
1010
|
+
this.preloadSceneImage(t.navigateTo), i.clearHideTimer(), i.show(), g(e, !0);
|
|
1011
|
+
}), d = f(e, "blur", () => {
|
|
1012
|
+
i.scheduleHide(200), this.trackedTimeout(() => {
|
|
1013
|
+
i.isVisible() || g(e, !1);
|
|
1014
|
+
}, 250);
|
|
1015
|
+
});
|
|
1016
|
+
this.addHotspotCleanups(t.id, n, c, l, d);
|
|
1017
|
+
} else {
|
|
1018
|
+
const n = f(e, "mouseenter", () => {
|
|
1019
|
+
this.preloadSceneImage(t.navigateTo);
|
|
1020
|
+
}), c = f(e, "focus", () => {
|
|
1021
|
+
this.preloadSceneImage(t.navigateTo);
|
|
1022
|
+
});
|
|
1023
|
+
this.addHotspotCleanups(t.id, n, c);
|
|
1024
|
+
}
|
|
1025
|
+
const r = f(e, "click", (n) => {
|
|
1026
|
+
var c, l, d;
|
|
1027
|
+
n.stopPropagation(), i == null || i.hide(), g(e, !1), (l = (c = this.config).onClick) == null || l.call(c, n, t), (d = t.onClick) == null || d.call(t, n, t), this.goToScene(t.navigateTo);
|
|
1028
|
+
}), s = f(e, "keydown", (n) => {
|
|
1029
|
+
var c, l, d;
|
|
1030
|
+
(n.key === "Enter" || n.key === " ") && (n.preventDefault(), i == null || i.hide(), g(e, !1), (l = (c = this.config).onClick) == null || l.call(c, n, t), (d = t.onClick) == null || d.call(t, n, t), this.goToScene(t.navigateTo));
|
|
1031
|
+
});
|
|
1032
|
+
this.addHotspotCleanups(t.id, r, s);
|
|
1033
|
+
}
|
|
1034
|
+
bindTrigger(t, e, i, o) {
|
|
1035
|
+
o === "hover" ? this.bindHoverTrigger(t, e, i) : (o === "click" || o === "load") && this.bindClickTrigger(t, e, i), this.bindKeyboardTrigger(t, e, i, o);
|
|
1036
|
+
}
|
|
1037
|
+
bindHoverTrigger(t, e, i) {
|
|
1038
|
+
const o = f(e, "mouseenter", () => {
|
|
1039
|
+
i.clearHideTimer(), i.show(), g(e, !0);
|
|
1040
|
+
}), r = f(e, "mouseleave", () => {
|
|
1041
|
+
i.scheduleHide(200), this.trackedTimeout(() => {
|
|
1042
|
+
i.isVisible() || g(e, !1);
|
|
1043
|
+
}, 250);
|
|
1044
|
+
});
|
|
1045
|
+
this.addHotspotCleanups(t.id, o, r);
|
|
1046
|
+
}
|
|
1047
|
+
bindClickTrigger(t, e, i) {
|
|
1048
|
+
const o = O(i.element, e);
|
|
1049
|
+
this.focusTraps.set(t.id, o);
|
|
1050
|
+
const r = f(e, "click", (n) => {
|
|
1051
|
+
var c, l, d;
|
|
1052
|
+
n.stopPropagation(), (l = (c = this.config).onClick) == null || l.call(c, n, t), (d = t.onClick) == null || d.call(t, n, t), i.isVisible() ? (i.hide(), g(e, !1), o.deactivate()) : (this.closeAll(), i.show(), g(e, !0), o.activate());
|
|
1053
|
+
}), s = f(document, "click", (n) => {
|
|
1054
|
+
i.isVisible() && !t.keepOpen && !i.element.contains(n.target) && !e.contains(n.target) && (i.hide(), g(e, !1), o.deactivate());
|
|
1055
|
+
});
|
|
1056
|
+
this.addHotspotCleanups(t.id, r, s);
|
|
1057
|
+
}
|
|
1058
|
+
bindKeyboardTrigger(t, e, i, o) {
|
|
1059
|
+
const r = f(e, "focus", () => {
|
|
1060
|
+
o === "hover" && (i.clearHideTimer(), i.show(), g(e, !0));
|
|
1061
|
+
}), s = f(e, "blur", () => {
|
|
1062
|
+
o === "hover" && (i.scheduleHide(200), this.trackedTimeout(() => {
|
|
1063
|
+
i.isVisible() || g(e, !1);
|
|
1064
|
+
}, 250));
|
|
1065
|
+
}), n = f(e, "keydown", (c) => {
|
|
1066
|
+
var l, d, u, p, m;
|
|
1067
|
+
c.key === "Enter" || c.key === " " ? (c.preventDefault(), (d = (l = this.config).onClick) == null || d.call(l, c, t), i.isVisible() ? (i.hide(), g(e, !1), (u = this.focusTraps.get(t.id)) == null || u.deactivate()) : (this.closeAll(), i.show(), g(e, !0), this.ensureFocusTrap(t.id, i.element, e), (p = this.focusTraps.get(t.id)) == null || p.activate())) : c.key === "Escape" && i.isVisible() && (i.hide(), g(e, !1), (m = this.focusTraps.get(t.id)) == null || m.deactivate(), e.focus());
|
|
1068
|
+
});
|
|
1069
|
+
this.addHotspotCleanups(t.id, r, s, n);
|
|
1070
|
+
}
|
|
1071
|
+
renormalizePixelCoordinates() {
|
|
1072
|
+
const t = this.imgEl.naturalWidth, e = this.imgEl.naturalHeight;
|
|
1073
|
+
if (!(!t || !e)) {
|
|
1074
|
+
for (const i of this.config.hotspots)
|
|
1075
|
+
if (typeof i.x == "number" || typeof i.y == "number") {
|
|
1076
|
+
const { x: o, y: r } = V(i.x, i.y, t, e), s = this.markers.get(i.id);
|
|
1077
|
+
s && (s.style.left = `${o}%`, s.style.top = `${r}%`);
|
|
1078
|
+
const n = this.normalizedHotspots.get(i.id);
|
|
1079
|
+
n && (n.x = o, n.y = r);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
showLoadTriggerPopovers() {
|
|
1084
|
+
var t;
|
|
1085
|
+
for (const [e, i] of this.popovers) {
|
|
1086
|
+
const o = this.normalizedHotspots.get(e);
|
|
1087
|
+
if (((o == null ? void 0 : o.trigger) || this.config.trigger || "hover") === "load" && !i.isVisible()) {
|
|
1088
|
+
i.show();
|
|
1089
|
+
const s = this.markers.get(e);
|
|
1090
|
+
s && (g(s, !0), this.ensureFocusTrap(e, i.element, s), (t = this.focusTraps.get(e)) == null || t.activate());
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
initZoom() {
|
|
1096
|
+
this.config.scrollHint !== !1 && (this.scrollHint = new Dt(this.containerEl)), this.zoomPan = new Ht(this.viewportEl, this.containerEl, {
|
|
1097
|
+
zoomMin: this.config.zoomMin || 1,
|
|
1098
|
+
zoomMax: this.config.zoomMax || 4,
|
|
1099
|
+
onZoom: (t) => {
|
|
1100
|
+
var e, i, o;
|
|
1101
|
+
(i = (e = this.config).onZoom) == null || i.call(e, t), (o = this.zoomControls) == null || o.update();
|
|
1102
|
+
for (const [, r] of this.popovers)
|
|
1103
|
+
r.isVisible() && r.updatePosition();
|
|
1104
|
+
},
|
|
1105
|
+
onScrollWithoutZoom: () => {
|
|
1106
|
+
var t;
|
|
1107
|
+
return (t = this.scrollHint) == null ? void 0 : t.show();
|
|
1108
|
+
}
|
|
1109
|
+
}), this.config.zoomControls !== !1 && (this.zoomControls = Lt(this.containerEl, this.zoomPan, {
|
|
1110
|
+
zoomMin: this.config.zoomMin || 1,
|
|
1111
|
+
zoomMax: this.config.zoomMax || 4,
|
|
1112
|
+
position: this.config.zoomControlsPosition
|
|
1113
|
+
}));
|
|
1114
|
+
}
|
|
1115
|
+
setupResponsive() {
|
|
1116
|
+
if (typeof ResizeObserver > "u") return;
|
|
1117
|
+
let t = 0;
|
|
1118
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
1119
|
+
t || (t = requestAnimationFrame(() => {
|
|
1120
|
+
if (t = 0, this.destroyed) return;
|
|
1121
|
+
this.syncMarkersToImage();
|
|
1122
|
+
const e = this.containerEl.offsetWidth;
|
|
1123
|
+
for (const [i, o] of this.normalizedHotspots)
|
|
1124
|
+
if (o.responsive) {
|
|
1125
|
+
const r = this.markers.get(i);
|
|
1126
|
+
if (!r) continue;
|
|
1127
|
+
const s = o.responsive.maxWidth && e > o.responsive.maxWidth || o.responsive.minWidth && e < o.responsive.minWidth;
|
|
1128
|
+
ft(r, !!s);
|
|
1129
|
+
}
|
|
1130
|
+
}));
|
|
1131
|
+
}), this.cleanups.push(() => {
|
|
1132
|
+
t && cancelAnimationFrame(t);
|
|
1133
|
+
}), this.resizeObserver.observe(this.containerEl), this.cleanups.push(() => {
|
|
1134
|
+
var e;
|
|
1135
|
+
return (e = this.resizeObserver) == null ? void 0 : e.disconnect();
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
/** Position the markers layer to match the rendered image area within a fixed-ratio viewport */
|
|
1139
|
+
syncMarkersToImage() {
|
|
1140
|
+
if (!this.config.sceneAspectRatio) return;
|
|
1141
|
+
const t = this.viewportEl.offsetWidth, e = this.viewportEl.offsetHeight, i = this.imgEl.naturalWidth, o = this.imgEl.naturalHeight;
|
|
1142
|
+
if (!t || !e || !i || !o) return;
|
|
1143
|
+
const r = t / e, s = i / o;
|
|
1144
|
+
let n, c, l, d;
|
|
1145
|
+
s > r ? (n = t, c = t / s, l = 0, d = (e - c) / 2) : (c = e, n = e * s, l = (t - n) / 2, d = 0), this.markersEl.style.left = `${l}px`, this.markersEl.style.top = `${d}px`, this.markersEl.style.width = `${n}px`, this.markersEl.style.height = `${c}px`, this.markersEl.style.right = "auto", this.markersEl.style.bottom = "auto";
|
|
1146
|
+
}
|
|
1147
|
+
initScenes() {
|
|
1148
|
+
for (const i of this.config.scenes)
|
|
1149
|
+
this.scenesMap.set(i.id, i);
|
|
1150
|
+
const t = this.config.initialScene || this.config.scenes[0].id, e = this.scenesMap.get(t);
|
|
1151
|
+
this.config.src = e.src, this.config.alt = e.alt || "", this.config.hotspots = [...e.hotspots], this.currentSceneId = t;
|
|
1152
|
+
}
|
|
1153
|
+
initKeyboard() {
|
|
1154
|
+
this.keyboardHandler = new Yt({
|
|
1155
|
+
container: this.containerEl,
|
|
1156
|
+
getZoomPan: () => this.zoomPan,
|
|
1157
|
+
onEscape: () => {
|
|
1158
|
+
var t;
|
|
1159
|
+
if ((t = this.fullscreenControl) != null && t.isFullscreen()) {
|
|
1160
|
+
this.fullscreenControl.exit();
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
this.closeAll();
|
|
1164
|
+
},
|
|
1165
|
+
onFullscreenToggle: () => {
|
|
1166
|
+
var t;
|
|
1167
|
+
(t = this.fullscreenControl) == null || t.toggle();
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
initFullscreen() {
|
|
1172
|
+
this.config.fullscreenButton !== !1 && (this.fullscreenControl = Wt(this.containerEl, {
|
|
1173
|
+
onChange: (t) => {
|
|
1174
|
+
var e, i;
|
|
1175
|
+
requestAnimationFrame(() => {
|
|
1176
|
+
for (const [, o] of this.popovers)
|
|
1177
|
+
o.isVisible() && o.updatePosition();
|
|
1178
|
+
}), (i = (e = this.config).onFullscreenChange) == null || i.call(e, t);
|
|
1179
|
+
}
|
|
1180
|
+
}));
|
|
1181
|
+
}
|
|
1182
|
+
preloadSceneImage(t) {
|
|
1183
|
+
var o;
|
|
1184
|
+
if (this.preloadedScenes.has(t)) return;
|
|
1185
|
+
const e = this.scenesMap.get(t);
|
|
1186
|
+
if (!e) return;
|
|
1187
|
+
this.preloadedScenes.add(t);
|
|
1188
|
+
const i = new Image();
|
|
1189
|
+
if ((o = this.config.cloudimage) != null && o.token) {
|
|
1190
|
+
const r = this.containerEl.offsetWidth || 300, s = typeof window < "u" && window.devicePixelRatio || 1;
|
|
1191
|
+
i.src = z(e.src, this.config.cloudimage, r, 1, s);
|
|
1192
|
+
} else
|
|
1193
|
+
i.src = e.src;
|
|
1194
|
+
}
|
|
1195
|
+
ensureFocusTrap(t, e, i) {
|
|
1196
|
+
this.focusTraps.has(t) || this.focusTraps.set(t, O(e, i));
|
|
1197
|
+
}
|
|
1198
|
+
/** Create a setTimeout that is automatically cleared on destroy */
|
|
1199
|
+
trackedTimeout(t, e) {
|
|
1200
|
+
const i = setTimeout(() => {
|
|
1201
|
+
this.activeTimers.delete(i), t();
|
|
1202
|
+
}, e);
|
|
1203
|
+
this.activeTimers.add(i);
|
|
1204
|
+
}
|
|
1205
|
+
/** Sync current hotspots back to scene override map so navigating away and back preserves changes */
|
|
1206
|
+
syncCurrentSceneHotspots() {
|
|
1207
|
+
!this.currentSceneId || this.isTransitioning || this.sceneHotspotOverrides.set(this.currentSceneId, [...this.config.hotspots]);
|
|
1208
|
+
}
|
|
1209
|
+
addHotspotCleanups(t, ...e) {
|
|
1210
|
+
let i = this.hotspotCleanups.get(t);
|
|
1211
|
+
i || (i = [], this.hotspotCleanups.set(t, i)), i.push(...e);
|
|
1212
|
+
}
|
|
1213
|
+
clearHotspots() {
|
|
1214
|
+
for (const t of this.hotspotCleanups.values())
|
|
1215
|
+
t.forEach((e) => e());
|
|
1216
|
+
this.hotspotCleanups.clear();
|
|
1217
|
+
for (const [, t] of this.popovers)
|
|
1218
|
+
t.destroy();
|
|
1219
|
+
this.popovers.clear();
|
|
1220
|
+
for (const [, t] of this.markers)
|
|
1221
|
+
I(t);
|
|
1222
|
+
this.markers.clear(), this.normalizedHotspots.clear();
|
|
1223
|
+
for (const [, t] of this.focusTraps)
|
|
1224
|
+
t.destroy();
|
|
1225
|
+
this.focusTraps.clear();
|
|
1226
|
+
}
|
|
1227
|
+
/** Read scene transition duration from CSS variable (handles both ms and s units) */
|
|
1228
|
+
getSceneTransitionDuration() {
|
|
1229
|
+
if (typeof getComputedStyle > "u") return 400;
|
|
1230
|
+
const t = getComputedStyle(this.containerEl).getPropertyValue("--ci-hotspot-scene-transition-duration").trim(), e = parseFloat(t);
|
|
1231
|
+
return isNaN(e) ? 400 : t.endsWith("s") && !t.endsWith("ms") ? e * 1e3 : e;
|
|
1232
|
+
}
|
|
1233
|
+
performSceneTransition(t, e, i, o) {
|
|
1234
|
+
var c;
|
|
1235
|
+
if (e === "none") {
|
|
1236
|
+
this.clearHotspots(), this.switchToScene(t), o();
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
const r = this.getSceneTransitionDuration();
|
|
1240
|
+
v(this.containerEl, "ci-hotspot-scene-transitioning");
|
|
1241
|
+
const s = h("img", "ci-hotspot-scene-incoming", {
|
|
1242
|
+
alt: t.alt || "",
|
|
1243
|
+
draggable: "false"
|
|
1244
|
+
});
|
|
1245
|
+
if ((c = this.config.cloudimage) != null && c.token) {
|
|
1246
|
+
const l = this.containerEl.offsetWidth || 300, d = typeof window < "u" && window.devicePixelRatio || 1;
|
|
1247
|
+
s.src = z(t.src, this.config.cloudimage, l, 1, d);
|
|
1248
|
+
} else
|
|
1249
|
+
s.src = t.src;
|
|
1250
|
+
const n = () => {
|
|
1251
|
+
if (!this.destroyed) {
|
|
1252
|
+
if (e === "fade")
|
|
1253
|
+
v(s, "ci-hotspot-scene-fade-in"), v(this.imgEl, "ci-hotspot-scene-fade-out");
|
|
1254
|
+
else if (e === "slide") {
|
|
1255
|
+
const l = i ? "-reverse" : "";
|
|
1256
|
+
v(s, `ci-hotspot-scene-slide-in${l}`), v(this.imgEl, `ci-hotspot-scene-slide-out${l}`);
|
|
1257
|
+
}
|
|
1258
|
+
this.viewportEl.insertBefore(s, this.markersEl), this.transitionTimer = setTimeout(() => {
|
|
1259
|
+
if (this.transitionTimer = void 0, this.destroyed) return;
|
|
1260
|
+
this.clearHotspots(), this.switchToScene(t);
|
|
1261
|
+
const l = () => {
|
|
1262
|
+
s.remove(), y(this.imgEl, "ci-hotspot-scene-fade-out"), y(this.imgEl, "ci-hotspot-scene-slide-out"), y(this.imgEl, "ci-hotspot-scene-slide-out-reverse"), y(this.containerEl, "ci-hotspot-scene-transitioning"), o();
|
|
1263
|
+
};
|
|
1264
|
+
this.imgEl.complete && this.imgEl.naturalWidth > 0 ? l() : (this.imgEl.addEventListener("load", l, { once: !0 }), this.imgEl.addEventListener("error", l, { once: !0 }));
|
|
1265
|
+
}, r);
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
s.complete ? n() : (v(this.containerEl, "ci-hotspot-scene-loading"), s.onload = () => {
|
|
1269
|
+
y(this.containerEl, "ci-hotspot-scene-loading"), n();
|
|
1270
|
+
}, s.onerror = () => {
|
|
1271
|
+
this.destroyed || (y(this.containerEl, "ci-hotspot-scene-loading"), s.remove(), y(this.containerEl, "ci-hotspot-scene-transitioning"), this.clearHotspots(), this.switchToScene(t), o());
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
switchToScene(t) {
|
|
1275
|
+
var i;
|
|
1276
|
+
this.config.src = t.src, this.config.alt = t.alt || "", this.config.hotspots = this.sceneHotspotOverrides.get(t.id) ?? [...t.hotspots], this.imgEl.alt = t.alt || "", this.containerEl.setAttribute("aria-label", t.alt || "Image with hotspots"), this.imageLoaded = !1;
|
|
1277
|
+
const e = () => {
|
|
1278
|
+
this.imageLoaded = !0, this.renormalizePixelCoordinates(), this.syncMarkersToImage(), this.showLoadTriggerPopovers();
|
|
1279
|
+
};
|
|
1280
|
+
if (this.imgEl.addEventListener("load", e, { once: !0 }), (i = this.config.cloudimage) != null && i.token) {
|
|
1281
|
+
const o = this.containerEl.offsetWidth || 300, r = typeof window < "u" && window.devicePixelRatio || 1;
|
|
1282
|
+
this.imgEl.src = z(t.src, this.config.cloudimage, o, 1, r);
|
|
1283
|
+
} else
|
|
1284
|
+
this.imgEl.src = t.src;
|
|
1285
|
+
this.imgEl.complete && this.imgEl.naturalWidth > 0 && !this.imageLoaded && (this.imgEl.removeEventListener("load", e), e()), this.initHotspots();
|
|
1286
|
+
}
|
|
1287
|
+
// === Public API ===
|
|
1288
|
+
/** Get references to the internal DOM elements */
|
|
1289
|
+
getElements() {
|
|
1290
|
+
return {
|
|
1291
|
+
container: this.containerEl,
|
|
1292
|
+
viewport: this.viewportEl,
|
|
1293
|
+
image: this.imgEl,
|
|
1294
|
+
markers: this.markersEl
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
open(t) {
|
|
1298
|
+
var o;
|
|
1299
|
+
if (this.destroyed) return;
|
|
1300
|
+
const e = this.popovers.get(t), i = this.markers.get(t);
|
|
1301
|
+
!e || !i || e.isVisible() || (this.closeAll(), e.show(), g(i, !0), (o = this.focusTraps.get(t)) == null || o.activate());
|
|
1302
|
+
}
|
|
1303
|
+
close(t) {
|
|
1304
|
+
var o;
|
|
1305
|
+
if (this.destroyed) return;
|
|
1306
|
+
const e = this.popovers.get(t), i = this.markers.get(t);
|
|
1307
|
+
e && i && (e.hide(), g(i, !1), (o = this.focusTraps.get(t)) == null || o.deactivate());
|
|
1308
|
+
}
|
|
1309
|
+
closeAll() {
|
|
1310
|
+
var t;
|
|
1311
|
+
if (!this.destroyed) {
|
|
1312
|
+
for (const [e, i] of this.popovers)
|
|
1313
|
+
if (i.isVisible()) {
|
|
1314
|
+
i.hide();
|
|
1315
|
+
const o = this.markers.get(e);
|
|
1316
|
+
o && g(o, !1), (t = this.focusTraps.get(e)) == null || t.deactivate();
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
setZoom(t) {
|
|
1321
|
+
var e;
|
|
1322
|
+
this.destroyed || (e = this.zoomPan) == null || e.setZoom(t);
|
|
1323
|
+
}
|
|
1324
|
+
getZoom() {
|
|
1325
|
+
var t;
|
|
1326
|
+
return ((t = this.zoomPan) == null ? void 0 : t.getZoom()) || 1;
|
|
1327
|
+
}
|
|
1328
|
+
resetZoom() {
|
|
1329
|
+
var t;
|
|
1330
|
+
this.destroyed || (t = this.zoomPan) == null || t.resetZoom();
|
|
1331
|
+
}
|
|
1332
|
+
goToScene(t) {
|
|
1333
|
+
if (this.destroyed || this.isTransitioning || !this.scenesMap.size || t === this.currentSceneId) return;
|
|
1334
|
+
const e = this.scenesMap.get(t);
|
|
1335
|
+
if (!e) return;
|
|
1336
|
+
const i = this.config.sceneTransition || "fade";
|
|
1337
|
+
this.isTransitioning = !0, this.zoomPan && this.zoomPan.getZoom() > 1 && this.zoomPan.resetZoom();
|
|
1338
|
+
let o = !1;
|
|
1339
|
+
if (i === "slide") {
|
|
1340
|
+
for (const r of this.config.hotspots)
|
|
1341
|
+
if (r.navigateTo === t) {
|
|
1342
|
+
const s = this.normalizedHotspots.get(r.id);
|
|
1343
|
+
s && s.x <= 50 && (o = !0);
|
|
1344
|
+
break;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
this.syncCurrentSceneHotspots(), this.currentSceneId = t, this.performSceneTransition(e, i, o, () => {
|
|
1348
|
+
var s, n;
|
|
1349
|
+
this.isTransitioning = !1, $t(`Navigated to ${e.alt || t}`), (n = (s = this.config).onSceneChange) == null || n.call(s, t, e);
|
|
1350
|
+
const r = e.hotspots[0];
|
|
1351
|
+
if (r) {
|
|
1352
|
+
const c = this.markers.get(r.id);
|
|
1353
|
+
c && document.activeElement && this.containerEl.contains(document.activeElement) && c.focus();
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
getCurrentScene() {
|
|
1358
|
+
return this.currentSceneId;
|
|
1359
|
+
}
|
|
1360
|
+
getScenes() {
|
|
1361
|
+
return Array.from(this.scenesMap.keys());
|
|
1362
|
+
}
|
|
1363
|
+
enterFullscreen() {
|
|
1364
|
+
var t;
|
|
1365
|
+
this.destroyed || (t = this.fullscreenControl) == null || t.enter();
|
|
1366
|
+
}
|
|
1367
|
+
exitFullscreen() {
|
|
1368
|
+
var t;
|
|
1369
|
+
this.destroyed || (t = this.fullscreenControl) == null || t.exit();
|
|
1370
|
+
}
|
|
1371
|
+
isFullscreen() {
|
|
1372
|
+
var t;
|
|
1373
|
+
return ((t = this.fullscreenControl) == null ? void 0 : t.isFullscreen()) ?? !1;
|
|
1374
|
+
}
|
|
1375
|
+
addHotspot(t) {
|
|
1376
|
+
this.destroyed || (this.config.hotspots.push(t), this.addHotspotInternal(t), this.syncCurrentSceneHotspots());
|
|
1377
|
+
}
|
|
1378
|
+
removeHotspot(t) {
|
|
1379
|
+
if (this.destroyed) return;
|
|
1380
|
+
const e = this.hotspotCleanups.get(t);
|
|
1381
|
+
e && (e.forEach((s) => s()), this.hotspotCleanups.delete(t));
|
|
1382
|
+
const i = this.focusTraps.get(t);
|
|
1383
|
+
i && (i.destroy(), this.focusTraps.delete(t));
|
|
1384
|
+
const o = this.markers.get(t), r = this.popovers.get(t);
|
|
1385
|
+
r && (r.destroy(), this.popovers.delete(t)), o && (I(o), this.markers.delete(t)), this.normalizedHotspots.delete(t), this.config.hotspots = this.config.hotspots.filter((s) => s.id !== t), this.syncCurrentSceneHotspots();
|
|
1386
|
+
}
|
|
1387
|
+
updateHotspot(t, e) {
|
|
1388
|
+
if (this.destroyed) return;
|
|
1389
|
+
const i = this.config.hotspots.findIndex((l) => l.id === t);
|
|
1390
|
+
if (i === -1) return;
|
|
1391
|
+
const o = this.markers.get(t), r = (o == null ? void 0 : o.nextElementSibling) || null, n = { ...this.config.hotspots[i], ...e };
|
|
1392
|
+
this.removeHotspot(t), this.config.hotspots.splice(i, 0, n), this.addHotspotInternal(n);
|
|
1393
|
+
const c = this.markers.get(t);
|
|
1394
|
+
c && r && this.markersEl.contains(r) && this.markersEl.insertBefore(c, r), this.syncCurrentSceneHotspots();
|
|
1395
|
+
}
|
|
1396
|
+
update(t) {
|
|
1397
|
+
this.destroyed || (this.destroyInternal(), q(), this.config = X({ ...this.config, ...t }), j(this.config), this.config.scenes && this.config.scenes.length > 0 && this.initScenes(), this.buildDOM(), this.applyTheme(), this.setupImage(), this.initHotspots(), this.config.zoom && this.initZoom(), this.initKeyboard(), this.initFullscreen(), this.setupResponsive());
|
|
1398
|
+
}
|
|
1399
|
+
destroy() {
|
|
1400
|
+
this.destroyed || (this.destroyed = !0, this.destroyInternal(), this.rootEl.innerHTML = "");
|
|
1401
|
+
}
|
|
1402
|
+
destroyInternal() {
|
|
1403
|
+
var t, e, i, o, r, s, n;
|
|
1404
|
+
this.imageLoaded = !1;
|
|
1405
|
+
for (const c of this.activeTimers) clearTimeout(c);
|
|
1406
|
+
this.activeTimers.clear();
|
|
1407
|
+
for (const c of this.hotspotCleanups.values())
|
|
1408
|
+
c.forEach((l) => l());
|
|
1409
|
+
this.hotspotCleanups.clear(), this.cleanups.forEach((c) => c()), this.cleanups = [];
|
|
1410
|
+
for (const [, c] of this.popovers)
|
|
1411
|
+
c.destroy();
|
|
1412
|
+
this.popovers.clear();
|
|
1413
|
+
for (const [, c] of this.markers)
|
|
1414
|
+
I(c);
|
|
1415
|
+
this.markers.clear(), this.normalizedHotspots.clear();
|
|
1416
|
+
for (const [, c] of this.focusTraps)
|
|
1417
|
+
c.destroy();
|
|
1418
|
+
this.focusTraps.clear(), this.scenesMap.clear(), this.preloadedScenes.clear(), this.sceneHotspotOverrides.clear(), this.currentSceneId = void 0, this.isTransitioning = !1, this.transitionTimer !== void 0 && (clearTimeout(this.transitionTimer), this.transitionTimer = void 0), (t = this.fullscreenControl) == null || t.destroy(), this.fullscreenControl = null, (e = this.keyboardHandler) == null || e.destroy(), this.keyboardHandler = null, (i = this.zoomPan) == null || i.destroy(), this.zoomPan = null, (o = this.zoomControls) == null || o.destroy(), this.zoomControls = null, (r = this.scrollHint) == null || r.destroy(), this.scrollHint = null, (s = this.cloudimageHandler) == null || s.destroy(), this.cloudimageHandler = null, (n = this.resizeObserver) == null || n.disconnect(), this.resizeObserver = null, Xt();
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
M.NAVIGATE_ARROW_SVG = '<svg class="ci-hotspot-navigate-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>';
|
|
1422
|
+
let Y = M;
|
|
1423
|
+
const C = {
|
|
1424
|
+
cursor: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.586 12.586 19 19"/><path d="M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z"/></svg>',
|
|
1425
|
+
plus: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>',
|
|
1426
|
+
undo: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/></svg>',
|
|
1427
|
+
redo: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m15 14 5-5-5-5"/><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13"/></svg>',
|
|
1428
|
+
trash: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>',
|
|
1429
|
+
download: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>',
|
|
1430
|
+
upload: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v12"/><path d="m17 8-5-5-5 5"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/></svg>',
|
|
1431
|
+
copy: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
|
|
1432
|
+
image: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>'
|
|
1433
|
+
};
|
|
1434
|
+
class Ut {
|
|
1435
|
+
constructor(t, e) {
|
|
1436
|
+
this.parentEl = t, this.editor = e, this.toolbarEl = h("div", "ci-editor-toolbar"), this.urlBarEl = h("div", "ci-editor-url-bar"), this.build();
|
|
1437
|
+
const i = this.parentEl.firstChild;
|
|
1438
|
+
this.parentEl.insertBefore(this.toolbarEl, i), this.parentEl.insertBefore(this.urlBarEl, i);
|
|
1439
|
+
}
|
|
1440
|
+
build() {
|
|
1441
|
+
const t = h("div", "ci-editor-toolbar-group");
|
|
1442
|
+
this.selectBtn = this.createBtn(C.cursor, "Select", () => this.editor.setMode("select")), this.addBtn = this.createBtn(C.plus, "Add", () => this.editor.setMode("add")), t.appendChild(this.selectBtn), t.appendChild(this.addBtn), this.toolbarEl.appendChild(t), this.toolbarEl.appendChild(this.createSeparator());
|
|
1443
|
+
const e = h("div", "ci-editor-toolbar-group");
|
|
1444
|
+
this.undoBtn = this.createBtn(C.undo, "Undo", () => this.editor.getUndoManager().undo()), this.redoBtn = this.createBtn(C.redo, "Redo", () => this.editor.getUndoManager().redo()), this.deleteBtn = this.createBtn(C.trash, "Delete", () => {
|
|
1445
|
+
const n = this.editor.getSelection().getSelectedId();
|
|
1446
|
+
n && this.editor.removeHotspot(n);
|
|
1447
|
+
}), e.appendChild(this.undoBtn), e.appendChild(this.redoBtn), e.appendChild(this.deleteBtn), this.toolbarEl.appendChild(e), this.toolbarEl.appendChild(this.createSeparator());
|
|
1448
|
+
const i = h("div", "ci-editor-toolbar-group");
|
|
1449
|
+
this.exportBtn = this.createBtn(C.download, "Export", () => this.showExportJSON()), this.importBtn = this.createBtn(C.upload, "Import", () => this.showImportModal()), this.copyBtn = this.createBtn(C.copy, "Copy JSON", () => this.copyJSON()), i.appendChild(this.exportBtn), i.appendChild(this.importBtn), i.appendChild(this.copyBtn), this.toolbarEl.appendChild(i);
|
|
1450
|
+
const o = h("span", "ci-editor-btn-icon");
|
|
1451
|
+
o.innerHTML = C.image;
|
|
1452
|
+
const r = h("input", "ci-editor-toolbar-url");
|
|
1453
|
+
r.type = "url", r.placeholder = "Image URL...", r.value = this.editor.getSrc();
|
|
1454
|
+
const s = this.createBtn("", "Load", () => this.loadImageUrl(r));
|
|
1455
|
+
r.addEventListener("keydown", (n) => {
|
|
1456
|
+
n.key === "Enter" && (n.preventDefault(), this.loadImageUrl(r));
|
|
1457
|
+
}), this.urlBarEl.appendChild(o), this.urlBarEl.appendChild(r), this.urlBarEl.appendChild(s), this.updateState();
|
|
1458
|
+
}
|
|
1459
|
+
createBtn(t, e, i) {
|
|
1460
|
+
const o = h("button", "ci-editor-btn");
|
|
1461
|
+
return o.innerHTML = t, o.appendChild(document.createTextNode(` ${e}`)), o.title = e, o.setAttribute("aria-label", e), o.addEventListener("click", (r) => {
|
|
1462
|
+
r.stopPropagation(), i();
|
|
1463
|
+
}), o;
|
|
1464
|
+
}
|
|
1465
|
+
createSeparator() {
|
|
1466
|
+
return h("div", "ci-editor-toolbar-separator");
|
|
1467
|
+
}
|
|
1468
|
+
updateState() {
|
|
1469
|
+
const t = this.editor.getMode();
|
|
1470
|
+
this.selectBtn.classList.toggle("ci-editor-btn--active", t === "select"), this.addBtn.classList.toggle("ci-editor-btn--active", t === "add"), this.selectBtn.setAttribute("aria-pressed", String(t === "select")), this.addBtn.setAttribute("aria-pressed", String(t === "add"));
|
|
1471
|
+
const e = this.editor.getUndoManager();
|
|
1472
|
+
this.undoBtn.disabled = !e.canUndo(), this.redoBtn.disabled = !e.canRedo(), this.deleteBtn.disabled = !this.editor.getSelection().getSelectedId();
|
|
1473
|
+
}
|
|
1474
|
+
showExportJSON() {
|
|
1475
|
+
const t = this.editor.exportJSON(), e = new Blob([t], { type: "application/json" }), i = URL.createObjectURL(e), o = h("a");
|
|
1476
|
+
o.href = i, o.download = "hotspots.json", o.click(), URL.revokeObjectURL(i), this.editor.showToast("Exported hotspots.json");
|
|
1477
|
+
}
|
|
1478
|
+
async copyJSON() {
|
|
1479
|
+
try {
|
|
1480
|
+
await navigator.clipboard.writeText(this.editor.exportJSON()), this.editor.showToast("Copied JSON to clipboard");
|
|
1481
|
+
} catch {
|
|
1482
|
+
this.editor.showToast("Failed to copy");
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
showImportModal() {
|
|
1486
|
+
const t = h("div", "ci-editor-modal-overlay"), e = h("div", "ci-editor-modal");
|
|
1487
|
+
e.setAttribute("role", "dialog"), e.setAttribute("aria-modal", "true");
|
|
1488
|
+
const i = "ci-editor-import-title";
|
|
1489
|
+
e.setAttribute("aria-labelledby", i);
|
|
1490
|
+
const o = h("h3");
|
|
1491
|
+
o.id = i, o.textContent = "Import Hotspots JSON";
|
|
1492
|
+
const r = h("textarea");
|
|
1493
|
+
r.placeholder = `[
|
|
1494
|
+
{ "id": "h1", "x": "50%", "y": "50%", "label": "My Hotspot" }
|
|
1495
|
+
]`;
|
|
1496
|
+
const s = h("div", "ci-editor-modal-error");
|
|
1497
|
+
s.style.display = "none";
|
|
1498
|
+
const n = h("div", "ci-editor-modal-actions"), c = h("button", "ci-editor-btn");
|
|
1499
|
+
c.textContent = "Cancel";
|
|
1500
|
+
const l = h("button", "ci-editor-btn ci-editor-btn--primary");
|
|
1501
|
+
l.textContent = "Import", n.appendChild(c), n.appendChild(l), e.appendChild(o), e.appendChild(r), e.appendChild(s), e.appendChild(n), t.appendChild(e), document.body.appendChild(t);
|
|
1502
|
+
const d = O(e, this.importBtn), u = () => {
|
|
1503
|
+
d.destroy(), t.remove();
|
|
1504
|
+
};
|
|
1505
|
+
c.addEventListener("click", u), t.addEventListener("click", (p) => {
|
|
1506
|
+
p.target === t && u();
|
|
1507
|
+
}), t.addEventListener("keydown", (p) => {
|
|
1508
|
+
p.key === "Escape" && u();
|
|
1509
|
+
}), l.addEventListener("click", () => {
|
|
1510
|
+
try {
|
|
1511
|
+
this.editor.importJSON(r.value), u(), this.editor.showToast("Imported hotspots");
|
|
1512
|
+
} catch (p) {
|
|
1513
|
+
s.style.display = "block", s.textContent = p instanceof Error ? p.message : "Invalid JSON";
|
|
1514
|
+
}
|
|
1515
|
+
}), r.focus(), d.activate();
|
|
1516
|
+
}
|
|
1517
|
+
loadImageUrl(t) {
|
|
1518
|
+
const e = t.value.trim();
|
|
1519
|
+
e && (this.editor.setSrc(e), this.editor.showToast("Image updated"));
|
|
1520
|
+
}
|
|
1521
|
+
destroy() {
|
|
1522
|
+
this.toolbarEl.remove(), this.urlBarEl.remove();
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
class _t {
|
|
1526
|
+
constructor(t) {
|
|
1527
|
+
this.editor = t, this.selectedId = null, this.cleanups = [], this.bindCanvasClicks();
|
|
1528
|
+
}
|
|
1529
|
+
bindCanvasClicks() {
|
|
1530
|
+
const t = f(this.editor.getCanvasEl(), "click", (e) => {
|
|
1531
|
+
if (this.editor.getMode() !== "select") return;
|
|
1532
|
+
const i = e.target, o = i.closest("[data-hotspot-id]");
|
|
1533
|
+
if (o) {
|
|
1534
|
+
e.stopPropagation();
|
|
1535
|
+
const r = o.getAttribute("data-hotspot-id");
|
|
1536
|
+
r && this.select(r);
|
|
1537
|
+
} else {
|
|
1538
|
+
const r = i.closest(".ci-editor-toolbar"), s = i.closest(".ci-editor-sidebar");
|
|
1539
|
+
!r && !s && this.deselect();
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
this.cleanups.push(t);
|
|
1543
|
+
}
|
|
1544
|
+
select(t) {
|
|
1545
|
+
this.selectedId !== t && (this.deselect(), this.selectedId = t, this.applySelectedClass(t, !0), this.editor.events.emit("hotspot:select", t), this.editor.getToolbar().updateState());
|
|
1546
|
+
}
|
|
1547
|
+
deselect() {
|
|
1548
|
+
if (!this.selectedId) return;
|
|
1549
|
+
const t = this.selectedId;
|
|
1550
|
+
this.applySelectedClass(t, !1), this.selectedId = null, this.editor.events.emit("hotspot:deselect", t), this.editor.getToolbar().updateState();
|
|
1551
|
+
}
|
|
1552
|
+
getSelectedId() {
|
|
1553
|
+
return this.selectedId;
|
|
1554
|
+
}
|
|
1555
|
+
refreshMarkerVisuals() {
|
|
1556
|
+
this.selectedId && this.applySelectedClass(this.selectedId, !0);
|
|
1557
|
+
}
|
|
1558
|
+
applySelectedClass(t, e) {
|
|
1559
|
+
const o = this.editor.getCanvasEl().querySelector(`[data-hotspot-id="${t}"]`);
|
|
1560
|
+
o && o.classList.toggle("ci-hotspot-marker--editor-selected", e);
|
|
1561
|
+
}
|
|
1562
|
+
destroy() {
|
|
1563
|
+
this.cleanups.forEach((t) => t()), this.cleanups = [];
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
class qt {
|
|
1567
|
+
constructor(t, e) {
|
|
1568
|
+
this.parentEl = t, this.editor = e, this.fieldCounter = 0, this.panelEl = h("div", "ci-editor-panel"), this.parentEl.appendChild(this.panelEl), this.editor.events.on("hotspot:select", () => this.refresh()), this.editor.events.on("hotspot:deselect", () => this.refresh()), this.refresh();
|
|
1569
|
+
}
|
|
1570
|
+
refresh() {
|
|
1571
|
+
const t = this.editor.getSelection().getSelectedId();
|
|
1572
|
+
if (!t) {
|
|
1573
|
+
this.renderHotspotList();
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
const e = this.editor.getHotspot(t);
|
|
1577
|
+
if (!e) {
|
|
1578
|
+
this.renderHotspotList();
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
this.renderForm(e);
|
|
1582
|
+
}
|
|
1583
|
+
renderHotspotList() {
|
|
1584
|
+
this.panelEl.innerHTML = "";
|
|
1585
|
+
const t = h("div", "ci-editor-panel-title");
|
|
1586
|
+
t.textContent = "Hotspots", this.panelEl.appendChild(t);
|
|
1587
|
+
const e = this.editor.getHotspots();
|
|
1588
|
+
if (e.length === 0) {
|
|
1589
|
+
const o = h("div", "ci-editor-panel-empty");
|
|
1590
|
+
o.textContent = "No hotspots yet. Use the Add tool to place hotspots on the image.", this.panelEl.appendChild(o);
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
const i = h("ul", "ci-editor-hotspot-list");
|
|
1594
|
+
i.setAttribute("role", "listbox"), i.setAttribute("aria-label", "Hotspot list");
|
|
1595
|
+
for (const o of e) {
|
|
1596
|
+
const r = h("li", "ci-editor-hotspot-item");
|
|
1597
|
+
r.setAttribute("data-list-id", o.id), r.setAttribute("role", "option"), r.setAttribute("tabindex", "0");
|
|
1598
|
+
const s = h("span", "ci-editor-hotspot-item-label");
|
|
1599
|
+
s.textContent = o.label || o.id;
|
|
1600
|
+
const n = h("span", "ci-editor-hotspot-item-coords");
|
|
1601
|
+
n.textContent = `${this.fmtCoord(o.x)}, ${this.fmtCoord(o.y)}`, r.appendChild(s), r.appendChild(n);
|
|
1602
|
+
const c = () => this.editor.getSelection().select(o.id);
|
|
1603
|
+
r.addEventListener("click", c), r.addEventListener("keydown", (l) => {
|
|
1604
|
+
(l.key === "Enter" || l.key === " ") && (l.preventDefault(), c());
|
|
1605
|
+
}), i.appendChild(r);
|
|
1606
|
+
}
|
|
1607
|
+
this.panelEl.appendChild(i);
|
|
1608
|
+
}
|
|
1609
|
+
renderForm(t) {
|
|
1610
|
+
this.panelEl.innerHTML = "", this.fieldCounter = 0;
|
|
1611
|
+
const e = h("div", "ci-editor-panel-title");
|
|
1612
|
+
e.textContent = `Edit: ${t.label || t.id}`, this.panelEl.appendChild(e), this.panelEl.appendChild(
|
|
1613
|
+
this.createTextField("Label", t.label || "", (c) => {
|
|
1614
|
+
this.editor.updateHotspot(t.id, { label: c });
|
|
1615
|
+
})
|
|
1616
|
+
);
|
|
1617
|
+
const i = h("div", "ci-editor-field-row");
|
|
1618
|
+
i.appendChild(
|
|
1619
|
+
this.createTextField("X", String(t.x), (c) => {
|
|
1620
|
+
this.editor.updateHotspot(t.id, { x: c });
|
|
1621
|
+
})
|
|
1622
|
+
), i.appendChild(
|
|
1623
|
+
this.createTextField("Y", String(t.y), (c) => {
|
|
1624
|
+
this.editor.updateHotspot(t.id, { y: c });
|
|
1625
|
+
})
|
|
1626
|
+
), this.panelEl.appendChild(i), this.panelEl.appendChild(
|
|
1627
|
+
this.createSelect("Trigger", t.trigger || "click", ["hover", "click", "load"], (c) => {
|
|
1628
|
+
this.editor.updateHotspot(t.id, { trigger: c });
|
|
1629
|
+
})
|
|
1630
|
+
), this.panelEl.appendChild(
|
|
1631
|
+
this.createSelect(
|
|
1632
|
+
"Placement",
|
|
1633
|
+
t.placement || "top",
|
|
1634
|
+
["top", "bottom", "left", "right", "auto"],
|
|
1635
|
+
(c) => {
|
|
1636
|
+
this.editor.updateHotspot(t.id, { placement: c });
|
|
1637
|
+
}
|
|
1638
|
+
)
|
|
1639
|
+
);
|
|
1640
|
+
const o = t.data || {};
|
|
1641
|
+
this.panelEl.appendChild(
|
|
1642
|
+
this.createTextField("Title", o.title || "", (c) => {
|
|
1643
|
+
this.editor.updateHotspot(t.id, {
|
|
1644
|
+
data: { ...t.data, title: c }
|
|
1645
|
+
});
|
|
1646
|
+
})
|
|
1647
|
+
), this.panelEl.appendChild(
|
|
1648
|
+
this.createTextField("Price", o.price || "", (c) => {
|
|
1649
|
+
this.editor.updateHotspot(t.id, {
|
|
1650
|
+
data: { ...t.data, price: c }
|
|
1651
|
+
});
|
|
1652
|
+
})
|
|
1653
|
+
), this.panelEl.appendChild(
|
|
1654
|
+
this.createTextArea("Description", o.description || "", (c) => {
|
|
1655
|
+
this.editor.updateHotspot(t.id, {
|
|
1656
|
+
data: { ...t.data, description: c }
|
|
1657
|
+
});
|
|
1658
|
+
})
|
|
1659
|
+
), this.panelEl.appendChild(
|
|
1660
|
+
this.createTextField("Image URL", o.image || "", (c) => {
|
|
1661
|
+
this.editor.updateHotspot(t.id, {
|
|
1662
|
+
data: { ...t.data, image: c }
|
|
1663
|
+
});
|
|
1664
|
+
})
|
|
1665
|
+
), this.panelEl.appendChild(
|
|
1666
|
+
this.createTextField("Link URL", o.url || "", (c) => {
|
|
1667
|
+
this.editor.updateHotspot(t.id, {
|
|
1668
|
+
data: { ...t.data, url: c }
|
|
1669
|
+
});
|
|
1670
|
+
})
|
|
1671
|
+
), this.panelEl.appendChild(
|
|
1672
|
+
this.createTextField("CTA Text", o.ctaText || "", (c) => {
|
|
1673
|
+
this.editor.updateHotspot(t.id, {
|
|
1674
|
+
data: { ...t.data, ctaText: c }
|
|
1675
|
+
});
|
|
1676
|
+
})
|
|
1677
|
+
);
|
|
1678
|
+
const r = h("div", "ci-editor-panel-actions"), s = h("button", "ci-editor-btn ci-editor-btn--danger");
|
|
1679
|
+
s.textContent = "Delete Hotspot", s.addEventListener("click", () => this.editor.removeHotspot(t.id));
|
|
1680
|
+
const n = h("button", "ci-editor-btn");
|
|
1681
|
+
n.textContent = "Back to List", n.addEventListener("click", () => this.editor.getSelection().deselect()), r.appendChild(n), r.appendChild(s), this.panelEl.appendChild(r);
|
|
1682
|
+
}
|
|
1683
|
+
nextFieldId(t) {
|
|
1684
|
+
return `ci-editor-field-${t.toLowerCase().replace(/\s+/g, "-")}-${++this.fieldCounter}`;
|
|
1685
|
+
}
|
|
1686
|
+
createTextField(t, e, i) {
|
|
1687
|
+
const o = this.nextFieldId(t), r = h("div", "ci-editor-field"), s = h("label", "", { for: o });
|
|
1688
|
+
s.textContent = t;
|
|
1689
|
+
const n = h("input", "", { id: o });
|
|
1690
|
+
return n.type = "text", n.value = e, n.addEventListener("change", () => i(n.value)), r.appendChild(s), r.appendChild(n), r;
|
|
1691
|
+
}
|
|
1692
|
+
createTextArea(t, e, i) {
|
|
1693
|
+
const o = this.nextFieldId(t), r = h("div", "ci-editor-field"), s = h("label", "", { for: o });
|
|
1694
|
+
s.textContent = t;
|
|
1695
|
+
const n = h("textarea", "", { id: o });
|
|
1696
|
+
return n.value = e, n.addEventListener("change", () => i(n.value)), r.appendChild(s), r.appendChild(n), r;
|
|
1697
|
+
}
|
|
1698
|
+
createSelect(t, e, i, o) {
|
|
1699
|
+
const r = this.nextFieldId(t), s = h("div", "ci-editor-field"), n = h("label", "", { for: r });
|
|
1700
|
+
n.textContent = t;
|
|
1701
|
+
const c = h("select", "", { id: r });
|
|
1702
|
+
for (const l of i) {
|
|
1703
|
+
const d = h("option");
|
|
1704
|
+
d.value = l, d.textContent = l, l === e && (d.selected = !0), c.appendChild(d);
|
|
1705
|
+
}
|
|
1706
|
+
return c.addEventListener("change", () => o(c.value)), s.appendChild(n), s.appendChild(c), s;
|
|
1707
|
+
}
|
|
1708
|
+
fmtCoord(t) {
|
|
1709
|
+
return typeof t == "string" ? t : `${Math.round(t * 100) / 100}%`;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
class Gt {
|
|
1713
|
+
constructor(t) {
|
|
1714
|
+
this.editor = t, this.cleanups = [], this.dragging = !1, this.dragId = null, this.startX = 0, this.startY = 0, this.markerEl = null, this.origLeft = "", this.origTop = "", this.rafId = null, this.bind();
|
|
1715
|
+
}
|
|
1716
|
+
bind() {
|
|
1717
|
+
this.unbind();
|
|
1718
|
+
const t = this.editor.getCanvasEl(), e = (c) => {
|
|
1719
|
+
if (this.editor.getMode() !== "select") return;
|
|
1720
|
+
const d = c.target.closest("[data-hotspot-id]");
|
|
1721
|
+
if (!d) return;
|
|
1722
|
+
const u = d.getAttribute("data-hotspot-id");
|
|
1723
|
+
u && (c.preventDefault(), this.dragging = !1, this.dragId = u, this.startX = c.clientX, this.startY = c.clientY, this.markerEl = d, this.origLeft = d.style.left, this.origTop = d.style.top, d.setPointerCapture(c.pointerId));
|
|
1724
|
+
}, i = (c) => {
|
|
1725
|
+
if (!this.dragId || !this.markerEl) return;
|
|
1726
|
+
const l = c.clientX - this.startX, d = c.clientY - this.startY;
|
|
1727
|
+
if (!this.dragging && Math.abs(l) + Math.abs(d) < 3 || (this.dragging = !0, this.rafId !== null)) return;
|
|
1728
|
+
const u = c.clientX, p = c.clientY;
|
|
1729
|
+
this.rafId = requestAnimationFrame(() => {
|
|
1730
|
+
if (this.rafId = null, !this.markerEl) return;
|
|
1731
|
+
const m = t.querySelector(".ci-hotspot-image");
|
|
1732
|
+
if (!m) return;
|
|
1733
|
+
const b = m.getBoundingClientRect(), k = (u - b.left) / b.width * 100, x = (p - b.top) / b.height * 100, H = Math.max(0, Math.min(100, k)), w = Math.max(0, Math.min(100, x));
|
|
1734
|
+
this.markerEl.style.left = `${H}%`, this.markerEl.style.top = `${w}%`;
|
|
1735
|
+
});
|
|
1736
|
+
}, o = (c) => {
|
|
1737
|
+
if (this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), !!this.dragId) {
|
|
1738
|
+
if (this.dragging && this.markerEl) {
|
|
1739
|
+
const l = t.querySelector(".ci-hotspot-image");
|
|
1740
|
+
if (l) {
|
|
1741
|
+
const d = l.getBoundingClientRect(), u = (c.clientX - d.left) / d.width * 100, p = (c.clientY - d.top) / d.height * 100, m = Math.max(0, Math.min(100, Math.round(u * 100) / 100)), b = Math.max(0, Math.min(100, Math.round(p * 100) / 100));
|
|
1742
|
+
this.editor.updateHotspot(this.dragId, {
|
|
1743
|
+
x: `${m}%`,
|
|
1744
|
+
y: `${b}%`
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
this.dragId = null, this.dragging = !1, this.markerEl = null;
|
|
1749
|
+
}
|
|
1750
|
+
}, r = f(t, "pointerdown", e), s = f(t, "pointermove", i), n = f(t, "pointerup", o);
|
|
1751
|
+
this.cleanups.push(r, s, n);
|
|
1752
|
+
}
|
|
1753
|
+
unbind() {
|
|
1754
|
+
this.cleanups.forEach((t) => t()), this.cleanups = [];
|
|
1755
|
+
}
|
|
1756
|
+
destroy() {
|
|
1757
|
+
this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.unbind();
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
class Jt {
|
|
1761
|
+
constructor(t, e) {
|
|
1762
|
+
this.editor = t, this.undoStack = [], this.redoStack = [], this.maxHistory = e;
|
|
1763
|
+
}
|
|
1764
|
+
saveInitial() {
|
|
1765
|
+
this.undoStack = [this.editor.createSnapshot()], this.redoStack = [], this.notifyChange();
|
|
1766
|
+
}
|
|
1767
|
+
save() {
|
|
1768
|
+
this.undoStack.push(this.editor.createSnapshot()), this.undoStack.length > this.maxHistory && this.undoStack.shift(), this.redoStack = [], this.notifyChange();
|
|
1769
|
+
}
|
|
1770
|
+
undo() {
|
|
1771
|
+
if (this.undoStack.length <= 1) return;
|
|
1772
|
+
const t = this.undoStack.pop();
|
|
1773
|
+
this.redoStack.push(t);
|
|
1774
|
+
const e = this.undoStack[this.undoStack.length - 1];
|
|
1775
|
+
this.editor.restoreSnapshot(e), this.notifyChange();
|
|
1776
|
+
}
|
|
1777
|
+
redo() {
|
|
1778
|
+
if (this.redoStack.length === 0) return;
|
|
1779
|
+
const t = this.redoStack.pop();
|
|
1780
|
+
this.undoStack.push(t), this.editor.restoreSnapshot(t), this.notifyChange();
|
|
1781
|
+
}
|
|
1782
|
+
canUndo() {
|
|
1783
|
+
return this.undoStack.length > 1;
|
|
1784
|
+
}
|
|
1785
|
+
canRedo() {
|
|
1786
|
+
return this.redoStack.length > 0;
|
|
1787
|
+
}
|
|
1788
|
+
notifyChange() {
|
|
1789
|
+
this.editor.events.emit("history:change"), this.editor.getToolbar().updateState();
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
const Kt = '.ci-editor{--ci-editor-panel-bg: #ffffff;--ci-editor-panel-color: #1a1a1a;--ci-editor-panel-border: 1px solid #e0e0e0;--ci-editor-panel-shadow: 0 2px 8px rgba(0, 0, 0, .1);--ci-editor-accent: #0058a3;--ci-editor-accent-hover: #004a8c;--ci-editor-danger: #d32f2f;--ci-editor-danger-hover: #b71c1c;--ci-editor-radius: 8px;--ci-editor-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--ci-editor-selected-ring: 0 0 0 3px rgba(0, 88, 163, .5);--ci-editor-toolbar-bg: #f5f5f5;display:flex;flex-direction:column;font-family:var(--ci-editor-font);color:var(--ci-editor-panel-color);line-height:1.5}.ci-editor *,.ci-editor *:before,.ci-editor *:after{box-sizing:border-box}.ci-editor-body{display:flex;gap:0;min-height:400px}.ci-editor-canvas{flex:1;position:relative;overflow:hidden;background:#f0f0f0;border:var(--ci-editor-panel-border);border-radius:var(--ci-editor-radius);cursor:default}.ci-editor-canvas--add-mode{cursor:crosshair}.ci-editor-sidebar{width:280px;flex-shrink:0;border-left:var(--ci-editor-panel-border);background:var(--ci-editor-panel-bg);overflow-y:auto}.ci-editor-toolbar{display:flex;align-items:center;gap:8px;padding:8px 12px;background:var(--ci-editor-toolbar-bg);border:var(--ci-editor-panel-border);border-radius:var(--ci-editor-radius) var(--ci-editor-radius) 0 0}.ci-editor-toolbar-group{display:flex;align-items:center;gap:4px}.ci-editor-toolbar-separator{width:1px;height:24px;background:#d0d0d0;margin:0 4px}.ci-editor-url-bar{display:flex;align-items:center;gap:8px;padding:6px 12px;background:var(--ci-editor-toolbar-bg);border:var(--ci-editor-panel-border);border-top:none}.ci-editor-toolbar-url{flex:1;min-width:200px;padding:6px 10px;border:1px solid #d0d0d0;border-radius:6px;font-family:var(--ci-editor-font);font-size:13px;color:var(--ci-editor-panel-color);background:#fff;transition:border-color .15s}.ci-editor-toolbar-url:focus{outline:none;border-color:var(--ci-editor-accent);box-shadow:0 0 0 2px #0058a326}.ci-editor-btn-icon{display:inline-flex;align-items:center;color:#666}.ci-editor-btn-icon svg{width:16px;height:16px}.ci-editor-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid #d0d0d0;border-radius:6px;background:#fff;color:var(--ci-editor-panel-color);font-family:var(--ci-editor-font);font-size:13px;font-weight:500;cursor:pointer;transition:background .15s,border-color .15s,box-shadow .15s;white-space:nowrap;line-height:1}.ci-editor-btn:hover{background:#f5f5f5;border-color:#bbb}.ci-editor-btn:active{background:#ebebeb}.ci-editor-btn--active{background:var(--ci-editor-accent);color:#fff;border-color:var(--ci-editor-accent)}.ci-editor-btn--active:hover{background:var(--ci-editor-accent-hover);border-color:var(--ci-editor-accent-hover)}.ci-editor-btn--primary{background:var(--ci-editor-accent);color:#fff;border-color:var(--ci-editor-accent)}.ci-editor-btn--primary:hover{background:var(--ci-editor-accent-hover)}.ci-editor-btn--danger{color:var(--ci-editor-danger);border-color:var(--ci-editor-danger)}.ci-editor-btn--danger:hover{background:var(--ci-editor-danger);color:#fff}.ci-editor-btn:focus-visible{outline:3px solid var(--ci-editor-focus-ring, #4A90D9);outline-offset:2px}.ci-editor-btn:disabled{opacity:.4;cursor:default;pointer-events:none}.ci-editor-btn svg{width:14px;height:14px;flex-shrink:0}.ci-editor-badge{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 6px;border-radius:10px;background:var(--ci-editor-accent);color:#fff;font-size:11px;font-weight:600;line-height:1}.ci-editor-panel{padding:16px}.ci-editor-panel-title{margin:0 0 12px;font-size:14px;font-weight:600}.ci-editor-panel-empty{padding:32px 16px;text-align:center;color:#888;font-size:13px}.ci-editor-field{margin-bottom:12px}.ci-editor-field label{display:block;margin-bottom:4px;font-size:12px;font-weight:500;color:#666}.ci-editor-field input[type=text],.ci-editor-field input[type=number],.ci-editor-field input[type=url],.ci-editor-field textarea,.ci-editor-field select{width:100%;padding:6px 10px;border:1px solid #d0d0d0;border-radius:6px;font-family:var(--ci-editor-font);font-size:13px;color:var(--ci-editor-panel-color);background:#fff;transition:border-color .15s}.ci-editor-field input:focus,.ci-editor-field textarea:focus,.ci-editor-field select:focus{outline:none;border-color:var(--ci-editor-accent);box-shadow:0 0 0 2px #0058a326}.ci-editor-field textarea{resize:vertical;min-height:60px}.ci-editor-field-row{display:flex;gap:8px}.ci-editor-field-row .ci-editor-field{flex:1}.ci-editor-panel-actions{display:flex;gap:8px;margin-top:16px;padding-top:12px;border-top:1px solid #e0e0e0}.ci-editor-hotspot-list{list-style:none;margin:0;padding:0}.ci-editor-hotspot-item{display:flex;align-items:center;gap:8px;padding:8px 16px;cursor:pointer;border-bottom:1px solid #f0f0f0;font-size:13px;transition:background .1s}.ci-editor-hotspot-item:hover{background:#f5f5f5}.ci-editor-hotspot-item--selected{background:#0058a314;border-left:3px solid var(--ci-editor-accent);padding-left:13px}.ci-editor-hotspot-item-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ci-editor-hotspot-item-coords{font-size:11px;color:#999;flex-shrink:0}.ci-hotspot-marker--editor-selected{box-shadow:var(--ci-editor-selected-ring)!important;z-index:3!important}.ci-editor-json{position:relative}.ci-editor-json pre{margin:0;padding:12px;background:#1e1e1e;color:#d4d4d4;border-radius:var(--ci-editor-radius);font-family:SF Mono,Consolas,Liberation Mono,Menlo,monospace;font-size:12px;line-height:1.5;overflow-x:auto;max-height:300px;overflow-y:auto;white-space:pre-wrap;word-break:break-all}.ci-editor-json-actions{display:flex;gap:8px;margin-top:8px}.ci-editor-status{display:flex;align-items:center;justify-content:space-between;padding:4px 12px;background:var(--ci-editor-toolbar-bg);border:var(--ci-editor-panel-border);border-top:none;border-radius:0 0 var(--ci-editor-radius) var(--ci-editor-radius);font-size:12px;color:#666}.ci-editor-toast{position:fixed;bottom:20px;left:50%;transform:translate(-50%) translateY(8px);padding:8px 20px;background:#333;color:#fff;border-radius:20px;font-size:13px;font-family:var(--ci-editor-font);z-index:10001;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s}.ci-editor-toast--visible{opacity:1;transform:translate(-50%) translateY(0);pointer-events:auto}.ci-editor-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0006;display:flex;align-items:center;justify-content:center;z-index:10000}.ci-editor-modal{background:var(--ci-editor-panel-bg);border-radius:12px;box-shadow:0 16px 48px #0003;padding:24px;width:480px;max-width:90vw;max-height:80vh;overflow-y:auto}.ci-editor-modal h3{margin:0 0 16px;font-size:16px;font-weight:600}.ci-editor-modal textarea{width:100%;min-height:200px;padding:12px;border:1px solid #d0d0d0;border-radius:8px;font-family:SF Mono,Consolas,monospace;font-size:12px;resize:vertical}.ci-editor-modal textarea:focus{outline:none;border-color:var(--ci-editor-accent);box-shadow:0 0 0 2px #0058a326}.ci-editor-modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}.ci-editor-modal-error{color:var(--ci-editor-danger);font-size:12px;margin-top:8px}.ci-editor--dark{--ci-editor-panel-bg: #1e1e1e;--ci-editor-panel-color: #e0e0e0;--ci-editor-panel-border: 1px solid #3a3a3a;--ci-editor-panel-shadow: 0 2px 8px rgba(0, 0, 0, .3);--ci-editor-accent: #4a9eff;--ci-editor-accent-hover: #3a8eef;--ci-editor-danger: #ef5350;--ci-editor-danger-hover: #e53935;--ci-editor-selected-ring: 0 0 0 3px rgba(74, 158, 255, .5);--ci-editor-toolbar-bg: #252525}.ci-editor--dark .ci-editor-canvas{background:#2a2a2a}.ci-editor--dark .ci-editor-toolbar-separator{background:#444}.ci-editor--dark .ci-editor-btn{background:#2a2a2a;color:#e0e0e0;border-color:#444}.ci-editor--dark .ci-editor-btn:hover{background:#333;border-color:#555}.ci-editor--dark .ci-editor-btn:active{background:#3a3a3a}.ci-editor--dark .ci-editor-btn--active{background:var(--ci-editor-accent);color:#fff;border-color:var(--ci-editor-accent)}.ci-editor--dark .ci-editor-btn--active:hover{background:var(--ci-editor-accent-hover);border-color:var(--ci-editor-accent-hover)}.ci-editor--dark .ci-editor-btn--primary{background:var(--ci-editor-accent);color:#fff;border-color:var(--ci-editor-accent)}.ci-editor--dark .ci-editor-btn:disabled{opacity:.3}.ci-editor--dark .ci-editor-toolbar-url{background:#2a2a2a;color:#e0e0e0;border-color:#444}.ci-editor--dark .ci-editor-btn-icon,.ci-editor--dark .ci-editor-field label{color:#999}.ci-editor--dark .ci-editor-field input[type=text],.ci-editor--dark .ci-editor-field input[type=number],.ci-editor--dark .ci-editor-field input[type=url],.ci-editor--dark .ci-editor-field textarea,.ci-editor--dark .ci-editor-field select{background:#2a2a2a;color:#e0e0e0;border-color:#444}.ci-editor--dark .ci-editor-panel-empty{color:#777}.ci-editor--dark .ci-editor-hotspot-item{border-bottom-color:#333}.ci-editor--dark .ci-editor-hotspot-item:hover{background:#2a2a2a}.ci-editor--dark .ci-editor-hotspot-item--selected{background:#4a9eff1a}.ci-editor--dark .ci-editor-hotspot-item-coords{color:#777}.ci-editor--dark .ci-editor-status{color:#888}.ci-editor--dark .ci-editor-panel-actions{border-top-color:#3a3a3a}.ci-editor--dark .ci-editor-toast{background:#e0e0e0;color:#1e1e1e}.ci-editor--dark .ci-editor-modal{background:#1e1e1e}.ci-editor--dark .ci-editor-modal textarea{background:#2a2a2a;color:#e0e0e0;border-color:#444}@media (max-width: 768px){.ci-editor-body{flex-direction:column}.ci-editor-sidebar{width:100%;border-left:none;border-top:var(--ci-editor-panel-border);max-height:300px}.ci-editor-toolbar{flex-wrap:wrap}}';
|
|
1793
|
+
class Qt {
|
|
1794
|
+
constructor(t, e) {
|
|
1795
|
+
if (this.viewer = null, this.hotspots = [], this.mode = "select", this.nextId = 1, this.events = new rt(), this.cleanups = [], this.toastEl = null, this.toastTimer = null, this.destroyed = !1, this.rootEl = typeof t == "string" ? document.querySelector(t) : t, !this.rootEl) throw new Error("CIHotspotEditor: element not found");
|
|
1796
|
+
this.config = {
|
|
1797
|
+
defaultTrigger: "click",
|
|
1798
|
+
defaultPlacement: "top",
|
|
1799
|
+
maxHistory: 50,
|
|
1800
|
+
...e
|
|
1801
|
+
}, this.hotspots = e.hotspots ? structuredClone(e.hotspots) : [];
|
|
1802
|
+
for (const i of this.hotspots) {
|
|
1803
|
+
const o = parseInt(i.id.replace(/\D/g, ""), 10);
|
|
1804
|
+
!isNaN(o) && o >= this.nextId && (this.nextId = o + 1);
|
|
1805
|
+
}
|
|
1806
|
+
Q(ot), this.injectEditorStyles(), this.buildDOM(), this.initModules(), this.rebuildViewer(), this.updateStatus();
|
|
1807
|
+
}
|
|
1808
|
+
// === DOM ===
|
|
1809
|
+
injectEditorStyles() {
|
|
1810
|
+
const t = "ci-editor-styles";
|
|
1811
|
+
if (document.getElementById(t)) return;
|
|
1812
|
+
const e = document.createElement("style");
|
|
1813
|
+
e.id = t, e.textContent = Kt, document.head.appendChild(e);
|
|
1814
|
+
}
|
|
1815
|
+
buildDOM() {
|
|
1816
|
+
this.editorEl = h("div", "ci-editor"), this.config.theme === "dark" && this.editorEl.classList.add("ci-editor--dark"), this.canvasEl = h("div", "ci-editor-canvas"), this.sidebarEl = h("div", "ci-editor-sidebar"), this.statusEl = h("div", "ci-editor-status");
|
|
1817
|
+
const t = h("div", "ci-editor-body");
|
|
1818
|
+
t.appendChild(this.canvasEl), t.appendChild(this.sidebarEl), this.editorEl.appendChild(t), this.editorEl.appendChild(this.statusEl), this.rootEl.innerHTML = "", this.rootEl.appendChild(this.editorEl);
|
|
1819
|
+
}
|
|
1820
|
+
initModules() {
|
|
1821
|
+
this.undoManager = new Jt(this, this.config.maxHistory), this.selection = new _t(this), this.toolbar = new Ut(this.editorEl, this), this.propertyPanel = new qt(this.sidebarEl, this), this.dragManager = new Gt(this);
|
|
1822
|
+
const t = f(this.canvasEl, "click", (i) => {
|
|
1823
|
+
var c;
|
|
1824
|
+
if (this.mode !== "add" || i.target.closest(".ci-hotspot-marker")) return;
|
|
1825
|
+
const r = (c = this.canvasEl.querySelector(".ci-hotspot-image")) == null ? void 0 : c.getBoundingClientRect();
|
|
1826
|
+
if (!r) return;
|
|
1827
|
+
const s = (i.clientX - r.left) / r.width * 100, n = (i.clientY - r.top) / r.height * 100;
|
|
1828
|
+
s < 0 || s > 100 || n < 0 || n > 100 || this.addHotspot({
|
|
1829
|
+
x: `${Math.round(s * 100) / 100}%`,
|
|
1830
|
+
y: `${Math.round(n * 100) / 100}%`
|
|
1831
|
+
});
|
|
1832
|
+
});
|
|
1833
|
+
this.cleanups.push(t);
|
|
1834
|
+
const e = f(document, "keydown", (i) => {
|
|
1835
|
+
const o = i.target.tagName;
|
|
1836
|
+
if (o === "INPUT" || o === "TEXTAREA" || o === "SELECT") return;
|
|
1837
|
+
const r = i.metaKey || i.ctrlKey, s = this.editorEl.contains(document.activeElement) || this.editorEl.contains(i.target);
|
|
1838
|
+
if (r && i.key === "z" && !i.shiftKey && s)
|
|
1839
|
+
i.preventDefault(), this.undoManager.undo();
|
|
1840
|
+
else if (r && i.key === "z" && i.shiftKey && s)
|
|
1841
|
+
i.preventDefault(), this.undoManager.redo();
|
|
1842
|
+
else if (r && i.key === "y" && s)
|
|
1843
|
+
i.preventDefault(), this.undoManager.redo();
|
|
1844
|
+
else if ((i.key === "Delete" || i.key === "Backspace") && s) {
|
|
1845
|
+
const n = this.selection.getSelectedId();
|
|
1846
|
+
n && (i.preventDefault(), this.removeHotspot(n));
|
|
1847
|
+
} else i.key === "Escape" && s ? this.mode === "add" ? this.setMode("select") : this.selection.deselect() : i.key === "a" && !r && s ? this.setMode(this.mode === "add" ? "select" : "add") : i.key === "v" && !r && s && this.setMode("select");
|
|
1848
|
+
});
|
|
1849
|
+
this.cleanups.push(e), this.undoManager.saveInitial();
|
|
1850
|
+
}
|
|
1851
|
+
// === Viewer ===
|
|
1852
|
+
rebuildViewer() {
|
|
1853
|
+
var t, e;
|
|
1854
|
+
this.destroyed || (this.viewer && (this.viewer.destroy(), this.viewer = null), this.viewer = new Y(this.canvasEl, {
|
|
1855
|
+
src: this.config.src,
|
|
1856
|
+
alt: this.config.alt || "Editor image",
|
|
1857
|
+
hotspots: this.hotspots,
|
|
1858
|
+
trigger: "click",
|
|
1859
|
+
pulse: !1,
|
|
1860
|
+
lazyLoad: !1,
|
|
1861
|
+
...this.config.cloudimage ? { cloudimage: this.config.cloudimage } : {}
|
|
1862
|
+
}), (t = this.selection) == null || t.refreshMarkerVisuals(), (e = this.dragManager) == null || e.bind());
|
|
1863
|
+
}
|
|
1864
|
+
// === Hotspot CRUD ===
|
|
1865
|
+
addHotspot(t = {}) {
|
|
1866
|
+
if (this.destroyed) return;
|
|
1867
|
+
const e = `hotspot-${this.nextId++}`, i = {
|
|
1868
|
+
...t,
|
|
1869
|
+
id: e,
|
|
1870
|
+
x: t.x ?? "50%",
|
|
1871
|
+
y: t.y ?? "50%",
|
|
1872
|
+
label: t.label || `Hotspot ${this.hotspots.length + 1}`,
|
|
1873
|
+
trigger: t.trigger || this.config.defaultTrigger,
|
|
1874
|
+
placement: t.placement || this.config.defaultPlacement,
|
|
1875
|
+
data: t.data || {}
|
|
1876
|
+
};
|
|
1877
|
+
return this.hotspots.push(i), this.rebuildViewer(), this.selection.select(e), this.undoManager.save(), this.notifyChange("hotspot:add"), this.updateStatus(), i;
|
|
1878
|
+
}
|
|
1879
|
+
removeHotspot(t) {
|
|
1880
|
+
if (this.destroyed) return;
|
|
1881
|
+
const e = this.hotspots.findIndex((i) => i.id === t);
|
|
1882
|
+
e !== -1 && (this.hotspots.splice(e, 1), this.selection.getSelectedId() === t && this.selection.deselect(), this.rebuildViewer(), this.undoManager.save(), this.notifyChange("hotspot:remove"), this.updateStatus());
|
|
1883
|
+
}
|
|
1884
|
+
updateHotspot(t, e) {
|
|
1885
|
+
if (this.destroyed) return;
|
|
1886
|
+
const i = this.hotspots.findIndex((o) => o.id === t);
|
|
1887
|
+
i !== -1 && (this.hotspots[i] = { ...this.hotspots[i], ...e }, this.rebuildViewer(), this.undoManager.save(), this.notifyChange("hotspot:update"), this.updateStatus());
|
|
1888
|
+
}
|
|
1889
|
+
// === State Access ===
|
|
1890
|
+
getHotspots() {
|
|
1891
|
+
return structuredClone(this.hotspots);
|
|
1892
|
+
}
|
|
1893
|
+
getHotspot(t) {
|
|
1894
|
+
const e = this.hotspots.find((i) => i.id === t);
|
|
1895
|
+
return e ? structuredClone(e) : void 0;
|
|
1896
|
+
}
|
|
1897
|
+
setHotspots(t) {
|
|
1898
|
+
this.destroyed || (this.hotspots = structuredClone(t), this.selection.deselect(), this.rebuildViewer(), this.updateStatus());
|
|
1899
|
+
}
|
|
1900
|
+
getMode() {
|
|
1901
|
+
return this.mode;
|
|
1902
|
+
}
|
|
1903
|
+
setMode(t) {
|
|
1904
|
+
this.destroyed || (this.mode = t, this.canvasEl.classList.toggle("ci-editor-canvas--add-mode", t === "add"), this.events.emit("mode:change", t), this.toolbar.updateState(), this.updateStatus());
|
|
1905
|
+
}
|
|
1906
|
+
getCanvasEl() {
|
|
1907
|
+
return this.canvasEl;
|
|
1908
|
+
}
|
|
1909
|
+
getViewer() {
|
|
1910
|
+
return this.viewer;
|
|
1911
|
+
}
|
|
1912
|
+
getSrc() {
|
|
1913
|
+
return this.config.src;
|
|
1914
|
+
}
|
|
1915
|
+
setSrc(t) {
|
|
1916
|
+
this.destroyed || (this.config.src = t, this.rebuildViewer());
|
|
1917
|
+
}
|
|
1918
|
+
getSelection() {
|
|
1919
|
+
return this.selection;
|
|
1920
|
+
}
|
|
1921
|
+
getToolbar() {
|
|
1922
|
+
return this.toolbar;
|
|
1923
|
+
}
|
|
1924
|
+
getUndoManager() {
|
|
1925
|
+
return this.undoManager;
|
|
1926
|
+
}
|
|
1927
|
+
// === Snapshot (for undo/redo) ===
|
|
1928
|
+
createSnapshot() {
|
|
1929
|
+
return {
|
|
1930
|
+
hotspots: structuredClone(this.hotspots),
|
|
1931
|
+
selectedId: this.selection.getSelectedId()
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
restoreSnapshot(t) {
|
|
1935
|
+
this.destroyed || (this.hotspots = structuredClone(t.hotspots), this.rebuildViewer(), t.selectedId && this.hotspots.find((e) => e.id === t.selectedId) ? this.selection.select(t.selectedId) : this.selection.deselect(), this.notifyChange("change"), this.updateStatus());
|
|
1936
|
+
}
|
|
1937
|
+
// === Export ===
|
|
1938
|
+
exportJSON() {
|
|
1939
|
+
return JSON.stringify(this.hotspots, null, 2);
|
|
1940
|
+
}
|
|
1941
|
+
importJSON(t) {
|
|
1942
|
+
if (this.destroyed) return;
|
|
1943
|
+
const e = JSON.parse(t);
|
|
1944
|
+
if (!Array.isArray(e)) throw new Error("Expected an array of hotspots");
|
|
1945
|
+
for (const i of e)
|
|
1946
|
+
if (!i.id || i.x == null || i.y == null)
|
|
1947
|
+
throw new Error("Each hotspot must have id, x, and y");
|
|
1948
|
+
this.hotspots = e;
|
|
1949
|
+
for (const i of this.hotspots) {
|
|
1950
|
+
const o = parseInt(i.id.replace(/\D/g, ""), 10);
|
|
1951
|
+
!isNaN(o) && o >= this.nextId && (this.nextId = o + 1);
|
|
1952
|
+
}
|
|
1953
|
+
this.selection.deselect(), this.rebuildViewer(), this.undoManager.save(), this.notifyChange("change"), this.updateStatus();
|
|
1954
|
+
}
|
|
1955
|
+
// === Notifications ===
|
|
1956
|
+
notifyChange(t) {
|
|
1957
|
+
var e, i, o;
|
|
1958
|
+
this.events.emit(t), this.events.emit("change"), (i = (e = this.config).onChange) == null || i.call(e, this.getHotspots()), (o = this.propertyPanel) == null || o.refresh();
|
|
1959
|
+
}
|
|
1960
|
+
updateStatus() {
|
|
1961
|
+
var r;
|
|
1962
|
+
const t = this.hotspots.length, e = (r = this.selection) == null ? void 0 : r.getSelectedId(), i = this.mode === "add" ? "Add mode" : "Select mode", o = [`${t} hotspot${t !== 1 ? "s" : ""}`, i];
|
|
1963
|
+
e && o.push(`Selected: ${e}`), this.statusEl.textContent = o.join(" | ");
|
|
1964
|
+
}
|
|
1965
|
+
// === Toast ===
|
|
1966
|
+
showToast(t, e = 2e3) {
|
|
1967
|
+
this.destroyed || (this.toastEl || (this.toastEl = h("div", "ci-editor-toast"), this.editorEl.appendChild(this.toastEl)), this.toastEl.textContent = t, this.toastEl.classList.add("ci-editor-toast--visible"), this.toastTimer && clearTimeout(this.toastTimer), this.toastTimer = setTimeout(() => {
|
|
1968
|
+
var i;
|
|
1969
|
+
(i = this.toastEl) == null || i.classList.remove("ci-editor-toast--visible"), this.toastTimer = null;
|
|
1970
|
+
}, e));
|
|
1971
|
+
}
|
|
1972
|
+
// === Lifecycle ===
|
|
1973
|
+
destroy() {
|
|
1974
|
+
var t;
|
|
1975
|
+
this.destroyed || (this.destroyed = !0, this.cleanups.forEach((e) => e()), this.cleanups = [], this.dragManager.destroy(), this.selection.destroy(), this.toolbar.destroy(), (t = this.viewer) == null || t.destroy(), this.events.removeAll(), this.toastTimer && (clearTimeout(this.toastTimer), this.toastTimer = null), this.toastEl = null, this.rootEl.innerHTML = "");
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
export {
|
|
1979
|
+
Qt as CIHotspotEditor
|
|
1980
|
+
};
|
|
1981
|
+
//# sourceMappingURL=js-cloudimage-hotspot-editor.esm.js.map
|