@cntrl-site/components 1.0.107-alpha.6 → 1.0.108-alpha.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.
@@ -1,1458 +0,0 @@
1
- import { jsxs as At, Fragment as Ie, jsx as u } from "react/jsx-runtime";
2
- import { s as se } from "./scalingValue-C9JH5L6O.mjs";
3
- import { u as hn } from "./useScopedStyles-DhBG3557.mjs";
4
- import { u as gn } from "./useLazyVideos-CxXyEjRQ.mjs";
5
- import { i as zt, E as Ze, g as pn } from "./EmbedMediaFrame-DwHeOAy5.mjs";
6
- import { L as mn } from "./LazyVideo-CdAWymKO.mjs";
7
- import { useRef as w, useState as $, useMemo as xe, useCallback as m, useEffect as B, useLayoutEffect as le } from "react";
8
- import { createPortal as wn } from "react-dom";
9
- import { H as vn } from "./HiveLightboxTitles-DhEeFKWs.mjs";
10
- import { g as yn } from "./getImageRect-CBMhFNHM.mjs";
11
- function $n(t) {
12
- return `calc(var(--cntrl-article-width, 100vw) * ${t / 1440})`;
13
- }
14
- function xn(t) {
15
- return `
16
- .${t}-wrapper {
17
- display: grid;
18
- align-items: start;
19
- justify-content: center;
20
- min-height: ${$n(48)};
21
- }
22
- .${t}-item {
23
- display: flex;
24
- flex-direction: column;
25
- justify-content: center;
26
- align-items: center;
27
- }
28
- .${t}-item-inner {
29
- display: flex;
30
- flex-direction: column;
31
- align-items: center;
32
- outline: 1px solid #FF5C02;
33
- }
34
- .${t}-item-inner-hidden {
35
- display: flex;
36
- flex-direction: column;
37
- align-items: center;
38
- }
39
- .${t}-item-image-wrapper {
40
- display: flex;
41
- justify-content: center;
42
- align-items: center;
43
- align-self: center;
44
- }
45
- .${t}-item-image-link {
46
- width: 100%;
47
- display: flex;
48
- flex-direction: column;
49
- align-items: center;
50
- }
51
- .${t}-item-image {
52
- width: 100%;
53
- height: 100%;
54
- display: block;
55
- max-width: 100%;
56
- }
57
- .${t}-item-video {
58
- width: 100%;
59
- height: 100%;
60
- display: block;
61
- max-width: 100%;
62
- }
63
- .${t}-image-align-top .${t}-item-image-wrapper {
64
- align-items: flex-start;
65
- }
66
- .${t}-image-align-center .${t}-item-image-wrapper {
67
- align-items: center;
68
- }
69
- .${t}-image-align-bottom .${t}-item-image-wrapper {
70
- align-items: flex-end;
71
- }
72
- .${t}-align-entries .${t}-item {
73
- display: contents;
74
- }
75
- .${t}-align-entries .${t}-item-inner,
76
- .${t}-align-entries .${t}-item-inner-hidden {
77
- display: grid;
78
- grid-template-rows: subgrid;
79
- grid-row: span 3;
80
- justify-self: center;
81
- margin-bottom: var(--${t}-align-entries-row-gap, 0);
82
- }
83
- .${t}-align-entries .${t}-item-inner-last-row {
84
- margin-bottom: 0;
85
- }
86
- .${t}-align-entries .${t}-item-title-row,
87
- .${t}-align-entries .${t}-item-subtitle-row {
88
- display: flex;
89
- flex-direction: column;
90
- align-items: center;
91
- width: 100%;
92
- min-height: 100%;
93
- }
94
- .${t}-align-entries .${t}-item-image-link {
95
- width: 100%;
96
- height: 100%;
97
- min-height: 100%;
98
- display: flex;
99
- flex-direction: column;
100
- align-items: center;
101
- justify-content: flex-start;
102
- }
103
- .${t}-align-entries .${t}-item-image-link > .${t}-item-image-wrapper {
104
- flex-shrink: 0;
105
- height: auto;
106
- align-self: auto;
107
- }
108
- .${t}-image-align-top.${t}-align-entries .${t}-item-image-link > .${t}-item-image-wrapper {
109
- margin-top: 0;
110
- margin-bottom: auto;
111
- }
112
- .${t}-image-align-center.${t}-align-entries .${t}-item-image-link > .${t}-item-image-wrapper {
113
- margin-top: auto;
114
- margin-bottom: auto;
115
- }
116
- .${t}-image-align-bottom.${t}-align-entries .${t}-item-image-link > .${t}-item-image-wrapper {
117
- margin-top: auto;
118
- margin-bottom: 0;
119
- }
120
- .${t}-image-align-top.${t}-align-entries .${t}-item-image-wrapper {
121
- align-items: flex-start;
122
- }
123
- .${t}-image-align-center.${t}-align-entries .${t}-item-image-wrapper {
124
- align-items: center;
125
- }
126
- .${t}-image-align-bottom.${t}-align-entries .${t}-item-image-wrapper {
127
- align-items: flex-end;
128
- }
129
- .${t}-image-align-top.${t}-align-entries .${t}-item-image-link {
130
- justify-content: flex-start;
131
- }
132
- .${t}-image-align-center.${t}-align-entries .${t}-item-image-link {
133
- justify-content: center;
134
- }
135
- .${t}-image-align-bottom.${t}-align-entries .${t}-item-image-link {
136
- justify-content: flex-end;
137
- }
138
- .${t}-titles-row {
139
- position: relative;
140
- flex: 0 1 auto;
141
- z-index: 2;
142
- box-sizing: border-box;
143
- pointer-events: none;
144
- word-break: break-word;
145
- min-width: 0;
146
- display: flex;
147
- flex-direction: row;
148
- align-items: baseline;
149
- }
150
- .${t}-titles-row-header {
151
- flex: 1;
152
- align-items: baseline;
153
- }
154
- .${t}-titles-row-header-controls {
155
- display: flex;
156
- flex-direction: row;
157
- align-items: baseline;
158
- flex-shrink: 0;
159
- }
160
- .${t}-close-icon {
161
- position: relative;
162
- flex-shrink: 0;
163
- align-self: center;
164
- pointer-events: auto;
165
- z-index: 2;
166
- display: flex;
167
- align-items: center;
168
- justify-content: center;
169
- border: none;
170
- background-color: transparent;
171
- padding: 0;
172
- }
173
- .${t}-close-icon-inner {
174
- all: unset;
175
- position: relative;
176
- cursor: pointer;
177
- width: 100%;
178
- height: 100%;
179
- pointer-events: auto;
180
- }
181
- .${t}-close-icon-img {
182
- position: absolute;
183
- top: 50%;
184
- left: 50%;
185
- transform: translate(-50%, -50%);
186
- }
187
- .${t}-titles-baseline-strut {
188
- width: 0;
189
- overflow: hidden;
190
- flex-shrink: 0;
191
- pointer-events: none;
192
- white-space: nowrap;
193
- }
194
- .${t}-titles-row-titles {
195
- position: relative;
196
- flex: 1;
197
- min-width: 0;
198
- align-self: flex-start;
199
- }
200
- .${t}-titles-stack {
201
- position: relative;
202
- display: flex;
203
- flex-direction: row;
204
- align-items: baseline;
205
- align-self: flex-start;
206
- min-width: 0;
207
- }
208
- .${t}-titles-row-two-row {
209
- display: flex;
210
- flex: 1;
211
- height: 100%;
212
- min-height: 0;
213
- align-self: stretch;
214
- flex-direction: column;
215
- width: 100%;
216
- }
217
- .${t}-titles-row-top {
218
- display: flex;
219
- flex-direction: row;
220
- align-items: baseline;
221
- width: 100%;
222
- flex-shrink: 0;
223
- margin-bottom: 0;
224
- }
225
- .${t}-titles-row-top .${t}-title-cell[data-title="title1"] {
226
- flex: 0 0 auto;
227
- min-width: 0;
228
- }
229
- .${t}-titles-row-bottom-wrap {
230
- display: flex;
231
- flex-direction: column;
232
- width: 100%;
233
- margin-top: auto;
234
- flex-shrink: 0;
235
- }
236
- .${t}-titles-row-bottom-area {
237
- position: relative;
238
- flex: 1;
239
- min-height: 0;
240
- display: flex;
241
- flex-direction: column;
242
- width: 100%;
243
- }
244
- .${t}-titles-row-bottom {
245
- position: relative;
246
- display: flex;
247
- flex-direction: row;
248
- align-items: flex-end;
249
- width: 100%;
250
- }
251
- .${t}-titles-row-bottom .${t}-title-cell {
252
- flex: 0 0 auto;
253
- }
254
- .${t}-title-cell {
255
- position: relative;
256
- flex: 0 0 auto;
257
- min-width: 0;
258
- box-sizing: border-box;
259
- }
260
- .${t}-text-bar-cell {
261
- position: relative;
262
- flex: 0 1 auto;
263
- min-width: 0;
264
- display: flex;
265
- align-items: baseline;
266
- }
267
- .${t}-title1,
268
- .${t}-title2,
269
- .${t}-title3 {
270
- margin: 0;
271
- min-width: 0;
272
- }
273
- .${t}-title-resize-handle {
274
- background: transparent;
275
- }
276
- .${t}-lightbox {
277
- position: fixed;
278
- inset: 0;
279
- z-index: 9997;
280
- overscroll-behavior: none;
281
- overflow: hidden;
282
- }
283
- .${t}-lightbox-editor {
284
- inset: auto;
285
- top: var(--cntrl-article-top, 0);
286
- left: var(--cntrl-article-left, 0);
287
- width: var(--cntrl-article-width, 100vw) !important;
288
- height: var(--cntrl-viewport-height, 100vh) !important;
289
- }
290
- .${t}-lightbox-edit-mode {
291
- z-index: 1;
292
- }
293
- .${t}-lightbox-dismiss-area {
294
- position: relative;
295
- width: 100%;
296
- height: 100%;
297
- }
298
- .${t}-lightbox-overlay-content {
299
- position: absolute;
300
- inset: 0;
301
- z-index: 3;
302
- pointer-events: none;
303
- display: flex;
304
- flex-direction: column;
305
- isolation: isolate;
306
- }
307
- .${t}-lightbox-content-area {
308
- position: relative;
309
- display: flex;
310
- flex-direction: row;
311
- align-items: flex-start;
312
- flex: 1;
313
- min-width: 0;
314
- min-height: 0;
315
- }
316
- .${t}-lightbox-content-area-stacked {
317
- align-items: stretch;
318
- align-self: stretch;
319
- }
320
- .${t}-text-bar-cell-stacked {
321
- align-self: stretch;
322
- flex: 1;
323
- min-width: 0;
324
- min-height: 0;
325
- height: 100%;
326
- flex-direction: column;
327
- align-items: stretch;
328
- }
329
- .${t}-control {
330
- position: relative;
331
- z-index: 2;
332
- pointer-events: auto;
333
- flex-shrink: 0;
334
- }
335
- `;
336
- }
337
- const Ye = { assetId: "", name: "", objectFit: "cover" }, it = 500, Zt = 650, V = "cubic-bezier(0.22, 1, 0.36, 1)", bn = 72, In = 50, Sn = 1e4, Ln = 650, kn = 500;
338
- function An(t, e) {
339
- const i = t.width / e.width, r = t.height / e.height, o = t.left - e.left, l = t.top - e.top;
340
- return `translate(${o}px, ${l}px) scale(${i}, ${r})`;
341
- }
342
- function Ke(t, e) {
343
- if (e === "contain" && t instanceof HTMLImageElement) {
344
- const r = yn(t);
345
- return { left: r.x, top: r.y, width: r.width, height: r.height };
346
- }
347
- const i = t.getBoundingClientRect();
348
- return { left: i.left, top: i.top, width: i.width, height: i.height };
349
- }
350
- function Rn(t, e, i) {
351
- const r = t.querySelector(`[data-hive-grid-index="${e}"]`);
352
- return r instanceof HTMLElement ? Ke(r, i) : null;
353
- }
354
- function Tn(t) {
355
- return t.reduce((e, i, r) => {
356
- const o = Le(i.gallery), g = ke(o).filter((a) => a.lightboxMedia).map((a) => a.lightboxMedia);
357
- return g.length === 0 || e.push({
358
- gridIndex: r,
359
- items: g,
360
- entry: {
361
- title1: i.title1 ?? "",
362
- title2: i.title2 ?? "",
363
- title3: i.title3 ?? ""
364
- }
365
- }), e;
366
- }, []);
367
- }
368
- function Kt(t, e, i) {
369
- var o;
370
- if (t.length <= 1) return null;
371
- const r = (e + i + t.length) % t.length;
372
- return ((o = t[r]) == null ? void 0 : o.items[0]) ?? null;
373
- }
374
- function qe(t, e, i) {
375
- if (t.length <= 2) return null;
376
- const r = (e + i + t.length) % t.length;
377
- return Kt(t, r, i);
378
- }
379
- const Hn = 0.03;
380
- function Je(t) {
381
- return t.width * Hn;
382
- }
383
- const be = {
384
- left: 0,
385
- top: 0,
386
- width: typeof window < "u" ? window.innerWidth : 1440,
387
- height: typeof window < "u" ? window.innerHeight : 900
388
- };
389
- function ae(t, e) {
390
- return {
391
- left: t.left - e.left,
392
- top: t.top - e.top,
393
- width: t.width,
394
- height: t.height
395
- };
396
- }
397
- function Ue(t) {
398
- const e = t.getBoundingClientRect();
399
- return { width: e.width, height: e.height, left: e.left, top: e.top };
400
- }
401
- function En(t) {
402
- return t instanceof HTMLVideoElement ? { width: t.videoWidth, height: t.videoHeight } : { width: t.naturalWidth, height: t.naturalHeight };
403
- }
404
- function Se(t, e, i) {
405
- const r = t.getBoundingClientRect(), o = r.width, l = r.height, g = e / i, a = o / l;
406
- if (g > a) {
407
- const S = o / g;
408
- return { width: o, height: S, left: r.left, top: r.top + (l - S) / 2 };
409
- }
410
- const W = l * g;
411
- return { width: W, height: l, left: r.left + (o - W) / 2, top: r.top };
412
- }
413
- function Fn(t, e) {
414
- return !t || !(e != null && e.width) || !(e != null && e.height) ? null : Se(t, e.width, e.height);
415
- }
416
- function Cn(t, e) {
417
- if (zt(t)) {
418
- e(t.assetId, pn(t), 1);
419
- return;
420
- }
421
- if (Dt(t)) {
422
- const r = document.createElement("video"), o = () => {
423
- r.videoWidth > 0 && r.videoHeight > 0 && e(t.assetId, r.videoWidth, r.videoHeight), r.removeEventListener("loadedmetadata", o);
424
- };
425
- r.addEventListener("loadedmetadata", o), r.preload = "auto", r.src = t.assetId, r.load();
426
- return;
427
- }
428
- const i = new Image();
429
- i.onload = () => {
430
- i.naturalWidth > 0 && i.naturalHeight > 0 && e(t.assetId, i.naturalWidth, i.naturalHeight);
431
- }, i.src = t.assetId;
432
- }
433
- function Nn(t) {
434
- const e = /* @__PURE__ */ new Set(), i = [];
435
- for (const r of t) {
436
- const o = Le(r.gallery), l = ke(o);
437
- for (const g of l)
438
- for (const a of [g.displayMedia, g.lightboxMedia])
439
- a != null && a.assetId && !e.has(a.assetId) && (e.add(a.assetId), i.push(a));
440
- }
441
- return i;
442
- }
443
- function Wn({ mediaList: t }) {
444
- const [e, i] = $(null);
445
- gn(e, { preload: "metadata" });
446
- const r = t.filter((o) => !zt(o));
447
- return r.length === 0 ? null : /* @__PURE__ */ u(
448
- "div",
449
- {
450
- ref: i,
451
- "aria-hidden": !0,
452
- style: {
453
- position: "absolute",
454
- width: 0,
455
- height: 0,
456
- overflow: "hidden",
457
- opacity: 0,
458
- pointerEvents: "none"
459
- },
460
- children: r.map((o) => Dt(o) ? /* @__PURE__ */ u(
461
- "video",
462
- {
463
- src: o.assetId,
464
- preload: "none",
465
- muted: !0,
466
- playsInline: !0
467
- },
468
- o.assetId
469
- ) : /* @__PURE__ */ u(
470
- "img",
471
- {
472
- src: o.assetId,
473
- alt: ""
474
- },
475
- o.assetId
476
- ))
477
- }
478
- );
479
- }
480
- function Ot(t, e, i) {
481
- const { width: r, height: o, top: l } = t, { left: g, width: a } = i, W = Je(i);
482
- return e === "left" ? {
483
- left: g + W - r,
484
- top: l,
485
- width: r,
486
- height: o
487
- } : {
488
- left: g + a - W,
489
- top: l,
490
- width: r,
491
- height: o
492
- };
493
- }
494
- function ue(t, e, i) {
495
- const r = Ot(t, e, i);
496
- return {
497
- ...r,
498
- left: 2 * r.left - t.left
499
- };
500
- }
501
- function jn(t, e, i) {
502
- const { left: r, width: o } = i, l = Je(i);
503
- return e === "left" ? {
504
- left: r,
505
- top: t.top,
506
- width: l,
507
- height: t.height
508
- } : {
509
- left: r + o - l,
510
- top: t.top,
511
- width: l,
512
- height: t.height
513
- };
514
- }
515
- function Qe(t, e, i, r) {
516
- const o = Ot(t, "left", r), l = Ot(t, "right", r), g = ue(t, "left", r), a = ue(t, "right", r);
517
- if (i === 1)
518
- switch (e) {
519
- case "center":
520
- return { start: t, end: o };
521
- case "right-adjacent":
522
- return { start: l, end: t };
523
- case "left-adjacent":
524
- return { start: o, end: g };
525
- case "far-right":
526
- return { start: a, end: l };
527
- default:
528
- return { start: t, end: t };
529
- }
530
- switch (e) {
531
- case "center":
532
- return { start: t, end: l };
533
- case "left-adjacent":
534
- return { start: o, end: t };
535
- case "right-adjacent":
536
- return { start: l, end: a };
537
- case "far-left":
538
- return { start: g, end: o };
539
- default:
540
- return { start: t, end: t };
541
- }
542
- }
543
- function On(t, e, i, r) {
544
- const { start: o, end: l } = Qe(t, e, i, r);
545
- return {
546
- x: l.left - o.left,
547
- y: l.top - o.top
548
- };
549
- }
550
- function zn(t, e, i) {
551
- const r = Ot(t, e, i), o = ue(t, e, i);
552
- return {
553
- x: o.left - r.left,
554
- y: o.top - r.top
555
- };
556
- }
557
- function Pe(t) {
558
- if (!Array.isArray(t) || t.length === 0) return !1;
559
- const e = t[0];
560
- return e !== null && typeof e == "object" && "media" in e && Array.isArray(e.media);
561
- }
562
- function Le(t) {
563
- if (!t) return;
564
- if (Pe(t)) return t;
565
- if (!Array.isArray(t)) return;
566
- const [e, i] = t, r = e != null && e.assetId ? e : void 0, o = i != null && i.assetId ? i : void 0;
567
- if (!(!r && !o))
568
- return [{
569
- media: [
570
- o ?? r ?? Ye,
571
- r ?? o ?? Ye
572
- ]
573
- }];
574
- }
575
- function Dn(t) {
576
- const [e, i] = t.media;
577
- return i != null && i.assetId ? i : e != null && e.assetId ? e : null;
578
- }
579
- function Mn(t) {
580
- const [e] = t.media;
581
- return e != null && e.assetId ? e : null;
582
- }
583
- function ke(t) {
584
- if (!Array.isArray(t) || t.length === 0) return [];
585
- if (Pe(t)) {
586
- const e = [];
587
- for (const i of t) {
588
- const r = Dn(i);
589
- if (!r) continue;
590
- const o = Mn(i);
591
- e.push({
592
- displayMedia: r,
593
- lightboxMedia: o != null && o.assetId ? o : null
594
- });
595
- }
596
- return e;
597
- }
598
- return t.filter((e) => e == null ? void 0 : e.assetId).map((e) => ({
599
- displayMedia: e,
600
- lightboxMedia: e
601
- }));
602
- }
603
- function Dt(t) {
604
- return zt(t) ? !1 : t.type === "video" ? !0 : /\.(mp4|webm|ogg|mov)(\?|#|$)/i.test(t.assetId);
605
- }
606
- function _n({
607
- media: t,
608
- className: e,
609
- style: i,
610
- gridIndex: r,
611
- onMediaClick: o
612
- }) {
613
- return zt(t) ? /* @__PURE__ */ u(
614
- Ze,
615
- {
616
- media: t,
617
- fit: i.objectFit === "contain" ? "contain" : "cover",
618
- silentLoop: !0,
619
- className: e,
620
- "data-hive-grid-index": r,
621
- style: {
622
- ...i,
623
- cursor: o ? "pointer" : "default"
624
- },
625
- onClick: o
626
- }
627
- ) : Dt(t) ? /* @__PURE__ */ u(
628
- mn,
629
- {
630
- src: t.assetId,
631
- className: e,
632
- "data-hive-grid-index": r,
633
- style: {
634
- ...i,
635
- cursor: o ? "pointer" : "default"
636
- },
637
- muted: !0,
638
- autoPlay: !0,
639
- loop: !0,
640
- playsInline: !0,
641
- onClick: o
642
- }
643
- ) : /* @__PURE__ */ u(
644
- "img",
645
- {
646
- src: t.assetId,
647
- alt: t.name,
648
- className: e,
649
- "data-hive-grid-index": r,
650
- style: {
651
- ...i,
652
- cursor: o ? "pointer" : "default"
653
- },
654
- onClick: o
655
- }
656
- );
657
- }
658
- function Vn({
659
- src: t,
660
- onMediaElement: e,
661
- wrapperStyle: i,
662
- videoStyle: r,
663
- onLoadedMetadata: o,
664
- onTransitionEnd: l
665
- }) {
666
- const g = w(null);
667
- return B(() => {
668
- const a = g.current;
669
- return e == null || e(a ?? null), () => {
670
- a == null || a.pause(), e == null || e(null);
671
- };
672
- }, [t, e]), /* @__PURE__ */ u("div", { style: i, onTransitionEnd: l, children: /* @__PURE__ */ u(
673
- "video",
674
- {
675
- ref: g,
676
- src: t,
677
- muted: !0,
678
- autoPlay: !0,
679
- loop: !0,
680
- playsInline: !0,
681
- preload: "auto",
682
- onLoadedMetadata: o,
683
- style: r
684
- },
685
- t
686
- ) });
687
- }
688
- function ce({
689
- media: t,
690
- style: e,
691
- onTransitionEnd: i,
692
- onMeasure: r
693
- }) {
694
- return zt(t) ? /* @__PURE__ */ u("img", { src: t.thumbnail, alt: t.name, style: e, onTransitionEnd: i }) : Dt(t) ? /* @__PURE__ */ u(
695
- "video",
696
- {
697
- src: t.assetId,
698
- muted: !0,
699
- autoPlay: !0,
700
- loop: !0,
701
- playsInline: !0,
702
- preload: "auto",
703
- style: e,
704
- onLoadedMetadata: (o) => {
705
- const l = o.currentTarget;
706
- l.videoWidth > 0 && l.videoHeight > 0 && (r == null || r(t.assetId, l.videoWidth, l.videoHeight));
707
- },
708
- onTransitionEnd: i
709
- }
710
- ) : /* @__PURE__ */ u(
711
- "img",
712
- {
713
- src: t.assetId,
714
- alt: t.name,
715
- style: e,
716
- onLoad: (o) => {
717
- const l = o.currentTarget;
718
- l.naturalWidth > 0 && l.naturalHeight > 0 && (r == null || r(t.assetId, l.naturalWidth, l.naturalHeight));
719
- },
720
- onTransitionEnd: i
721
- }
722
- );
723
- }
724
- function Bn({
725
- prefix: t,
726
- items: e,
727
- index: i,
728
- entry: r,
729
- settings: o,
730
- isEditor: l,
731
- isEditMode: g,
732
- isPreviewMode: a,
733
- canNavigate: W,
734
- lightboxEntries: S,
735
- entryIdx: rt,
736
- layoutId: G,
737
- sourceRect: j,
738
- resolveCloseSourceRect: Rt,
739
- onClose: Mt,
740
- onPrev: _t,
741
- onNext: Vt
742
- }) {
743
- const Jt = w(null), Tt = w(null), Ht = w(null), Et = w(/* @__PURE__ */ new Map()), [Y, Ft] = $(0), ot = w(null), xt = w(0), O = w(0), N = w("none"), q = w(!1), U = w(!1), st = w(!1), lt = w(null), L = w(null), Ct = w(null), dt = w(() => {
744
- }), Z = w(null), z = w(null), ft = w(null), at = w(!1), [A, bt] = $(null), [R, Qt] = $(be), [de, fe] = $(0), [h, ht] = $("opening"), [K, It] = $(0), [Bt, k] = $(0), [X, he] = $(!1), [J, gt] = $(null), [St, pt] = $(null), [x, v] = $(null), [mt, T] = $(!1), [wt, Gt] = $(null), [Xt, Q] = $(!1), Lt = w(!1), [D, C] = $(!1), [tn, Ae] = $(!1), Re = w(i), Te = w(void 0), d = e[i], He = d ? Dt(d) : !1, Ee = d ? zt(d) : !1, vt = Bt !== 0 || X, ge = !g && (!l || !!a), ct = W && !g, yt = S.length > 1, Nt = m((n, s) => e.length <= 1 ? null : e[(n + s + e.length) % e.length] ?? null, [e]), H = yt ? Kt(S, rt, -1) : Nt(i, -1), E = yt ? Kt(S, rt, 1) : Nt(i, 1), pe = J === -1 && vt ? yt && St !== null ? Kt(S, St, -1) : x !== null ? Nt(x, -1) : null : null, me = J === 1 && vt ? yt && St !== null ? Kt(S, St, 1) : x !== null ? Nt(x, 1) : null : null, en = pe && pe.assetId !== (H == null ? void 0 : H.assetId) ? pe : null, nn = me && me.assetId !== (E == null ? void 0 : E.assetId) ? me : null, rn = H && ct ? (() => {
745
- const n = yt ? qe(S, rt, -1) : e.length > 2 ? Nt((i - 1 + e.length) % e.length, -1) : null;
746
- return n && n.assetId !== H.assetId ? n : null;
747
- })() : null, on = E && ct ? (() => {
748
- const n = yt ? qe(S, rt, 1) : e.length > 2 ? Nt((i + 1) % e.length, 1) : null;
749
- return n && n.assetId !== E.assetId ? n : null;
750
- })() : null, Pt = en ?? rn, te = nn ?? on, $t = m((n, s, f) => {
751
- if (!n || !s || !f) return;
752
- const c = Et.current, y = c.get(n);
753
- (y == null ? void 0 : y.width) === s && (y == null ? void 0 : y.height) === f || (c.set(n, { width: s, height: f }), Ft((_) => _ + 1));
754
- }, []), Wt = m((n) => {
755
- if (!(n != null && n.assetId)) return null;
756
- const s = Et.current.get(n.assetId);
757
- return Fn(Tt.current, s);
758
- }, [Y, de]), ee = m(() => {
759
- if (!d) return;
760
- const n = Wt(d);
761
- if (n) {
762
- bt(n);
763
- return;
764
- }
765
- const s = Tt.current;
766
- s && bt(Ue(s));
767
- }, [d, Wt]), ne = m((n) => {
768
- if (yt) {
769
- const s = S.length;
770
- pt((rt + n + s) % s), v(null);
771
- return;
772
- }
773
- e.length > 1 && (v((i + n + e.length) % e.length), pt(null));
774
- }, [yt, S.length, rt, e.length, i]), F = m((n) => {
775
- st.current = n, he(n);
776
- }, []), b = m(() => {
777
- lt.current !== null && (window.clearTimeout(lt.current), lt.current = null);
778
- }, []), Fe = m(() => {
779
- b(), lt.current = window.setTimeout(() => {
780
- b(), F(!1);
781
- }, Zt + 32);
782
- }, [b, F]), Ce = m(() => {
783
- const n = Jt.current;
784
- if (!n) {
785
- Qt({
786
- left: 0,
787
- top: 0,
788
- width: typeof window < "u" ? window.innerWidth : be.width,
789
- height: typeof window < "u" ? window.innerHeight : be.height
790
- });
791
- return;
792
- }
793
- const s = n.getBoundingClientRect();
794
- Qt({
795
- left: s.left,
796
- top: s.top,
797
- width: s.width,
798
- height: s.height
799
- });
800
- }, []), Ne = m((n, s) => {
801
- if (vt) {
802
- if (D && !X)
803
- return `translate(${Bt}px, 0px)`;
804
- if (X && J !== null) {
805
- const f = Wt(n);
806
- if (!f) return;
807
- const { x: c, y } = On(f, s, J, R);
808
- return `translate(${c}px, ${y}px)`;
809
- }
810
- if (X)
811
- return "translate(0px, 0px)";
812
- }
813
- }, [
814
- vt,
815
- D,
816
- X,
817
- Bt,
818
- J,
819
- R,
820
- Wt
821
- ]), jt = m(() => {
822
- const n = L.current;
823
- L.current = null, b(), F(!1), gt(null), pt(null), v(null), k(0), C(!1), q.current = !1, O.current = 0, N.current = "none", n === -1 ? _t() : n === 1 && Vt();
824
- }, [b, F, _t, Vt]), ie = m(() => {
825
- b(), lt.current = window.setTimeout(() => {
826
- L.current !== null && jt();
827
- }, Zt + 32);
828
- }, [b, jt]), We = m(() => {
829
- b(), L.current = null, F(!1), gt(null), pt(null), v(null), k(0), C(!1), q.current = !1, O.current = 0, N.current = "none";
830
- }, [b, F]), je = m((n) => {
831
- if (!(!ct || !A)) {
832
- if (st.current) {
833
- if (L.current === n) {
834
- Ct.current = n, jt();
835
- return;
836
- }
837
- We();
838
- }
839
- b(), ne(n), L.current = n, gt(n), F(!0), ie();
840
- }
841
- }, [
842
- ct,
843
- A,
844
- jt,
845
- We,
846
- b,
847
- ne,
848
- F,
849
- ie
850
- ]);
851
- dt.current = je;
852
- const ut = m(() => {
853
- Z.current = null, at.current = !1, z.current !== null && (window.clearInterval(z.current), z.current = null), ft.current !== null && (window.clearTimeout(ft.current), ft.current = null);
854
- }, []), we = m((n) => {
855
- z.current !== null && window.clearInterval(z.current);
856
- const s = at.current ? kn : Ln;
857
- z.current = window.setInterval(() => {
858
- dt.current(n);
859
- }, s);
860
- }, []), Oe = m((n) => {
861
- Z.current !== n && (ut(), Z.current = n, at.current = !1, dt.current(n), we(n), ft.current = window.setTimeout(() => {
862
- ft.current = null, Z.current === n && (at.current = !0, we(n));
863
- }, Sn));
864
- }, [ut, we]), P = m(() => {
865
- const n = Tt.current;
866
- if (!n) return;
867
- const s = d == null ? void 0 : d.assetId, f = s ? Et.current.get(s) : void 0;
868
- if (f != null && f.width && (f != null && f.height)) {
869
- bt(Se(n, f.width, f.height));
870
- return;
871
- }
872
- const c = Ht.current;
873
- if (c && s && (c.src === s || c.currentSrc === s)) {
874
- const { width: _, height: p } = En(c);
875
- if (_ && p) {
876
- $t(s, _, p), bt(Se(n, _, p));
877
- return;
878
- }
879
- }
880
- const y = Ue(n);
881
- !y.width || !y.height || bt(y);
882
- }, [d == null ? void 0 : d.assetId, $t]), ze = m((n) => {
883
- if (Ht.current = n, !!n) {
884
- if (n instanceof HTMLVideoElement) {
885
- n.readyState >= 1 && n.videoWidth > 0 && P();
886
- return;
887
- }
888
- n.complete && n.naturalWidth > 0 && P();
889
- }
890
- }, [P]), Yt = m(() => {
891
- Ce(), P(), fe((n) => n + 1);
892
- }, [Ce, P]);
893
- B(() => {
894
- Yt();
895
- const n = Tt.current, s = Jt.current, f = new ResizeObserver(() => Yt());
896
- return n && f.observe(n), s && f.observe(s), window.addEventListener("resize", Yt), () => {
897
- f.disconnect(), window.removeEventListener("resize", Yt);
898
- };
899
- }, [Yt, i, G]), le(() => {
900
- if (!d) return;
901
- const n = Ht.current;
902
- if (n) {
903
- if (n instanceof HTMLImageElement && n.complete && n.naturalWidth > 0) {
904
- P();
905
- return;
906
- }
907
- n instanceof HTMLVideoElement && n.readyState >= 1 && n.videoWidth > 0 && P();
908
- }
909
- }, [d == null ? void 0 : d.assetId, i, P]), B(() => {
910
- ee();
911
- }, [ee, Y]), B(() => {
912
- const n = /* @__PURE__ */ new Set(), s = [], f = (c) => {
913
- !(c != null && c.assetId) || n.has(c.assetId) || (n.add(c.assetId), s.push(c));
914
- };
915
- e.forEach(f), S.forEach((c) => c.items.forEach(f)), s.forEach((c) => {
916
- Et.current.has(c.assetId) || Cn(c, $t);
917
- });
918
- }, [e, S, $t]), B(() => {
919
- if (h !== "opening" || !A) return;
920
- if (!j) {
921
- ht("open");
922
- return;
923
- }
924
- T(!1);
925
- const n = requestAnimationFrame(() => {
926
- requestAnimationFrame(() => {
927
- T(!0), ht("open");
928
- });
929
- });
930
- return () => cancelAnimationFrame(n);
931
- }, [h, A, j]), B(() => {
932
- if (h !== "closing") return;
933
- const n = setTimeout(() => Mt(), it);
934
- return () => clearTimeout(n);
935
- }, [h, Mt]), B(() => () => {
936
- b();
937
- }, [b]), le(() => {
938
- Re.current === i && Te.current === (d == null ? void 0 : d.assetId) || (b(), L.current = null, gt(null), pt(null), v(null), It(0), k(0), F(!1), Ae(!1), C(!1), xt.current = 0, O.current = 0, N.current = "none", q.current = !1, ot.current = null, U.current = !1, Ht.current = null, ee(), Re.current = i, Te.current = d == null ? void 0 : d.assetId);
939
- }, [i, d == null ? void 0 : d.assetId, F, b, ee]), le(() => {
940
- const n = Ct.current;
941
- n !== null && (Ct.current = null, requestAnimationFrame(() => {
942
- dt.current(n);
943
- }));
944
- }, [i, rt, d == null ? void 0 : d.assetId]), le(() => {
945
- if (h === "opening") {
946
- Lt.current = !1, Q(!1);
947
- return;
948
- }
949
- if (h !== "open" || Lt.current) return;
950
- if (!H && !E) {
951
- Lt.current = !0;
952
- return;
953
- }
954
- Q(!1);
955
- const n = requestAnimationFrame(() => {
956
- requestAnimationFrame(() => {
957
- Q(!0), Lt.current = !0;
958
- });
959
- });
960
- return () => cancelAnimationFrame(n);
961
- }, [h, H == null ? void 0 : H.assetId, E == null ? void 0 : E.assetId]), B(() => {
962
- if (h !== "open") return;
963
- const n = () => {
964
- const p = (I) => {
965
- I.stopPropagation(), I.preventDefault(), document.removeEventListener("click", p, !0);
966
- };
967
- document.addEventListener("click", p, !0);
968
- }, s = (p) => {
969
- const I = p < 0 ? 1 : -1;
970
- b(), ne(I), L.current = I, gt(I), F(!0), ie();
971
- }, f = (p) => {
972
- if (Math.abs(p) > In && ct) {
973
- s(p);
974
- return;
975
- }
976
- L.current = null, gt(null), pt(null), v(null), F(!0), k(0), Fe();
977
- }, c = (p) => {
978
- if (p.touches.length !== 1 || st.current) return;
979
- const I = p.touches[0];
980
- U.current = !0, ot.current = { x: I.clientX, y: I.clientY }, N.current = "none", O.current = 0, q.current = !1;
981
- }, y = (p) => {
982
- if (!ot.current || p.touches.length !== 1 || st.current) return;
983
- const I = p.touches[0], et = I.clientX - ot.current.x, nt = I.clientY - ot.current.y;
984
- if (N.current === "none") {
985
- if (Math.abs(et) < 10 && Math.abs(nt) < 10) return;
986
- if (Math.abs(et) > Math.abs(nt)) {
987
- if (!ct) return;
988
- N.current = "horizontal";
989
- } else if (nt > 0) {
990
- if (!ge) return;
991
- N.current = "vertical";
992
- } else
993
- return;
994
- }
995
- if (N.current === "horizontal") {
996
- q.current = !0, C(!0), O.current = et, k(et), p.preventDefault();
997
- return;
998
- }
999
- N.current === "vertical" && (q.current = !0, C(!0), xt.current = nt, It(nt), p.preventDefault());
1000
- }, _ = () => {
1001
- if (!ot.current) return;
1002
- const p = N.current, I = q.current;
1003
- if (I && p === "horizontal")
1004
- f(O.current), n();
1005
- else if (I && p === "vertical") {
1006
- const et = xt.current;
1007
- if (ge && et > bn) {
1008
- const nt = window.innerHeight;
1009
- xt.current = nt, Ae(!0), It(nt), ht("closing");
1010
- } else
1011
- xt.current = 0, It(0);
1012
- n();
1013
- } else p === "horizontal" && Math.abs(O.current) > 0 && (f(O.current), n());
1014
- ot.current = null, N.current = "none", O.current = 0, q.current = !1, C(!1);
1015
- };
1016
- return document.addEventListener("touchstart", c, { passive: !0 }), document.addEventListener("touchmove", y, { passive: !1 }), document.addEventListener("touchend", _), document.addEventListener("touchcancel", _), () => {
1017
- document.removeEventListener("touchstart", c), document.removeEventListener("touchmove", y), document.removeEventListener("touchend", _), document.removeEventListener("touchcancel", _);
1018
- };
1019
- }, [h, ct, F, Fe, b, ge, ie, ne]);
1020
- const ve = m(() => {
1021
- const n = (Rt == null ? void 0 : Rt()) ?? j ?? null;
1022
- n && A && (Gt(n), T(!0)), ht("closing");
1023
- }, [Rt, j, A]);
1024
- B(() => {
1025
- const n = (c) => {
1026
- if (c.key === "Escape") {
1027
- if (l && a || h === "closing") return;
1028
- ut(), ve();
1029
- return;
1030
- }
1031
- if (c.key !== "ArrowLeft" && c.key !== "ArrowRight" || h !== "open" || !ct) return;
1032
- c.preventDefault();
1033
- const y = c.key === "ArrowLeft" ? -1 : 1;
1034
- c.repeat && Z.current === y || Oe(y);
1035
- }, s = (c) => {
1036
- if (c.key !== "ArrowLeft" && c.key !== "ArrowRight") return;
1037
- const y = c.key === "ArrowLeft" ? -1 : 1;
1038
- Z.current === y && ut();
1039
- }, f = () => {
1040
- ut();
1041
- };
1042
- return window.addEventListener("keydown", n), window.addEventListener("keyup", s), window.addEventListener("blur", f), () => {
1043
- window.removeEventListener("keydown", n), window.removeEventListener("keyup", s), window.removeEventListener("blur", f), ut();
1044
- };
1045
- }, [
1046
- h,
1047
- l,
1048
- a,
1049
- ve,
1050
- ct,
1051
- Oe,
1052
- ut
1053
- ]), B(() => {
1054
- h !== "open" && ut();
1055
- }, [h, ut]);
1056
- const De = () => {
1057
- h === "closing" || g || ve();
1058
- }, tt = h === "open", re = h === "closing", sn = K > 0 ? Math.max(0, 1 - K / 500) : 1, ln = K > 0 ? Math.max(0.35, 1 - K / 500) : 1, kt = m((n) => {
1059
- if (!(n.propertyName !== "transform" || !st.current)) {
1060
- if (L.current !== null) {
1061
- jt();
1062
- return;
1063
- }
1064
- b(), F(!1);
1065
- }
1066
- }, [b, F, jt]), ye = h === "closing" ? wt ?? j : j, an = ye && A && (h === "opening" || re) ? An(ye, A) : void 0, cn = vt && d ? Ne(d, "center") : K > 0 ? `translateY(${K}px)` : an, M = A ? ae(A, R) : null, Me = !!(ye && A), un = Me && (h === "closing" || h === "open" && mt), $e = {
1067
- position: "absolute",
1068
- top: M == null ? void 0 : M.top,
1069
- left: M == null ? void 0 : M.left,
1070
- width: M == null ? void 0 : M.width,
1071
- height: M == null ? void 0 : M.height,
1072
- objectFit: "contain",
1073
- transformOrigin: "top left",
1074
- transform: cn,
1075
- opacity: K > 0 ? ln : Me ? 1 : h === "opening" || re ? 0 : 1,
1076
- transition: D && !X ? "none" : X ? `transform ${Zt}ms ${V}` : tn ? `transform ${it}ms ${V}, opacity ${it}ms ${V}` : un ? `transform ${it}ms ${V}` : h === "opening" || re ? `opacity ${it}ms ${V}` : "none",
1077
- pointerEvents: "none",
1078
- zIndex: 1,
1079
- overflow: He || Ee ? "hidden" : void 0
1080
- }, _e = {
1081
- width: "100%",
1082
- height: "100%",
1083
- display: "block",
1084
- objectFit: "contain",
1085
- pointerEvents: "none"
1086
- }, oe = (n, s, f = "adjacent") => {
1087
- const c = Wt(n);
1088
- if (!c) return { display: "none" };
1089
- const y = f === "far" ? s === "left" ? "far-left" : "far-right" : s === "left" ? "left-adjacent" : "right-adjacent", { start: _ } = J !== null ? Qe(c, y, J, R) : {
1090
- start: f === "far" ? ue(c, s, R) : Ot(c, s, R)
1091
- }, p = ae(_, R), I = Ne(n, y), et = !vt && f === "adjacent" && tt && !Xt ? zn(c, s, R) : null, nt = f === "far" && vt && J === (s === "left" ? -1 : 1), dn = D && !X ? !1 : X, fn = f === "adjacent" && tt && Xt && !vt;
1092
- return {
1093
- position: "absolute",
1094
- top: p.top,
1095
- left: p.left,
1096
- width: p.width,
1097
- height: p.height,
1098
- objectFit: "contain",
1099
- transform: I ?? (et ? `translate(${et.x}px, ${et.y}px)` : void 0),
1100
- opacity: f === "far" ? tt && nt ? 1 : 0 : tt ? 1 : 0,
1101
- transition: dn ? f === "far" ? `transform ${Zt}ms ${V}` : `transform ${Zt}ms ${V}, opacity ${it}ms ${V}` : fn ? `transform ${it}ms ${V}` : h === "opening" || re ? `opacity ${it}ms ${V}` : "none",
1102
- pointerEvents: "none",
1103
- zIndex: 1
1104
- };
1105
- }, Ve = (n, s) => {
1106
- const f = Wt(n);
1107
- return f ? jn(Ot(f, s, R), s, R) : null;
1108
- }, Be = (n) => (s) => {
1109
- if (!g) {
1110
- if (U.current) {
1111
- U.current = !1;
1112
- return;
1113
- }
1114
- s.stopPropagation(), je(n);
1115
- }
1116
- }, Ge = H ? Ve(H, "left") : null, Xe = E ? Ve(E, "right") : null, qt = Ge ? ae(Ge, R) : null, Ut = Xe ? ae(Xe, R) : null;
1117
- return /* @__PURE__ */ At(
1118
- "div",
1119
- {
1120
- ref: Jt,
1121
- className: [
1122
- `${t}-lightbox`,
1123
- l ? `${t}-lightbox-editor` : "",
1124
- g ? `${t}-lightbox-edit-mode` : ""
1125
- ].filter(Boolean).join(" "),
1126
- style: {
1127
- touchAction: h === "open" ? "none" : void 0
1128
- },
1129
- onClick: De,
1130
- children: [
1131
- /* @__PURE__ */ u(
1132
- "div",
1133
- {
1134
- style: {
1135
- position: "absolute",
1136
- inset: 0,
1137
- background: o.backgroundColor ?? "#FFFFFF",
1138
- opacity: tt ? sn : 0,
1139
- transition: D ? "none" : `opacity ${it}ms ${V}`,
1140
- pointerEvents: "none"
1141
- }
1142
- }
1143
- ),
1144
- /* @__PURE__ */ At("div", { className: `${t}-lightbox-dismiss-area`, children: [
1145
- /* @__PURE__ */ At(
1146
- "div",
1147
- {
1148
- style: {
1149
- position: "relative",
1150
- width: "100%",
1151
- height: "100%",
1152
- display: "flex",
1153
- flexDirection: "column",
1154
- alignItems: "center",
1155
- justifyContent: "center"
1156
- },
1157
- children: [
1158
- /* @__PURE__ */ u("div", { style: { height: "10%" } }),
1159
- /* @__PURE__ */ u(
1160
- "div",
1161
- {
1162
- style: {
1163
- width: "70%",
1164
- height: "80%",
1165
- display: "flex",
1166
- justifyContent: "center",
1167
- alignItems: "center"
1168
- },
1169
- children: /* @__PURE__ */ u("div", { ref: Tt, style: { width: "100%", height: "100%" } })
1170
- }
1171
- ),
1172
- /* @__PURE__ */ u("div", { style: { height: "10%" } })
1173
- ]
1174
- }
1175
- ),
1176
- /* @__PURE__ */ u(
1177
- "div",
1178
- {
1179
- style: {
1180
- position: "absolute",
1181
- inset: 0,
1182
- opacity: tt ? 1 : 0,
1183
- transition: D ? "none" : `opacity ${it}ms ${V}`,
1184
- pointerEvents: "none"
1185
- },
1186
- children: /* @__PURE__ */ u(
1187
- vn,
1188
- {
1189
- prefix: t,
1190
- entry: r,
1191
- settings: o,
1192
- isEditor: l,
1193
- isEditMode: g,
1194
- isPreviewMode: a,
1195
- onClose: De
1196
- }
1197
- )
1198
- }
1199
- )
1200
- ] }),
1201
- tt && Pt && /* @__PURE__ */ u(
1202
- ce,
1203
- {
1204
- media: Pt,
1205
- style: oe(Pt, "left", "far"),
1206
- onMeasure: $t,
1207
- onTransitionEnd: kt
1208
- },
1209
- `far-prev-${Pt.assetId}`
1210
- ),
1211
- tt && H && /* @__PURE__ */ At(Ie, { children: [
1212
- /* @__PURE__ */ u(
1213
- ce,
1214
- {
1215
- media: H,
1216
- style: oe(H, "left"),
1217
- onMeasure: $t,
1218
- onTransitionEnd: kt
1219
- },
1220
- `prev-${H.assetId}`
1221
- ),
1222
- qt && /* @__PURE__ */ u(
1223
- "div",
1224
- {
1225
- style: {
1226
- position: "absolute",
1227
- top: qt.top,
1228
- left: qt.left,
1229
- width: qt.width,
1230
- height: qt.height,
1231
- cursor: g || D ? "default" : "pointer",
1232
- pointerEvents: g || D ? "none" : "auto",
1233
- zIndex: 3
1234
- },
1235
- onClick: Be(-1)
1236
- }
1237
- )
1238
- ] }),
1239
- tt && E && /* @__PURE__ */ At(Ie, { children: [
1240
- /* @__PURE__ */ u(
1241
- ce,
1242
- {
1243
- media: E,
1244
- style: oe(E, "right"),
1245
- onMeasure: $t,
1246
- onTransitionEnd: kt
1247
- },
1248
- `next-${E.assetId}`
1249
- ),
1250
- Ut && /* @__PURE__ */ u(
1251
- "div",
1252
- {
1253
- style: {
1254
- position: "absolute",
1255
- top: Ut.top,
1256
- left: Ut.left,
1257
- width: Ut.width,
1258
- height: Ut.height,
1259
- cursor: g || D ? "default" : "pointer",
1260
- pointerEvents: g || D ? "none" : "auto",
1261
- zIndex: 3
1262
- },
1263
- onClick: Be(1)
1264
- }
1265
- )
1266
- ] }),
1267
- tt && te && /* @__PURE__ */ u(
1268
- ce,
1269
- {
1270
- media: te,
1271
- style: oe(te, "right", "far"),
1272
- onMeasure: $t,
1273
- onTransitionEnd: kt
1274
- },
1275
- `far-next-${te.assetId}`
1276
- ),
1277
- A && d && (Ee ? /* @__PURE__ */ u("div", { style: $e, onTransitionEnd: kt, children: /* @__PURE__ */ u(
1278
- Ze,
1279
- {
1280
- media: d,
1281
- fit: "contain",
1282
- lazy: !1,
1283
- startsAtOnce: !0,
1284
- style: _e
1285
- }
1286
- ) }, `${i}-${d.assetId}`) : He ? /* @__PURE__ */ u(
1287
- Vn,
1288
- {
1289
- src: d.assetId,
1290
- onMediaElement: ze,
1291
- wrapperStyle: $e,
1292
- videoStyle: _e,
1293
- onLoadedMetadata: P,
1294
- onTransitionEnd: kt
1295
- },
1296
- `${i}-${d.assetId}`
1297
- ) : /* @__PURE__ */ u(
1298
- "img",
1299
- {
1300
- ref: ze,
1301
- src: d.assetId,
1302
- alt: d.name,
1303
- onLoad: P,
1304
- onTransitionEnd: kt,
1305
- style: $e
1306
- },
1307
- `${i}-${d.assetId}`
1308
- ))
1309
- ]
1310
- }
1311
- );
1312
- }
1313
- function ti({
1314
- settings: t,
1315
- content: e,
1316
- isEditor: i,
1317
- isPreviewMode: r,
1318
- isEditMode: o,
1319
- layoutId: l,
1320
- portalId: g
1321
- }) {
1322
- const { prefix: a } = hn(), { gridLayout: W, verticalGap: S, align: rt = "top", imageDisplay: G } = t, j = (G == null ? void 0 : G.display) === "cover", Rt = (G == null ? void 0 : G.ratioValue) ?? "1:1", Mt = (G == null ? void 0 : G.reversed) ?? !1, [_t, Vt] = Rt.split(":").map(Number), Ht = `${Mt ? Vt : _t} / ${Mt ? _t : Vt}`, Et = W.entryWidth ?? 0.2, Y = W.columnsCount, Ft = se(Et, i), ot = se(W.horizontalGap ?? 0, i), xt = Ft, O = Ft, N = {
1323
- width: xt,
1324
- ...j ? { aspectRatio: Ht, height: "auto", overflow: "hidden" } : { height: "auto" }
1325
- }, q = j ? {
1326
- objectFit: "cover",
1327
- pointerEvents: "auto",
1328
- width: "100%",
1329
- height: "100%",
1330
- maxWidth: "100%"
1331
- } : {
1332
- objectFit: "contain",
1333
- pointerEvents: "auto",
1334
- width: "auto",
1335
- height: "auto",
1336
- maxWidth: "100%"
1337
- }, U = w(null), [st, lt] = $(!1), [L, Ct] = $([]), [dt, Z] = $(0), [z, ft] = $(0), [at, A] = $(null), [bt, R] = $({
1338
- title1: "",
1339
- title2: "",
1340
- title3: ""
1341
- }), Qt = (() => {
1342
- const x = {}, v = U.current ? getComputedStyle(U.current).getPropertyValue("--cntrl-article-width").trim() : "";
1343
- return v && (x["--cntrl-article-width"] = v), x;
1344
- })(), de = !i || r || o, fe = xe(() => xn(a), [a]), h = e ?? [], ht = h.length % Y || Y, K = ht < Y && h.length > 0, It = h.length - ht, Bt = K ? Math.floor((Y - ht) / 2) + 1 : 1, k = xe(() => Tn(h), [h]), X = xe(() => Nn(h), [h]), he = (x, v, mt) => {
1345
- if (i && !o && !r) return;
1346
- const T = k.findIndex((Gt) => Gt.gridIndex === x);
1347
- if (T < 0) return;
1348
- const wt = k[T];
1349
- ft(T), Ct(wt.items), Z(v), R(wt.entry), A(mt ?? null), lt(!0);
1350
- }, J = m(() => {
1351
- lt(!1), A(null);
1352
- }, []), gt = m(() => {
1353
- const x = k[z];
1354
- return !x || !U.current ? at : Rn(
1355
- U.current,
1356
- x.gridIndex,
1357
- j ? "cover" : "contain"
1358
- ) ?? at;
1359
- }, [k, z, at, j]), St = m((x) => {
1360
- if (k.length > 1) {
1361
- const v = k.length, mt = (z + x + v) % v, T = k[mt], wt = Math.min(dt, T.items.length - 1);
1362
- ft(mt), Ct(T.items), Z(wt), R(T.entry);
1363
- return;
1364
- }
1365
- Z((v) => (v + x + L.length) % L.length);
1366
- }, [k, z, dt, L.length]), pt = k.length > 1 || L.length > 1;
1367
- return B(() => {
1368
- if (!st || typeof document > "u") return;
1369
- const x = document.body.style.overflow;
1370
- return document.body.style.overflow = "hidden", () => {
1371
- document.body.style.overflow = x;
1372
- };
1373
- }, [st]), B(() => {
1374
- !i || o || r || lt(!1);
1375
- }, [i, o, r]), /* @__PURE__ */ At(Ie, { children: [
1376
- /* @__PURE__ */ u("style", { dangerouslySetInnerHTML: { __html: fe } }),
1377
- /* @__PURE__ */ u(Wn, { mediaList: X }),
1378
- /* @__PURE__ */ u(
1379
- "div",
1380
- {
1381
- ref: U,
1382
- className: `${a}-wrapper ${a}-align-entries ${a}-image-align-${rt}`.trim(),
1383
- style: {
1384
- gridTemplateColumns: `repeat(${Y}, ${Ft})`,
1385
- rowGap: 0,
1386
- columnGap: ot,
1387
- width: se(W.wrapperWidth ?? 0, i),
1388
- [`--${a}-align-entries-row-gap`]: se(S ?? 0, i)
1389
- },
1390
- children: h.map((x, v) => {
1391
- const mt = Le(x.gallery), T = ke(mt), wt = T.filter((C) => C.lightboxMedia).map((C) => C.lightboxMedia), Gt = Math.floor(v / Y) === Math.ceil(h.length / Y) - 1, Xt = K && v >= It ? `${Bt + (v - It)}` : void 0, Q = T[0], Lt = Q != null && Q.lightboxMedia ? wt.findIndex((C) => C.assetId === Q.lightboxMedia.assetId) : -1, D = /* @__PURE__ */ u("div", { className: `${a}-item-image-wrapper`, style: N, children: T.length > 0 && /* @__PURE__ */ u(
1392
- _n,
1393
- {
1394
- media: Q.displayMedia,
1395
- gridIndex: v,
1396
- className: `${a}-item-${Dt(Q.displayMedia) ? "video" : "image"}`.trim(),
1397
- style: q,
1398
- onMediaClick: de && Lt >= 0 ? (C) => he(
1399
- v,
1400
- Lt,
1401
- Ke(C.currentTarget, j ? "cover" : "contain")
1402
- ) : void 0
1403
- }
1404
- ) });
1405
- return /* @__PURE__ */ u("div", { className: `${a}-item`, children: /* @__PURE__ */ At(
1406
- "div",
1407
- {
1408
- className: [
1409
- o ? `${a}-item-inner` : `${a}-item-inner-hidden`,
1410
- Gt ? `${a}-item-inner-last-row` : ""
1411
- ].filter(Boolean).join(" "),
1412
- style: {
1413
- width: Ft,
1414
- ...Xt ? { gridColumn: Xt } : {}
1415
- },
1416
- children: [
1417
- /* @__PURE__ */ u("div", { className: `${a}-item-title-row`, children: /* @__PURE__ */ u("div", { style: { height: 0, width: O } }) }),
1418
- /* @__PURE__ */ u("a", { className: `${a}-item-image-link`, children: D }),
1419
- /* @__PURE__ */ u("div", { className: `${a}-item-subtitle-row`, children: /* @__PURE__ */ u("div", { style: { height: 0, width: O } }) })
1420
- ]
1421
- }
1422
- ) }, v);
1423
- })
1424
- }
1425
- ),
1426
- st && typeof document < "u" && (() => {
1427
- const x = (g ? document.getElementById(g) : null) ?? document.body;
1428
- return wn(
1429
- /* @__PURE__ */ u("div", { style: Qt, "data-selection": "none", children: /* @__PURE__ */ u(
1430
- Bn,
1431
- {
1432
- prefix: a,
1433
- items: L,
1434
- index: dt,
1435
- entry: bt,
1436
- settings: t,
1437
- isEditor: i,
1438
- isEditMode: o,
1439
- isPreviewMode: r,
1440
- canNavigate: pt,
1441
- lightboxEntries: k,
1442
- entryIdx: z,
1443
- layoutId: l,
1444
- sourceRect: at,
1445
- resolveCloseSourceRect: gt,
1446
- onClose: J,
1447
- onPrev: () => St(-1),
1448
- onNext: () => St(1)
1449
- }
1450
- ) }),
1451
- x
1452
- );
1453
- })()
1454
- ] });
1455
- }
1456
- export {
1457
- ti as Hive
1458
- };