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