@crystaldesign/widget-library 25.3.0-beta.9 → 25.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/build/esm/index.js +925 -0
  2. package/build/types/widget-library/src/components/Gallery/ArActionIcon/index.d.ts +11 -0
  3. package/build/types/widget-library/src/components/Gallery/ArActionIcon/index.d.ts.map +1 -0
  4. package/build/types/widget-library/src/components/Gallery/MediaItem/ArItem/index.d.ts +18 -0
  5. package/build/types/widget-library/src/components/Gallery/MediaItem/ArItem/index.d.ts.map +1 -0
  6. package/build/types/widget-library/src/components/Gallery/MediaItem/SirvItem/index.d.ts +10 -0
  7. package/build/types/widget-library/src/components/Gallery/MediaItem/SirvItem/index.d.ts.map +1 -0
  8. package/build/types/widget-library/src/components/Gallery/MediaItem/index.d.ts +12 -0
  9. package/build/types/widget-library/src/components/Gallery/MediaItem/index.d.ts.map +1 -0
  10. package/build/types/widget-library/src/components/Gallery/PageNumber/index.d.ts +8 -0
  11. package/build/types/widget-library/src/components/Gallery/PageNumber/index.d.ts.map +1 -0
  12. package/build/types/widget-library/src/components/Gallery/Thumb/index.d.ts +9 -0
  13. package/build/types/widget-library/src/components/Gallery/Thumb/index.d.ts.map +1 -0
  14. package/build/types/widget-library/src/components/Gallery/index.d.ts +5 -0
  15. package/build/types/widget-library/src/components/Gallery/index.d.ts.map +1 -0
  16. package/build/types/widget-library/src/components/Gallery/types.d.ts +38 -0
  17. package/build/types/widget-library/src/components/Gallery/types.d.ts.map +1 -0
  18. package/build/types/widget-library/src/components/Gallery/useGallery.d.ts +15 -0
  19. package/build/types/widget-library/src/components/Gallery/useGallery.d.ts.map +1 -0
  20. package/build/types/widget-library/src/components/actions/Action/index.d.ts +4 -0
  21. package/build/types/widget-library/src/components/actions/Action/index.d.ts.map +1 -0
  22. package/build/types/widget-library/src/components/actions/ActionGroup/index.d.ts +4 -0
  23. package/build/types/widget-library/src/components/actions/ActionGroup/index.d.ts.map +1 -0
  24. package/build/types/widget-library/src/components/actions/index.d.ts +4 -0
  25. package/build/types/widget-library/src/components/actions/index.d.ts.map +1 -0
  26. package/build/types/widget-library/src/components/actions/types.d.ts +27 -0
  27. package/build/types/widget-library/src/components/actions/types.d.ts.map +1 -0
  28. package/build/types/widget-library/src/components/index.d.ts +4 -0
  29. package/build/types/widget-library/src/components/index.d.ts.map +1 -0
  30. package/build/types/widget-library/src/components/texts/Text/index.d.ts +5 -0
  31. package/build/types/widget-library/src/components/texts/Text/index.d.ts.map +1 -0
  32. package/build/types/widget-library/src/components/texts/TextBlock/index.d.ts +4 -0
  33. package/build/types/widget-library/src/components/texts/TextBlock/index.d.ts.map +1 -0
  34. package/build/types/widget-library/src/components/texts/index.d.ts +4 -0
  35. package/build/types/widget-library/src/components/texts/index.d.ts.map +1 -0
  36. package/build/types/widget-library/src/components/texts/types.d.ts +14 -0
  37. package/build/types/widget-library/src/components/texts/types.d.ts.map +1 -0
  38. package/build/types/widget-library/src/hooks/index.d.ts +4 -0
  39. package/build/types/widget-library/src/hooks/index.d.ts.map +1 -0
  40. package/build/types/widget-library/src/hooks/useConfiguration.d.ts +2 -0
  41. package/build/types/widget-library/src/hooks/useConfiguration.d.ts.map +1 -0
  42. package/build/types/widget-library/src/hooks/useCss.d.ts +3 -0
  43. package/build/types/widget-library/src/hooks/useCss.d.ts.map +1 -0
  44. package/build/types/widget-library/src/hooks/useMedia.d.ts +9 -0
  45. package/build/types/widget-library/src/hooks/useMedia.d.ts.map +1 -0
  46. package/build/types/widget-library/src/hooks/useProductData.d.ts +12 -0
  47. package/build/types/widget-library/src/hooks/useProductData.d.ts.map +1 -0
  48. package/build/types/widget-library/src/hooks/useSirv.d.ts +7 -0
  49. package/build/types/widget-library/src/hooks/useSirv.d.ts.map +1 -0
  50. package/build/types/widget-library/src/index.d.ts +4 -0
  51. package/build/types/widget-library/src/index.d.ts.map +1 -1
  52. package/build/types/widget-library/src/tests/components/actions/Action.test.d.ts +2 -0
  53. package/build/types/widget-library/src/tests/components/actions/Action.test.d.ts.map +1 -0
  54. package/build/types/widget-library/src/tests/components/actions/ActionGroup.test.d.ts +2 -0
  55. package/build/types/widget-library/src/tests/components/actions/ActionGroup.test.d.ts.map +1 -0
  56. package/build/types/widget-library/src/tests/components/texts/Text.test.d.ts +2 -0
  57. package/build/types/widget-library/src/tests/components/texts/Text.test.d.ts.map +1 -0
  58. package/build/types/widget-library/src/tests/components/texts/TextBlock.test.d.ts +2 -0
  59. package/build/types/widget-library/src/tests/components/texts/TextBlock.test.d.ts.map +1 -0
  60. package/build/types/widget-library/src/tests/utils/replaceActions.test.d.ts +2 -0
  61. package/build/types/widget-library/src/tests/utils/replaceActions.test.d.ts.map +1 -0
  62. package/build/types/widget-library/src/tests/utils/replaceTemplateString.test.d.ts +2 -0
  63. package/build/types/widget-library/src/tests/utils/replaceTemplateString.test.d.ts.map +1 -0
  64. package/build/types/widget-library/src/tests/utils/updateCssInDom.test.d.ts +2 -0
  65. package/build/types/widget-library/src/tests/utils/updateCssInDom.test.d.ts.map +1 -0
  66. package/build/types/widget-library/src/types/index.d.ts +10 -0
  67. package/build/types/widget-library/src/types/index.d.ts.map +1 -0
  68. package/build/types/widget-library/src/utils/index.d.ts +3 -0
  69. package/build/types/widget-library/src/utils/index.d.ts.map +1 -0
  70. package/build/types/widget-library/src/utils/replaceActions.d.ts +16 -0
  71. package/build/types/widget-library/src/utils/replaceActions.d.ts.map +1 -0
  72. package/build/types/widget-library/src/utils/replaceTemplateStrings.d.ts +14 -0
  73. package/build/types/widget-library/src/utils/replaceTemplateStrings.d.ts.map +1 -0
  74. package/build/types/widget-library/src/utils/updateCssInDom.d.ts +8 -0
  75. package/build/types/widget-library/src/utils/updateCssInDom.d.ts.map +1 -0
  76. package/package.json +6 -2
@@ -1,3 +1,19 @@
1
+ import { useEffect, useMemo, useState, forwardRef, useRef } from 'react';
2
+ import { useDivaCore, getLogger, DivaError, useTranslation } from '@crystaldesign/diva-core';
3
+ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
4
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
+ import _regeneratorRuntime from '@babel/runtime/regenerator';
6
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
7
+ import { Navigation, Thumbs, Pagination } from 'swiper/modules';
8
+ import { Swiper, SwiperSlide } from 'swiper/react';
9
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
10
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
+ import classNames from 'classnames';
12
+ import { useLayer, Arrow } from 'react-laag';
13
+ import QRCode from 'react-qr-code';
14
+ import _typeof from '@babel/runtime/helpers/typeof';
15
+ import flatten$1, { flatten } from 'flat';
16
+
1
17
  (function() {
2
18
  const env = {"STAGE":"production"};
3
19
  try {
@@ -9,3 +25,912 @@
9
25
  } catch (e) {} // avoid ReferenceError: process is not defined
10
26
  globalThis.process = { env:env };
11
27
  })();
28
+
29
+ /**
30
+ * Make sure that the CSS is in the dome and that it has the current content
31
+ *
32
+ * @param url an url to a css file
33
+ * @param css the css content as text
34
+ */
35
+ function updateCssInDom (url, css) {
36
+ if (url) {
37
+ var element = document.getElementById('DIVA-PDP-STYLE-URL');
38
+ if (element) {
39
+ var _element$parentNode;
40
+ (_element$parentNode = element.parentNode) === null || _element$parentNode === void 0 || _element$parentNode.removeChild(element);
41
+ }
42
+ element = document.createElement('link');
43
+ element.rel = 'stylesheet';
44
+ element.type = 'text/css';
45
+ element.id = 'DIVA-PDP-STYLE-URL';
46
+ element.href = url;
47
+ document.head.appendChild(element);
48
+ }
49
+ if (css) {
50
+ var finalCss = Array.isArray(css) ? css.join(' ') : css;
51
+ var _element = document.getElementById('DIVA-PDP-STYLE');
52
+ if (_element) {
53
+ var _element$parentNode2;
54
+ (_element$parentNode2 = _element.parentNode) === null || _element$parentNode2 === void 0 || _element$parentNode2.removeChild(_element);
55
+ }
56
+ _element = document.createElement('style');
57
+ _element.type = 'text/css';
58
+ _element.id = 'DIVA-PDP-STYLE';
59
+ _element.appendChild(document.createTextNode(finalCss));
60
+ document.head.appendChild(_element);
61
+ }
62
+ }
63
+
64
+ function useCss(settings) {
65
+ useEffect(function () {
66
+ updateCssInDom(settings.cssUrl, settings.css);
67
+ }, [settings.cssUrl, settings.css]);
68
+ }
69
+
70
+ function useConfiguration(type, componentSettings) {
71
+ var _useDivaCore = useDivaCore(),
72
+ getSubConfiguration = _useDivaCore.actions.getSubConfiguration;
73
+ var settings = useMemo(function () {
74
+ return componentSettings !== null && componentSettings !== void 0 ? componentSettings : getSubConfiguration(type);
75
+ }, [getSubConfiguration, type, componentSettings]);
76
+ if (!settings) {
77
+ throw new Error("Configuration for ".concat(type, " not found"));
78
+ }
79
+ return settings;
80
+ }
81
+
82
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
83
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
84
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
85
+ var LOG = getLogger('DivaWidget', 'useProductData');
86
+ function useProductData(_ref) {
87
+ var productIds = _ref.productIds,
88
+ variants = _ref.variants,
89
+ onProductLoaded = _ref.onProductLoaded;
90
+ var _useDivaCore = useDivaCore(),
91
+ handler = _useDivaCore.handler;
92
+ var _useState = useState(variants !== null && variants !== void 0 ? variants : []),
93
+ _useState2 = _slicedToArray(_useState, 2),
94
+ productVariants = _useState2[0],
95
+ setProductVariants = _useState2[1];
96
+ var _useState3 = useState(false),
97
+ _useState4 = _slicedToArray(_useState3, 2),
98
+ error = _useState4[0],
99
+ setError = _useState4[1];
100
+ var _useState5 = useState(true),
101
+ _useState6 = _slicedToArray(_useState5, 2),
102
+ loading = _useState6[0],
103
+ setLoading = _useState6[1];
104
+ useEffect(function () {
105
+ setError(false);
106
+ setLoading(true);
107
+ if (!(productIds !== null && productIds !== void 0 && productIds.length)) {
108
+ LOG.error(new DivaError('productIds array is required and cannot be empty'));
109
+ setError(true);
110
+ setLoading(false);
111
+ return;
112
+ }
113
+ (function () {
114
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(ids) {
115
+ var newVariants, productsPromises, productsResults, allProducts, _iterator, _step, _loop;
116
+ return _regeneratorRuntime.wrap(function _callee$(_context2) {
117
+ while (1) switch (_context2.prev = _context2.next) {
118
+ case 0:
119
+ _context2.prev = 0;
120
+ if (!variants) {
121
+ _context2.next = 6;
122
+ break;
123
+ }
124
+ setProductVariants(variants);
125
+ newVariants = variants;
126
+ _context2.next = 13;
127
+ break;
128
+ case 6:
129
+ // Fetch all products in parallel
130
+ productsPromises = ids.map(function (id) {
131
+ return handler.productHandler.apiGetProductVariants(id, true);
132
+ });
133
+ _context2.next = 9;
134
+ return Promise.all(productsPromises);
135
+ case 9:
136
+ productsResults = _context2.sent;
137
+ // Flatten the array of arrays into a single array of variants
138
+ allProducts = productsResults.flat();
139
+ setProductVariants(allProducts);
140
+ newVariants = allProducts;
141
+ case 13:
142
+ // Log business events for loaded products
143
+ _iterator = _createForOfIteratorHelper(newVariants);
144
+ _context2.prev = 14;
145
+ _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
146
+ var product, matchingProductId;
147
+ return _regeneratorRuntime.wrap(function _loop$(_context) {
148
+ while (1) switch (_context.prev = _context.next) {
149
+ case 0:
150
+ product = _step.value;
151
+ matchingProductId = ids.find(function (id) {
152
+ return product._id === id;
153
+ });
154
+ if (matchingProductId) {
155
+ LOG.businessEvent('onLoadProductPDP', 'ProductDetailPage', 'Neues Product in PDP geladen.', {
156
+ productId: matchingProductId,
157
+ catalogName: product.modelName,
158
+ catalogCodex: product.catCodex
159
+ });
160
+ }
161
+ case 3:
162
+ case "end":
163
+ return _context.stop();
164
+ }
165
+ }, _loop);
166
+ });
167
+ _iterator.s();
168
+ case 17:
169
+ if ((_step = _iterator.n()).done) {
170
+ _context2.next = 21;
171
+ break;
172
+ }
173
+ return _context2.delegateYield(_loop(), "t0", 19);
174
+ case 19:
175
+ _context2.next = 17;
176
+ break;
177
+ case 21:
178
+ _context2.next = 26;
179
+ break;
180
+ case 23:
181
+ _context2.prev = 23;
182
+ _context2.t1 = _context2["catch"](14);
183
+ _iterator.e(_context2.t1);
184
+ case 26:
185
+ _context2.prev = 26;
186
+ _iterator.f();
187
+ return _context2.finish(26);
188
+ case 29:
189
+ onProductLoaded === null || onProductLoaded === void 0 || onProductLoaded(newVariants);
190
+ _context2.next = 36;
191
+ break;
192
+ case 32:
193
+ _context2.prev = 32;
194
+ _context2.t2 = _context2["catch"](0);
195
+ LOG.error(new DivaError('Error loading products', {
196
+ cause: _context2.t2
197
+ }));
198
+ setError(true);
199
+ case 36:
200
+ _context2.prev = 36;
201
+ setLoading(false);
202
+ return _context2.finish(36);
203
+ case 39:
204
+ case "end":
205
+ return _context2.stop();
206
+ }
207
+ }, _callee, null, [[0, 32, 36, 39], [14, 23, 26, 29]]);
208
+ }));
209
+ return function (_x) {
210
+ return _ref2.apply(this, arguments);
211
+ };
212
+ })()(productIds);
213
+ }, [variants, productIds]);
214
+ return {
215
+ productVariants: productVariants,
216
+ error: error,
217
+ loading: loading
218
+ };
219
+ }
220
+
221
+ function useSirv(_ref) {
222
+ var hasSirvMedia = _ref.hasSirvMedia,
223
+ baseSirvUrls = _ref.baseSirvUrls;
224
+ var _useState = useState(false),
225
+ _useState2 = _slicedToArray(_useState, 2),
226
+ sirvLoaded = _useState2[0],
227
+ setSirvLoaded = _useState2[1];
228
+ useEffect(function () {
229
+ // Check if Sirv script is already loaded in DOM
230
+ var existingSirvScript = document.querySelector('script[src*="sirv.js"]');
231
+ if (existingSirvScript) {
232
+ setSirvLoaded(true);
233
+ return;
234
+ }
235
+ if (!hasSirvMedia) return;
236
+ var loadSirv = function loadSirv() {
237
+ return new Promise(function (resolve) {
238
+ var script = document.createElement('script');
239
+ script.src = 'https://scripts.sirv.com/sirvjs/v3/sirv.js?modules=lazyimage,zoom,spin';
240
+ script.type = 'text/javascript';
241
+ script.async = true;
242
+ script.onload = resolve;
243
+ document.body.appendChild(script);
244
+ });
245
+ };
246
+ loadSirv().then(function () {
247
+ setSirvLoaded(true);
248
+ });
249
+ }, [hasSirvMedia, baseSirvUrls]);
250
+ return {
251
+ sirvLoaded: sirvLoaded
252
+ };
253
+ }
254
+
255
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
256
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
257
+ function useMedia(_ref) {
258
+ var products = _ref.products,
259
+ functionTypes = _ref.functionTypes,
260
+ add2DImage = _ref.add2DImage,
261
+ add3DImageAsFallback = _ref.add3DImageAsFallback;
262
+ return useMemo(function () {
263
+ var newMedias = [];
264
+ products.forEach(function (product, productIndex) {
265
+ // Track if any media was added for this product
266
+ var hasAddedMediaForProduct = false;
267
+
268
+ // Add media based on function types
269
+ var _loop = function _loop() {
270
+ var _product$media$filter, _product$media;
271
+ var functionType = functionTypes[i];
272
+ var filteredMedia = (_product$media$filter = (_product$media = product.media) === null || _product$media === void 0 ? void 0 : _product$media.filter(function (m) {
273
+ return m.functionType === functionType;
274
+ })) !== null && _product$media$filter !== void 0 ? _product$media$filter : [];
275
+
276
+ // Add product index to each media item
277
+ if (filteredMedia.length > 0) {
278
+ hasAddedMediaForProduct = true;
279
+ newMedias = [].concat(_toConsumableArray(newMedias), _toConsumableArray(filteredMedia.map(function (media) {
280
+ return _objectSpread$3(_objectSpread$3({}, media), {}, {
281
+ productIndex: productIndex
282
+ });
283
+ })));
284
+ }
285
+ };
286
+ for (var i = 0; i < functionTypes.length; i++) {
287
+ _loop();
288
+ }
289
+
290
+ // Add 3D image as fallback only if no media at all exists for this product
291
+ if (add3DImageAsFallback && product.image && !hasAddedMediaForProduct) {
292
+ newMedias.push({
293
+ url: product.image,
294
+ productIndex: productIndex
295
+ });
296
+ }
297
+
298
+ // Add 2D image if configured
299
+ if (add2DImage && product.image2D) {
300
+ newMedias.push({
301
+ url: product.image2D,
302
+ productIndex: productIndex
303
+ });
304
+ }
305
+ });
306
+ return newMedias;
307
+ }, [products, functionTypes, add2DImage, add3DImageAsFallback]);
308
+ }
309
+
310
+ function useGallery(_ref) {
311
+ var products = _ref.products,
312
+ _ref$config = _ref.config,
313
+ functionTypes = _ref$config.functionTypes,
314
+ add2DImage = _ref$config.add2DImage,
315
+ add3DImageAsFallback = _ref$config.add3DImageAsFallback,
316
+ currentProductIndex = _ref.currentProductIndex,
317
+ setCurrentProductIndex = _ref.setCurrentProductIndex;
318
+ var _useDivaCore = useDivaCore(),
319
+ baseSirvUrls = _useDivaCore.state.apiConfig.baseSirvUrls;
320
+ var _useState = useState(null),
321
+ _useState2 = _slicedToArray(_useState, 2),
322
+ thumbsSwiper = _useState2[0],
323
+ setThumbsSwiper = _useState2[1];
324
+ var _useState3 = useState(null),
325
+ _useState4 = _slicedToArray(_useState3, 2),
326
+ swiper = _useState4[0],
327
+ setSwiper = _useState4[1];
328
+ var _useState5 = useState(0),
329
+ _useState6 = _slicedToArray(_useState5, 2),
330
+ currentMediaIndex = _useState6[0],
331
+ setCurrentMediaIndex = _useState6[1];
332
+ var medias = useMedia({
333
+ products: products,
334
+ functionTypes: functionTypes,
335
+ add2DImage: add2DImage,
336
+ add3DImageAsFallback: add3DImageAsFallback
337
+ });
338
+
339
+ // Update currentMediaIndex when currentProductIndex changes from outside
340
+ useEffect(function () {
341
+ var _medias$currentMediaI;
342
+ if (currentProductIndex !== undefined && ((_medias$currentMediaI = medias[currentMediaIndex]) === null || _medias$currentMediaI === void 0 ? void 0 : _medias$currentMediaI.productIndex) !== currentProductIndex) {
343
+ // Find the first media index that corresponds to this product index
344
+ var mediaIndex = medias.findIndex(function (media) {
345
+ return media.productIndex === currentProductIndex;
346
+ });
347
+ if (mediaIndex !== -1 && mediaIndex !== currentMediaIndex) {
348
+ setCurrentMediaIndex(mediaIndex);
349
+ swiper === null || swiper === void 0 || swiper.slideTo(mediaIndex);
350
+ }
351
+ }
352
+ }, [currentProductIndex]);
353
+ var hasSirvMedia = useMemo(function () {
354
+ var _loop = function _loop(i) {
355
+ if (medias.find(function (m) {
356
+ var _m$url;
357
+ return (_m$url = m.url) === null || _m$url === void 0 ? void 0 : _m$url.includes(baseSirvUrls[i]);
358
+ })) return {
359
+ v: true
360
+ };
361
+ },
362
+ _ret;
363
+ for (var i = 0; i < (baseSirvUrls !== null && baseSirvUrls !== void 0 ? baseSirvUrls : []).length; i++) {
364
+ _ret = _loop(i);
365
+ if (_ret) return _ret.v;
366
+ }
367
+ return false;
368
+ }, [medias, baseSirvUrls]);
369
+ var _useSirv = useSirv({
370
+ hasSirvMedia: hasSirvMedia,
371
+ baseSirvUrls: baseSirvUrls
372
+ }),
373
+ sirvLoaded = _useSirv.sirvLoaded;
374
+ var onSlideChange = function onSlideChange(swiper) {
375
+ var newMediaIndex = swiper.realIndex;
376
+ setCurrentMediaIndex(newMediaIndex);
377
+
378
+ // Get the product index corresponding to this media index
379
+ var media = medias[newMediaIndex];
380
+
381
+ // Call the external setCurrentProductIndex if provided
382
+ if (setCurrentProductIndex && media) {
383
+ setCurrentProductIndex(media.productIndex);
384
+ }
385
+ };
386
+
387
+ // Get the current product index based on the current media index
388
+ var currentMedia = medias[currentMediaIndex];
389
+ var derivedCurrentProductIndex = currentMedia === null || currentMedia === void 0 ? void 0 : currentMedia.productIndex;
390
+ return {
391
+ medias: medias,
392
+ sirvLoaded: sirvLoaded,
393
+ thumbsSwiper: thumbsSwiper,
394
+ swiper: swiper,
395
+ currentIndex: currentMediaIndex,
396
+ currentProductIndex: currentProductIndex !== null && currentProductIndex !== void 0 ? currentProductIndex : derivedCurrentProductIndex,
397
+ setCurrentProductIndex: setCurrentProductIndex,
398
+ setThumbsSwiper: setThumbsSwiper,
399
+ setSwiper: setSwiper,
400
+ onSlideChange: onSlideChange
401
+ };
402
+ }
403
+
404
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
405
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
406
+ var SirvMediaItem = function SirvMediaItem(_ref) {
407
+ var _ref$media = _ref.media,
408
+ url = _ref$media.url,
409
+ functionType = _ref$media.functionType,
410
+ _ref$config = _ref.config,
411
+ sirvProps = _ref$config.sirvProps,
412
+ specificSirvProps = _ref$config.specificSirvProps,
413
+ sirvWrapperProps = _ref$config.sirvWrapperProps;
414
+ var props = functionType && specificSirvProps !== null && specificSirvProps !== void 0 && specificSirvProps[functionType] ? specificSirvProps[functionType] : sirvProps;
415
+ var urlObj = new URL(url !== null && url !== void 0 ? url : '');
416
+ urlObj.searchParams.append('crop.type', 'trim');
417
+ urlObj.searchParams.append('crop.pad.x', '10%');
418
+ urlObj.searchParams.append('crop.pad.y', '10%');
419
+ return /*#__PURE__*/jsx("div", _objectSpread$2(_objectSpread$2({
420
+ className: "Sirv custom"
421
+ }, sirvWrapperProps), {}, {
422
+ children: /*#__PURE__*/jsx("div", _objectSpread$2(_objectSpread$2({
423
+ "data-src": urlObj.toString()
424
+ }, props), {}, {
425
+ className: 'diva-sirv-img'
426
+ }))
427
+ }));
428
+ };
429
+
430
+ function styleInject(css, ref) {
431
+ if ( ref === void 0 ) ref = {};
432
+ var insertAt = ref.insertAt;
433
+
434
+ if (!css || typeof document === 'undefined') { return; }
435
+
436
+ var head = document.head || document.getElementsByTagName('head')[0];
437
+ var style = document.createElement('style');
438
+ style.type = 'text/css';
439
+
440
+ if (insertAt === 'top') {
441
+ if (head.firstChild) {
442
+ head.insertBefore(style, head.firstChild);
443
+ } else {
444
+ head.appendChild(style);
445
+ }
446
+ } else {
447
+ head.appendChild(style);
448
+ }
449
+
450
+ if (style.styleSheet) {
451
+ style.styleSheet.cssText = css;
452
+ } else {
453
+ style.appendChild(document.createTextNode(css));
454
+ }
455
+ }
456
+
457
+ var divaAr = "diva-ar-gAk7I";
458
+ var css_248z$2 = "/* This keeps child nodes hidden while the element loads */\n.diva-ar-gAk7I :not(:defined) > * {\n display: none;\n}\n\nmodel-viewer.diva-ar-gAk7I {\n overflow-x: hidden;\n}\n\n@keyframes circle-9De-W {\n from {\n transform: translateX(-50%) rotate(0deg) translateX(50px) rotate(0deg);\n }\n to {\n transform: translateX(-50%) rotate(360deg) translateX(50px) rotate(-360deg);\n }\n}\n\n@keyframes elongate-AkX-b {\n from {\n transform: translateX(100px);\n }\n to {\n transform: translateX(-100px);\n }\n}\n\nmodel-viewer.diva-ar-gAk7I > #ar-prompt {\n position: absolute;\n left: 50%;\n bottom: 175px;\n animation: elongate-AkX-b 2s infinite ease-in-out alternate;\n display: none;\n}\n\nmodel-viewer.diva-ar-gAk7I[ar-status='session-started'] > #ar-prompt {\n display: block;\n}\n\nmodel-viewer.diva-ar-gAk7I > #ar-prompt > img {\n animation: circle-9De-W 4s linear infinite;\n}\n\nmodel-viewer.diva-ar-gAk7I > #ar-failure {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n bottom: 175px;\n display: none;\n}\n\nmodel-viewer.diva-ar-gAk7I[ar-tracking='not-tracking'] > #ar-failure {\n display: block;\n}\n";
459
+ styleInject(css_248z$2);
460
+
461
+ if (!window.customElements.get('model-viewer')) {
462
+ import('@google/model-viewer');
463
+ }
464
+ var ArViewer = /*#__PURE__*/forwardRef(function (_ref, ref) {
465
+ var media = _ref.media;
466
+ var _useDivaCore = useDivaCore(),
467
+ _useDivaCore$state = _useDivaCore.state,
468
+ baseCdnUrl = _useDivaCore$state.apiConfig.baseCdnUrl,
469
+ isFirefox = _useDivaCore$state.isFirefox;
470
+ return /*#__PURE__*/jsxs("model-viewer", {
471
+ ref: ref,
472
+ src: media.url,
473
+ "environment-image": 'neutral',
474
+ shadowIntensity: 1,
475
+ shadowSoftness: 1,
476
+ exposure: 1,
477
+ "camera-controls": true,
478
+ ar: true,
479
+ "ar-modes": !isFirefox ? 'webxr quick-look' : '',
480
+ "ar-scale": 'fixed',
481
+ style: {
482
+ overscrollBehavior: 'none',
483
+ width: '100%',
484
+ height: '100%',
485
+ touchAction: 'none'
486
+ },
487
+ "class": classNames(divaAr, 'diva-pdp-ar'),
488
+ "touch-action": "pan-y",
489
+ children: [/*#__PURE__*/jsx("div", {
490
+ id: "ar-prompt",
491
+ children: /*#__PURE__*/jsx("img", {
492
+ src: baseCdnUrl + '/static/images/hand.png'
493
+ })
494
+ }), /*#__PURE__*/jsx("button", {
495
+ id: "ar-failure",
496
+ children: "AR is not tracking!"
497
+ })]
498
+ });
499
+ });
500
+
501
+ var MediaItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
502
+ var media = _ref.media,
503
+ config = _ref.config;
504
+ _ref.isCurrentlyVisible;
505
+ var useSirv = false;
506
+ var _useDivaCore = useDivaCore(),
507
+ baseSirvUrls = _useDivaCore.state.apiConfig.baseSirvUrls;
508
+ if (!config.disableSirv && media.url && baseSirvUrls !== null && baseSirvUrls !== void 0 && baseSirvUrls.find(function (base) {
509
+ var _media$url;
510
+ return (_media$url = media.url) === null || _media$url === void 0 ? void 0 : _media$url.includes(base);
511
+ })) useSirv = true;
512
+ if (useSirv) return /*#__PURE__*/jsx(SirvMediaItem, {
513
+ media: media,
514
+ config: config
515
+ }, media.url);
516
+ if (media.mediaType == 'AR') return /*#__PURE__*/jsx(ArViewer, {
517
+ ref: ref,
518
+ media: media
519
+ });
520
+ return /*#__PURE__*/jsx("img", {
521
+ className: "gallery-image",
522
+ src: media.url
523
+ }, media.url);
524
+ });
525
+
526
+ var Thumb = function Thumb(_ref) {
527
+ var _media$url;
528
+ var media = _ref.media,
529
+ medias = _ref.medias;
530
+ var _useDivaCore = useDivaCore(),
531
+ baseSirvUrls = _useDivaCore.state.apiConfig.baseSirvUrls;
532
+ function addCrop(url) {
533
+ var res = new URL(url);
534
+ if (url && baseSirvUrls !== null && baseSirvUrls !== void 0 && baseSirvUrls.find(function (base) {
535
+ return url.includes(base);
536
+ })) {
537
+ res.searchParams.append('crop.type', 'trim');
538
+ res.searchParams.append('crop.pad.x', '10%');
539
+ res.searchParams.append('crop.pad.y', '10%');
540
+ }
541
+ return res;
542
+ }
543
+ if (media.mediaType == 'AR') {
544
+ var _ref2, _medias$find$url, _medias$find;
545
+ var mainImageUrl = addCrop((_ref2 = (_medias$find$url = (_medias$find = medias.find(function (m) {
546
+ return m.functionType == 'ART';
547
+ })) === null || _medias$find === void 0 ? void 0 : _medias$find.url) !== null && _medias$find$url !== void 0 ? _medias$find$url : medias[0].url) !== null && _ref2 !== void 0 ? _ref2 : '');
548
+ return /*#__PURE__*/jsxs(Fragment, {
549
+ children: [/*#__PURE__*/jsx("img", {
550
+ className: "gallery-image-thumb",
551
+ src: mainImageUrl.toString()
552
+ }), /*#__PURE__*/jsx("div", {
553
+ className: 'ar-icon-thumb',
554
+ style: {
555
+ backgroundColor: 'white',
556
+ border: 'solid',
557
+ borderWidth: '0.1px',
558
+ borderRadius: '100%'
559
+ }
560
+ })]
561
+ });
562
+ }
563
+ var urlObj = addCrop((_media$url = media.url) !== null && _media$url !== void 0 ? _media$url : '');
564
+ return /*#__PURE__*/jsx("img", {
565
+ className: "gallery-image-thumb",
566
+ src: urlObj.toString()
567
+ });
568
+ };
569
+
570
+ var gallery = "gallery-XR09O";
571
+ var css_248z$1 = ".gallery-XR09O .gallery-thumb .swiper-slide {\n opacity: 0.4;\n}\n.gallery-XR09O .gallery-thumb .swiper-slide-thumb-active {\n opacity: 1;\n}\n\n/*swiper min css*/\n\n@font-face {\n font-family: swiper-icons;\n src: url('data:application/font-woff;charset=utf-8;base64, d09GRgABAAAAAAZgABAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAGRAAAABoAAAAci6qHkUdERUYAAAWgAAAAIwAAACQAYABXR1BPUwAABhQAAAAuAAAANuAY7+xHU1VCAAAFxAAAAFAAAABm2fPczU9TLzIAAAHcAAAASgAAAGBP9V5RY21hcAAAAkQAAACIAAABYt6F0cBjdnQgAAACzAAAAAQAAAAEABEBRGdhc3AAAAWYAAAACAAAAAj//wADZ2x5ZgAAAywAAADMAAAD2MHtryVoZWFkAAABbAAAADAAAAA2E2+eoWhoZWEAAAGcAAAAHwAAACQC9gDzaG10eAAAAigAAAAZAAAArgJkABFsb2NhAAAC0AAAAFoAAABaFQAUGG1heHAAAAG8AAAAHwAAACAAcABAbmFtZQAAA/gAAAE5AAACXvFdBwlwb3N0AAAFNAAAAGIAAACE5s74hXjaY2BkYGAAYpf5Hu/j+W2+MnAzMYDAzaX6QjD6/4//Bxj5GA8AuRwMYGkAPywL13jaY2BkYGA88P8Agx4j+/8fQDYfA1AEBWgDAIB2BOoAeNpjYGRgYNBh4GdgYgABEMnIABJzYNADCQAACWgAsQB42mNgYfzCOIGBlYGB0YcxjYGBwR1Kf2WQZGhhYGBiYGVmgAFGBiQQkOaawtDAoMBQxXjg/wEGPcYDDA4wNUA2CCgwsAAAO4EL6gAAeNpj2M0gyAACqxgGNWBkZ2D4/wMA+xkDdgAAAHjaY2BgYGaAYBkGRgYQiAHyGMF8FgYHIM3DwMHABGQrMOgyWDLEM1T9/w8UBfEMgLzE////P/5//f/V/xv+r4eaAAeMbAxwIUYmIMHEgKYAYjUcsDAwsLKxc3BycfPw8jEQA/gZBASFhEVExcQlJKWkZWTl5BUUlZRVVNXUNTQZBgMAAMR+E+gAEQFEAAAAKgAqACoANAA+AEgAUgBcAGYAcAB6AIQAjgCYAKIArAC2AMAAygDUAN4A6ADyAPwBBgEQARoBJAEuATgBQgFMAVYBYAFqAXQBfgGIAZIBnAGmAbIBzgHsAAB42u2NMQ6CUAyGW568x9AneYYgm4MJbhKFaExIOAVX8ApewSt4Bic4AfeAid3VOBixDxfPYEza5O+Xfi04YADggiUIULCuEJK8VhO4bSvpdnktHI5QCYtdi2sl8ZnXaHlqUrNKzdKcT8cjlq+rwZSvIVczNiezsfnP/uznmfPFBNODM2K7MTQ45YEAZqGP81AmGGcF3iPqOop0r1SPTaTbVkfUe4HXj97wYE+yNwWYxwWu4v1ugWHgo3S1XdZEVqWM7ET0cfnLGxWfkgR42o2PvWrDMBSFj/IHLaF0zKjRgdiVMwScNRAoWUoH78Y2icB/yIY09An6AH2Bdu/UB+yxopYshQiEvnvu0dURgDt8QeC8PDw7Fpji3fEA4z/PEJ6YOB5hKh4dj3EvXhxPqH/SKUY3rJ7srZ4FZnh1PMAtPhwP6fl2PMJMPDgeQ4rY8YT6Gzao0eAEA409DuggmTnFnOcSCiEiLMgxCiTI6Cq5DZUd3Qmp10vO0LaLTd2cjN4fOumlc7lUYbSQcZFkutRG7g6JKZKy0RmdLY680CDnEJ+UMkpFFe1RN7nxdVpXrC4aTtnaurOnYercZg2YVmLN/d/gczfEimrE/fs/bOuq29Zmn8tloORaXgZgGa78yO9/cnXm2BpaGvq25Dv9S4E9+5SIc9PqupJKhYFSSl47+Qcr1mYNAAAAeNptw0cKwkAAAMDZJA8Q7OUJvkLsPfZ6zFVERPy8qHh2YER+3i/BP83vIBLLySsoKimrqKqpa2hp6+jq6RsYGhmbmJqZSy0sraxtbO3sHRydnEMU4uR6yx7JJXveP7WrDycAAAAAAAH//wACeNpjYGRgYOABYhkgZgJCZgZNBkYGLQZtIJsFLMYAAAw3ALgAeNolizEKgDAQBCchRbC2sFER0YD6qVQiBCv/H9ezGI6Z5XBAw8CBK/m5iQQVauVbXLnOrMZv2oLdKFa8Pjuru2hJzGabmOSLzNMzvutpB3N42mNgZGBg4GKQYzBhYMxJLMlj4GBgAYow/P/PAJJhLM6sSoWKfWCAAwDAjgbRAAB42mNgYGBkAIIbCZo5IPrmUn0hGA0AO8EFTQAA');\n font-weight: 400;\n font-style: normal;\n}\n\n.gallery-XR09O.diva-widget-gallery .swiper {\n margin-left: auto;\n margin-right: auto;\n position: relative;\n overflow: hidden;\n list-style: none;\n padding: 0;\n z-index: 1;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-vertical > .swiper-wrapper {\n flex-direction: column;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n z-index: 1;\n display: flex;\n transition-property: transform;\n box-sizing: content-box;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-android .swiper-slide,\n.gallery-XR09O.diva-widget-gallery .swiper-wrapper {\n transform: translate3d(0px, 0, 0);\n}\n.gallery-XR09O.diva-widget-gallery .swiper-pointer-events {\n touch-action: pan-y;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-pointer-events.swiper-vertical {\n touch-action: pan-x;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-slide {\n flex-shrink: 0;\n width: 100%;\n height: 100%;\n position: relative;\n transition-property: transform;\n}\n\n.gallery-XR09O.diva-widget-gallery .swiper-slide-invisible-blank {\n visibility: hidden;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-autoheight,\n.gallery-XR09O.diva-widget-gallery .swiper-autoheight .swiper-slide {\n height: auto;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-autoheight .swiper-wrapper {\n align-items: flex-start;\n transition-property: transform, height;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-backface-hidden .swiper-slide {\n transform: translateZ(0);\n backface-visibility: hidden;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-horizontal.swiper-css-mode > .swiper-wrapper {\n scroll-snap-type: x mandatory;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-vertical.swiper-css-mode > .swiper-wrapper {\n scroll-snap-type: y mandatory;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-centered > .swiper-wrapper::before {\n content: '';\n flex-shrink: 0;\n order: 9999;\n}\n[dir=\"ltr\"] .gallery-XR09O.diva-widget-gallery .swiper-centered.swiper-horizontal > .swiper-wrapper > .swiper-slide:first-child {\n margin-left: var(--swiper-centered-offset-before);\n}\n[dir=\"rtl\"] .gallery-XR09O.diva-widget-gallery .swiper-centered.swiper-horizontal > .swiper-wrapper > .swiper-slide:first-child {\n margin-right: var(--swiper-centered-offset-before);\n}\n.gallery-XR09O.diva-widget-gallery .swiper-centered.swiper-horizontal > .swiper-wrapper::before {\n height: 100%;\n min-height: 1px;\n width: var(--swiper-centered-offset-after);\n}\n.gallery-XR09O.diva-widget-gallery .swiper-centered.swiper-vertical > .swiper-wrapper > .swiper-slide:first-child {\n margin-top: var(--swiper-centered-offset-before);\n}\n.gallery-XR09O.diva-widget-gallery .swiper-centered.swiper-vertical > .swiper-wrapper::before {\n width: 100%;\n min-width: 1px;\n height: var(--swiper-centered-offset-after);\n}\n.gallery-XR09O.diva-widget-gallery .swiper-centered > .swiper-wrapper > .swiper-slide {\n scroll-snap-align: center center;\n}\n\n/*pagination.css*/\n\n.gallery-XR09O .swiper-pagination {\n position: absolute;\n text-align: center;\n transition: 300ms opacity;\n transform: translate3d(0, 0, 0);\n z-index: 10;\n}\n.gallery-XR09O .swiper-pagination.swiper-pagination-hidden {\n opacity: 0;\n}\n.gallery-XR09O .swiper-pagination-disabled > .swiper-pagination,\n.gallery-XR09O .swiper-pagination.swiper-pagination-disabled {\n display: none !important;\n}\n/* Common Styles */\n.gallery-XR09O .swiper-pagination-fraction,\n.gallery-XR09O .swiper-pagination-custom,\n.gallery-XR09O .swiper-horizontal > .swiper-pagination-bullets,\n.gallery-XR09O .swiper-pagination-bullets.swiper-pagination-horizontal {\n bottom: 8px;\n bottom: var(--swiper-pagination-bottom, 8px);\n top: auto;\n top: var(--swiper-pagination-top, auto);\n left: 0;\n width: 100%;\n}\n/* Bullets */\n.gallery-XR09O .swiper-pagination-bullets-dynamic {\n overflow: hidden;\n font-size: 0;\n}\n.gallery-XR09O .swiper-pagination-bullets-dynamic .swiper-pagination-bullet {\n transform: scale(0.33);\n position: relative;\n}\n.gallery-XR09O .swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active {\n transform: scale(1);\n}\n.gallery-XR09O .swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-main {\n transform: scale(1);\n}\n.gallery-XR09O .swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-prev {\n transform: scale(0.66);\n}\n.gallery-XR09O .swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-prev-prev {\n transform: scale(0.33);\n}\n.gallery-XR09O .swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-next {\n transform: scale(0.66);\n}\n.gallery-XR09O .swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-next-next {\n transform: scale(0.33);\n}\n.gallery-XR09O .swiper-pagination-bullet {\n width: 8px;\n width: var(--swiper-pagination-bullet-width, var(--swiper-pagination-bullet-size, 8px));\n height: 8px;\n height: var(--swiper-pagination-bullet-height, var(--swiper-pagination-bullet-size, 8px));\n display: inline-block;\n border-radius: 50%;\n border-radius: var(--swiper-pagination-bullet-border-radius, 50%);\n background: #000;\n background: var(--swiper-pagination-bullet-inactive-color, #000);\n opacity: 0.2;\n opacity: var(--swiper-pagination-bullet-inactive-opacity, 0.2);\n}\n.gallery-XR09O button.swiper-pagination-bullet {\n border: none;\n margin: 0;\n padding: 0;\n box-shadow: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n.gallery-XR09O .swiper-pagination-clickable .swiper-pagination-bullet {\n cursor: pointer;\n}\n.gallery-XR09O .swiper-pagination-bullet:only-child {\n display: none !important;\n}\n.gallery-XR09O .swiper-pagination-bullet-active {\n opacity: 1;\n opacity: var(--swiper-pagination-bullet-opacity, 1);\n background: var(--swiper-theme-color);\n background: var(--swiper-pagination-color, var(--swiper-theme-color));\n}\n.gallery-XR09O .swiper-vertical > .swiper-pagination-bullets,\n.gallery-XR09O .swiper-pagination-vertical.swiper-pagination-bullets {\n right: 8px;\n right: var(--swiper-pagination-right, 8px);\n left: auto;\n left: var(--swiper-pagination-left, auto);\n top: 50%;\n transform: translate3d(0px, -50%, 0);\n}\n.gallery-XR09O .swiper-vertical > .swiper-pagination-bullets .swiper-pagination-bullet,\n.gallery-XR09O .swiper-pagination-vertical.swiper-pagination-bullets .swiper-pagination-bullet {\n margin: 6px 0;\n margin: var(--swiper-pagination-bullet-vertical-gap, 6px) 0;\n display: block;\n}\n.gallery-XR09O .swiper-vertical > .swiper-pagination-bullets.swiper-pagination-bullets-dynamic,\n.gallery-XR09O .swiper-pagination-vertical.swiper-pagination-bullets.swiper-pagination-bullets-dynamic {\n top: 50%;\n transform: translateY(-50%);\n width: 8px;\n}\n.gallery-XR09O .swiper-vertical > .swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet,\n.gallery-XR09O .swiper-pagination-vertical.swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet {\n display: inline-block;\n transition:\n 200ms transform,\n 200ms top;\n}\n.gallery-XR09O .swiper-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet,\n.gallery-XR09O .swiper-pagination-horizontal.swiper-pagination-bullets .swiper-pagination-bullet {\n margin: 0 4px;\n margin: 0 var(--swiper-pagination-bullet-horizontal-gap, 4px);\n}\n.gallery-XR09O .swiper-horizontal > .swiper-pagination-bullets.swiper-pagination-bullets-dynamic,\n.gallery-XR09O .swiper-pagination-horizontal.swiper-pagination-bullets.swiper-pagination-bullets-dynamic {\n left: 50%;\n transform: translateX(-50%);\n white-space: nowrap;\n}\n.gallery-XR09O .swiper-horizontal > .swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet,\n.gallery-XR09O .swiper-pagination-horizontal.swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet {\n transition:\n 200ms transform,\n 200ms left;\n}\n.gallery-XR09O .swiper-horizontal.swiper-rtl > .swiper-pagination-bullets-dynamic .swiper-pagination-bullet {\n transition:\n 200ms transform,\n 200ms right;\n}\n/* Fraction */\n.gallery-XR09O .swiper-pagination-fraction {\n color: inherit;\n color: var(--swiper-pagination-fraction-color, inherit);\n}\n/* Progress */\n.gallery-XR09O .swiper-pagination-progressbar {\n background: rgba(0, 0, 0, 0.25);\n background: var(--swiper-pagination-progressbar-bg-color, rgba(0, 0, 0, 0.25));\n position: absolute;\n}\n.gallery-XR09O .swiper-pagination-progressbar .swiper-pagination-progressbar-fill {\n background: var(--swiper-theme-color);\n background: var(--swiper-pagination-color, var(--swiper-theme-color));\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n transform: scale(0);\n transform-origin: left top;\n}\n.gallery-XR09O .swiper-rtl .swiper-pagination-progressbar .swiper-pagination-progressbar-fill {\n transform-origin: right top;\n}\n.gallery-XR09O .swiper-horizontal > .swiper-pagination-progressbar,\n.gallery-XR09O .swiper-pagination-progressbar.swiper-pagination-horizontal,\n.gallery-XR09O .swiper-vertical > .swiper-pagination-progressbar.swiper-pagination-progressbar-opposite,\n.gallery-XR09O .swiper-pagination-progressbar.swiper-pagination-vertical.swiper-pagination-progressbar-opposite {\n width: 100%;\n height: 4px;\n height: var(--swiper-pagination-progressbar-size, 4px);\n left: 0;\n top: 0;\n}\n.gallery-XR09O .swiper-vertical > .swiper-pagination-progressbar,\n.gallery-XR09O .swiper-pagination-progressbar.swiper-pagination-vertical,\n.gallery-XR09O .swiper-horizontal > .swiper-pagination-progressbar.swiper-pagination-progressbar-opposite,\n.gallery-XR09O .swiper-pagination-progressbar.swiper-pagination-horizontal.swiper-pagination-progressbar-opposite {\n width: 4px;\n width: var(--swiper-pagination-progressbar-size, 4px);\n height: 100%;\n left: 0;\n top: 0;\n}\n.gallery-XR09O .swiper-pagination-lock {\n display: none;\n}\n\n/*navigation*/\n.gallery-XR09O.diva-widget-gallery .swiper-button-prev,\n.gallery-XR09O.diva-widget-gallery .swiper-button-next {\n position: absolute;\n top: 50%;\n top: var(--swiper-navigation-top-offset, 50%);\n width: calc(var(--swiper-navigation-size) / 44 * 27);\n height: var(--swiper-navigation-size);\n margin-top: calc(0px - (var(--swiper-navigation-size) / 2));\n z-index: 10;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--swiper-theme-color);\n color: var(--swiper-navigation-color, var(--swiper-theme-color));\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-prev.swiper-button-disabled,\n.gallery-XR09O.diva-widget-gallery .swiper-button-next.swiper-button-disabled {\n opacity: 0.35;\n cursor: auto;\n pointer-events: none;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-prev.swiper-button-hidden,\n.gallery-XR09O.diva-widget-gallery .swiper-button-next.swiper-button-hidden {\n opacity: 0;\n cursor: auto;\n pointer-events: none;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-navigation-disabled .swiper-button-prev,\n.gallery-XR09O.diva-widget-gallery .swiper-navigation-disabled .swiper-button-next {\n display: none !important;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-prev svg,\n.gallery-XR09O.diva-widget-gallery .swiper-button-next svg {\n width: 100%;\n height: 100%;\n -o-object-fit: contain;\n object-fit: contain;\n transform-origin: center;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-rtl .swiper-button-prev svg,\n.gallery-XR09O.diva-widget-gallery .swiper-rtl .swiper-button-next svg {\n transform: rotate(180deg);\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-prev,\n.gallery-XR09O.diva-widget-gallery .swiper-rtl .swiper-button-next {\n left: 10px;\n left: var(--swiper-navigation-sides-offset, 10px);\n right: auto;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-next,\n.gallery-XR09O.diva-widget-gallery .swiper-rtl .swiper-button-prev {\n right: 10px;\n right: var(--swiper-navigation-sides-offset, 10px);\n left: auto;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-lock {\n display: none;\n}\n/* Navigation font start */\n.gallery-XR09O.diva-widget-gallery .swiper-button-prev:after,\n.gallery-XR09O.diva-widget-gallery .swiper-button-next:after {\n text-transform: none !important;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-prev:after,\n.gallery-XR09O.diva-widget-gallery .swiper-button-next:after {\n font-family: swiper-icons;\n font-size: var(--swiper-navigation-size);\n letter-spacing: 0;\n font-feature-settings: ;\n font-variant: normal;\n font-variant: initial;\n line-height: 1;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-prev:after,\n.gallery-XR09O.diva-widget-gallery .swiper-rtl .swiper-button-next:after {\n content: 'prev';\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-next,\n.gallery-XR09O.diva-widget-gallery .swiper-rtl .swiper-button-prev {\n right: 10px;\n right: var(--swiper-navigation-sides-offset, 10px);\n left: auto;\n}\n.gallery-XR09O.diva-widget-gallery .swiper-button-next:after,\n.gallery-XR09O.diva-widget-gallery .swiper-rtl .swiper-button-prev:after {\n content: 'next';\n}\n/* Navigation font end */\n";
572
+ styleInject(css_248z$1);
573
+
574
+ var galleryAdditional = "gallery-additional-oIgEY";
575
+ var css_248z = ".gallery-additional-oIgEY.diva-widget-gallery {\n width: 100%;\n height: 100%;\n --swiper-navigation-color: #bbb;\n --swiper-navigation-sides-offset: 4px;\n}\n\n.gallery-additional-oIgEY .gallery-main {\n height: 85%;\n}\n\n.gallery-additional-oIgEY .gallery-thumb {\n height: 15%;\n}\n\n.gallery-additional-oIgEY .gallery-image,\n.gallery-additional-oIgEY .gallery-image-thumb {\n width: 100%;\n height: 100%;\n -o-object-fit: scale-down;\n object-fit: scale-down;\n}\n\n.gallery-additional-oIgEY .gallery-image-thumb {\n cursor: pointer;\n}\n\n.gallery-additional-oIgEY .mobile .gallery-main {\n height: 100%;\n}\n\n.gallery-additional-oIgEY .mobile .gallery-thumb {\n display: none;\n}\n\n.gallery-additional-oIgEY .gallery-page-number {\n position: absolute;\n bottom: 16px;\n left: 16px;\n border-radius: 15px;\n z-index: 1000;\n padding: 0 16px;\n}\n";
576
+ styleInject(css_248z);
577
+
578
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
579
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
580
+ var ArActionIcon = function ArActionIcon(_ref) {
581
+ var _config$className;
582
+ var config = _ref.config,
583
+ url = _ref.url,
584
+ htmlArElement = _ref.htmlArElement;
585
+ var _useDivaCore = useDivaCore(),
586
+ _useDivaCore$state = _useDivaCore.state,
587
+ isMobile = _useDivaCore$state.isMobile,
588
+ arViewerBaseUrl = _useDivaCore$state.apiConfig.arViewerBaseUrl;
589
+ var _useTranslation = useTranslation(),
590
+ t = _useTranslation.t;
591
+ var userAgent = navigator.userAgent.toLowerCase();
592
+ var supportAr = !(userAgent.includes('fxios') || userAgent.includes('firefox') || userAgent.includes('edgios') && userAgent.includes('iphone'));
593
+ var useTooltip = !isMobile || !supportAr;
594
+ var _useState = useState(false),
595
+ _useState2 = _slicedToArray(_useState, 2),
596
+ isOpen = _useState2[0],
597
+ setOpen = _useState2[1];
598
+ var _useLayer = useLayer({
599
+ isOpen: isOpen && useTooltip,
600
+ auto: true,
601
+ onOutsideClick: function onOutsideClick() {
602
+ return setOpen(false);
603
+ },
604
+ placement: 'top-start',
605
+ triggerOffset: 10
606
+ }),
607
+ arrowProps = _useLayer.arrowProps,
608
+ layerProps = _useLayer.layerProps,
609
+ renderLayer = _useLayer.renderLayer,
610
+ triggerProps = _useLayer.triggerProps;
611
+ useEffect(function () {
612
+ if (isOpen && !useTooltip) {
613
+ htmlArElement.activateAR();
614
+ }
615
+ }, [isOpen]);
616
+ useEffect(function () {
617
+ var _htmlArElement$shadow;
618
+ var element = (_htmlArElement$shadow = htmlArElement.shadowRoot) === null || _htmlArElement$shadow === void 0 ? void 0 : _htmlArElement$shadow.getElementById('default-ar-button');
619
+ if (element !== null && element !== void 0 && element.style) element.style.display = 'none';
620
+ }, []);
621
+ if (!url || !arViewerBaseUrl) return /*#__PURE__*/jsx(Fragment, {});
622
+ var finalURL = arViewerBaseUrl + '/arViewer?arMedia=' + url;
623
+ var arText = typeof (config === null || config === void 0 ? void 0 : config.text) === 'string' ? config.text : (config === null || config === void 0 ? void 0 : config.text) !== false ? t('widget.gallery.arActionIcon.text') : '';
624
+ return /*#__PURE__*/jsx("div", _objectSpread$1(_objectSpread$1({}, triggerProps), {}, {
625
+ onClick: function onClick() {
626
+ return setOpen(!isOpen);
627
+ },
628
+ className: 'diva-widget-ar-action-icon ' + ((_config$className = config === null || config === void 0 ? void 0 : config.className) !== null && _config$className !== void 0 ? _config$className : ''),
629
+ children: isOpen && useTooltip && renderLayer(/*#__PURE__*/jsxs("div", _objectSpread$1(_objectSpread$1({}, layerProps), {}, {
630
+ className: "ar-tooltip",
631
+ children: [/*#__PURE__*/jsxs("div", {
632
+ className: "ar-tooltip-container",
633
+ onClick: function onClick(e) {
634
+ return e.stopPropagation();
635
+ },
636
+ children: [/*#__PURE__*/jsx(QRCode, {
637
+ value: finalURL,
638
+ className: "qr-code",
639
+ onClick: function onClick() {
640
+ return window.open(finalURL, '_blank');
641
+ }
642
+ }), /*#__PURE__*/jsx("div", {
643
+ className: "text",
644
+ children: arText
645
+ }), /*#__PURE__*/jsx("div", {
646
+ className: "close",
647
+ onClick: function onClick() {
648
+ return setOpen(false);
649
+ }
650
+ })]
651
+ }), /*#__PURE__*/jsx(Arrow, _objectSpread$1({
652
+ onPointerEnterCapture: undefined,
653
+ onPointerLeaveCapture: undefined
654
+ }, arrowProps))]
655
+ })))
656
+ }));
657
+ };
658
+
659
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
660
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
661
+ var focusable = '.smv-cursor-zoom-in, .sirv-zoom-wrapper, .sirv-zoom-map-lens ,.sirv-zoom-map, .sirv-deepzoom, .smv-icon, canvas, .diva-sirv-img, input, select, option, textarea, button, video, label';
662
+ var noSwiping = 'canvas, model-viewer, .sirv-zoom-map, .zoom-controls, .smv-icon';
663
+ var Gallery = function Gallery(props) {
664
+ var _medias$find, _props$config$arIconP;
665
+ var _useGallery = useGallery(props),
666
+ medias = _useGallery.medias,
667
+ thumbsSwiper = _useGallery.thumbsSwiper,
668
+ swiper = _useGallery.swiper,
669
+ onSlideChange = _useGallery.onSlideChange,
670
+ setThumbsSwiper = _useGallery.setThumbsSwiper,
671
+ setSwiper = _useGallery.setSwiper;
672
+ var htmlArElement = useRef(null);
673
+ if (!medias.length) return /*#__PURE__*/jsx(Fragment, {});
674
+ var arUrl = (_medias$find = medias.find(function (m) {
675
+ return m.mediaType == 'AR';
676
+ })) === null || _medias$find === void 0 ? void 0 : _medias$find.url;
677
+ return /*#__PURE__*/jsxs("div", {
678
+ className: classNames(gallery, galleryAdditional, ' diva-widget-gallery', props.config.className),
679
+ children: [!((_props$config$arIconP = props.config.arIconProps) !== null && _props$config$arIconP !== void 0 && _props$config$arIconP.hidden) && (htmlArElement === null || htmlArElement === void 0 ? void 0 : htmlArElement.current) && arUrl && /*#__PURE__*/jsx(ArActionIcon, {
680
+ config: props.config.arIconProps,
681
+ url: arUrl,
682
+ htmlArElement: htmlArElement === null || htmlArElement === void 0 ? void 0 : htmlArElement.current
683
+ }), /*#__PURE__*/jsx(Swiper, _objectSpread(_objectSpread({
684
+ onSwiper: setSwiper,
685
+ resizeObserver: false,
686
+ onSlideChange: onSlideChange,
687
+ focusableElements: focusable,
688
+ noSwipingSelector: noSwiping,
689
+ navigation: true,
690
+ thumbs: {
691
+ swiper: thumbsSwiper && !thumbsSwiper.destroyed ? thumbsSwiper : null
692
+ },
693
+ modules: [Navigation, Thumbs, Pagination],
694
+ className: "gallery-main"
695
+ }, props.config.sliderProp), {}, {
696
+ children: medias.map(function (media, i) {
697
+ return /*#__PURE__*/jsx(SwiperSlide, {
698
+ id: 'gallery media index ' + i,
699
+ children: /*#__PURE__*/jsx(MediaItem, {
700
+ media: media,
701
+ config: props.config,
702
+ isCurrentlyVisible: i === (swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex),
703
+ ref: htmlArElement
704
+ })
705
+ }, media.ref);
706
+ })
707
+ })), /*#__PURE__*/jsx(Swiper, _objectSpread(_objectSpread({
708
+ onSwiper: setThumbsSwiper,
709
+ resizeObserver: false,
710
+ slidesPerView: medias.length < 5 ? medias.length : 6,
711
+ modules: [Navigation, Thumbs],
712
+ className: "gallery-thumb"
713
+ }, props.config.thumbSliderProp), {}, {
714
+ children: medias.map(function (media, i) {
715
+ return /*#__PURE__*/jsx(SwiperSlide, {
716
+ id: 'thumb media index ' + i,
717
+ children: /*#__PURE__*/jsx(Thumb, {
718
+ media: media,
719
+ medias: medias
720
+ }, i)
721
+ }, media.ref + 't');
722
+ })
723
+ }))]
724
+ });
725
+ };
726
+
727
+ var Action = function Action(_ref) {
728
+ var _ref$config = _ref.config,
729
+ icon = _ref$config.icon,
730
+ iconClass = _ref$config.iconClass,
731
+ textClass = _ref$config.textClass,
732
+ onClick = _ref$config.onClick,
733
+ onDoubleClick = _ref$config.onDoubleClick,
734
+ text = _ref$config.text,
735
+ className = _ref$config.className;
736
+ return /*#__PURE__*/jsxs("button", {
737
+ className: classNames('diva-widget-action', className),
738
+ onDoubleClick: onDoubleClick ? onClick : undefined,
739
+ onClick: !onDoubleClick ? onClick : undefined,
740
+ children: [typeof text == 'string' && /*#__PURE__*/jsx("div", {
741
+ className: classNames(textClass, 'diva-widget-action-text'),
742
+ children: text
743
+ }), icon !== undefined && /*#__PURE__*/jsx("img", {
744
+ src: icon
745
+ }), iconClass !== undefined && /*#__PURE__*/jsx("div", {
746
+ className: classNames(iconClass, 'diva-widget-action-icon')
747
+ })]
748
+ });
749
+ };
750
+
751
+ var ActionGroup = function ActionGroup(_ref) {
752
+ var _config$actions;
753
+ var config = _ref.config;
754
+ return /*#__PURE__*/jsx("div", {
755
+ className: classNames('diva-widget-actions', config.className),
756
+ children: (_config$actions = config.actions) === null || _config$actions === void 0 ? void 0 : _config$actions.map(function (a, index) {
757
+ return /*#__PURE__*/jsx(Action, {
758
+ config: a
759
+ }, index);
760
+ })
761
+ });
762
+ };
763
+
764
+ var Text = function Text(_ref) {
765
+ var config = _ref.config;
766
+ return /*#__PURE__*/jsx("div", {
767
+ className: classNames('diva-widget-text', config.className),
768
+ dangerouslySetInnerHTML: {
769
+ __html: config.text
770
+ }
771
+ });
772
+ };
773
+
774
+ function TextBlock(_ref) {
775
+ var config = _ref.config;
776
+ return /*#__PURE__*/jsx("div", {
777
+ className: classNames('diva-widget-text-block', config.className),
778
+ children: config.texts.map(function (text, index) {
779
+ return /*#__PURE__*/jsx(Text, {
780
+ config: text
781
+ }, index);
782
+ })
783
+ });
784
+ }
785
+
786
+ /**
787
+ * Replaces the template strings in the content with the actual product data
788
+ *
789
+ * @param content the content to parse
790
+ * @param product the product data to use
791
+ * @param language the language to use
792
+ */
793
+ function replaceTemplatesInObject(content, product, language) {
794
+ if (typeof content == 'string') return content;
795
+ var flatProduct = flatten(product);
796
+ return recursiveReplaceTemplates(content, flatProduct, language);
797
+ }
798
+
799
+ /**
800
+ * Replaces the template string in all fields of the content object with the actual product data
801
+ *
802
+ * @param content the content to parse
803
+ * @param product the flattend version of the product data
804
+ */
805
+ function recursiveReplaceTemplates(content, product, language) {
806
+ for (var _i = 0, _Object$entries = Object.entries(content); _i < _Object$entries.length; _i++) {
807
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
808
+ key = _Object$entries$_i[0],
809
+ value = _Object$entries$_i[1];
810
+ if (typeof content[key] === 'string' && key != 'link') {
811
+ content[key] = replaceTemplateString(value, product, language);
812
+ }
813
+ if (_typeof(content[key]) === 'object') {
814
+ //check if the object is a language dictionary, if so replace it with the value for the current language
815
+ var keys = Object.keys(content[key]);
816
+ if (keys.includes(language) || keys.includes('de')) {
817
+ var _content$key$language;
818
+ content[key] = replaceTemplateString((_content$key$language = content[key][language]) !== null && _content$key$language !== void 0 ? _content$key$language : content[key].de, product, language);
819
+ } else {
820
+ content[key] = recursiveReplaceTemplates(content[key], product, language);
821
+ }
822
+ }
823
+ }
824
+ return content;
825
+ }
826
+
827
+ /**
828
+ * replaces the templates in on string with the actual product data
829
+ *
830
+ * @param template the templatestring to parse
831
+ * @param product the flattend version of the product data
832
+ * @param locale the locale to use, if any
833
+ */
834
+ function replaceTemplateString(template, product, locale) {
835
+ var matches = checkForTemplateStrings(template);
836
+ var flatProduct = flatten(product);
837
+ for (var _i2 = 0, _matches = matches; _i2 < _matches.length; _i2++) {
838
+ var _flatProduct;
839
+ var match = _matches[_i2];
840
+ //if a locale is provided, check if there is a locale version of the field (fallback is 'de'), if not use the default
841
+ var productField = match.replace('product.', '');
842
+ var value = void 0;
843
+ if (locale) value = (_flatProduct = flatProduct["".concat(productField, "_locales.").concat(locale)]) !== null && _flatProduct !== void 0 ? _flatProduct : flatProduct["".concat(productField, "_locales.de")];
844
+ if (!value) value = flatProduct[productField];
845
+ if (value != undefined) template = template.replace('${' + match + '}', value);
846
+ }
847
+ return template;
848
+ }
849
+
850
+ /**
851
+ * Extracts all substrings that are inside ${...}
852
+ *
853
+ * @param input the template to parse
854
+ * @returns a list of values extracted form the template
855
+ */
856
+ function checkForTemplateStrings(input) {
857
+ // Regular expression to match ${...}
858
+ var regex = /\$\{([^}]+)\}/g;
859
+ var matches = [];
860
+ var match;
861
+
862
+ // Find all matches
863
+ while ((match = regex.exec(input)) !== null) {
864
+ // Extract the content inside ${...}
865
+ matches.push(match[1]);
866
+ }
867
+ return matches;
868
+ }
869
+
870
+ /**
871
+ * Replace the configurated actions with an onClick function
872
+ *
873
+ * Needs to be called after the references are resolved, but before the templates are replaced.
874
+ * The onClick function accepts a product id, which can differ from the current product, so the translation has to be done in the function
875
+ *
876
+ * @param content the content to replace the actions in
877
+ * @param productVariants the current product variants, needed for the side menu renderer
878
+ * @param product the current product, needed for the side menu renderer and the is also passed with the event
879
+ * @param language the language to use, needed to translated the action
880
+ * @param openComponentFunction the function to open a component, called when an action with openComponent config is clicked
881
+ * @param onEventFunction the function to handle an event, called when an action with onEvent config is clicked, the current product is passed with the event
882
+ */
883
+ function replaceActions(content, productVariants, product, language, openComponentFunction, onEventFunction) {
884
+ if (typeof content == 'string') return content;
885
+ return recursiveReplaceActions(content, productVariants, product, language, openComponentFunction, onEventFunction);
886
+ }
887
+
888
+ /**
889
+ * Recursively replace the actions in the content with an onClick function
890
+ *
891
+ * @param content the content to replace the actions in
892
+ * @param productVariants the current product variants
893
+ * @param product the current product
894
+ * @param language the language to use
895
+ * @param openComponentFunction the function to open a component
896
+ * @param onEventFunction the function to handle an event
897
+ */
898
+ function recursiveReplaceActions(content, productVariants, product, language, openComponentFunction, onEventFunction) {
899
+ var keys = Object.keys(content);
900
+ var openComponent = undefined;
901
+ var onEvent = undefined;
902
+ for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
903
+ var key = _keys[_i];
904
+ if (key === 'openComponent') {
905
+ openComponent = content[key];
906
+ delete content[key];
907
+ } else if (key === 'onEvent') {
908
+ onEvent = content[key];
909
+ delete content[key];
910
+ } else if (_typeof(content[key]) === 'object') {
911
+ content[key] = recursiveReplaceActions(content[key], productVariants, product, language, openComponentFunction, onEventFunction);
912
+ }
913
+ }
914
+ if (openComponent || onEvent) {
915
+ content['onClick'] = function (_, productId) {
916
+ var _productVariants$find;
917
+ var currentProduct = (_productVariants$find = productVariants.find(function (variant) {
918
+ return variant._id === productId;
919
+ })) !== null && _productVariants$find !== void 0 ? _productVariants$find : product;
920
+ flatten$1(currentProduct);
921
+ if (openComponent) {
922
+ var translatedOpenComponent = replaceTemplatesInObject(openComponent, currentProduct, language);
923
+ openComponentFunction(translatedOpenComponent);
924
+ }
925
+ if (onEvent) {
926
+ onEventFunction({
927
+ type: onEvent,
928
+ data: currentProduct
929
+ });
930
+ }
931
+ };
932
+ }
933
+ return content;
934
+ }
935
+
936
+ export { Action, ActionGroup, Gallery, Text, TextBlock, replaceActions, replaceTemplatesInObject, useConfiguration, useCss, useProductData };