@mintplayer/web-components 2.1.0 → 2.2.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,947 @@
1
+ import { unsafeCSS as p, LitElement as f, adoptStyles as m, nothing as l, html as c } from "lit";
2
+ import { map as h } from "lit/directives/map.js";
3
+ import { range as u } from "lit/directives/range.js";
4
+ import { unsafeHTML as g } from "lit/directives/unsafe-html.js";
5
+ import { keyToIntent as b, IndexMachine as v, PointerArbiter as y } from "../swiper-core/index.mjs";
6
+ const x = p(`.carousel {
7
+ position: relative;
8
+ }
9
+
10
+ .carousel.pointer-event {
11
+ touch-action: pan-y;
12
+ }
13
+
14
+ .carousel-inner {
15
+ position: relative;
16
+ width: 100%;
17
+ overflow: hidden;
18
+ }
19
+ .carousel-inner::after {
20
+ display: block;
21
+ clear: both;
22
+ content: "";
23
+ }
24
+
25
+ .carousel-item {
26
+ position: relative;
27
+ display: none;
28
+ float: left;
29
+ width: 100%;
30
+ margin-right: -100%;
31
+ backface-visibility: hidden;
32
+ transition: transform 0.6s ease-in-out;
33
+ }
34
+ @media (prefers-reduced-motion: reduce) {
35
+ .carousel-item {
36
+ transition: none;
37
+ }
38
+ }
39
+
40
+ .carousel-item.active,
41
+ .carousel-item-next,
42
+ .carousel-item-prev {
43
+ display: block;
44
+ }
45
+
46
+ .carousel-item-next:not(.carousel-item-start),
47
+ .active.carousel-item-end {
48
+ transform: translateX(100%);
49
+ }
50
+
51
+ .carousel-item-prev:not(.carousel-item-end),
52
+ .active.carousel-item-start {
53
+ transform: translateX(-100%);
54
+ }
55
+
56
+ .carousel-fade .carousel-item {
57
+ opacity: 0;
58
+ transition-property: opacity;
59
+ transform: none;
60
+ }
61
+ .carousel-fade .carousel-item.active,
62
+ .carousel-fade .carousel-item-next.carousel-item-start,
63
+ .carousel-fade .carousel-item-prev.carousel-item-end {
64
+ z-index: 1;
65
+ opacity: 1;
66
+ }
67
+ .carousel-fade .active.carousel-item-start,
68
+ .carousel-fade .active.carousel-item-end {
69
+ z-index: 0;
70
+ opacity: 0;
71
+ transition: opacity 0s 0.6s;
72
+ }
73
+ @media (prefers-reduced-motion: reduce) {
74
+ .carousel-fade .active.carousel-item-start,
75
+ .carousel-fade .active.carousel-item-end {
76
+ transition: none;
77
+ }
78
+ }
79
+
80
+ .carousel-control-prev,
81
+ .carousel-control-next {
82
+ position: absolute;
83
+ top: 0;
84
+ bottom: 0;
85
+ z-index: 1;
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ width: 15%;
90
+ padding: 0;
91
+ color: #fff;
92
+ text-align: center;
93
+ background: none;
94
+ filter: var(--bs-carousel-control-icon-filter);
95
+ border: 0;
96
+ opacity: 0.5;
97
+ transition: opacity 0.15s ease;
98
+ }
99
+ @media (prefers-reduced-motion: reduce) {
100
+ .carousel-control-prev,
101
+ .carousel-control-next {
102
+ transition: none;
103
+ }
104
+ }
105
+ .carousel-control-prev:hover, .carousel-control-prev:focus,
106
+ .carousel-control-next:hover,
107
+ .carousel-control-next:focus {
108
+ color: #fff;
109
+ text-decoration: none;
110
+ outline: 0;
111
+ opacity: 0.9;
112
+ }
113
+
114
+ .carousel-control-prev {
115
+ left: 0;
116
+ }
117
+
118
+ .carousel-control-next {
119
+ right: 0;
120
+ }
121
+
122
+ .carousel-control-prev-icon,
123
+ .carousel-control-next-icon {
124
+ display: inline-block;
125
+ width: 2rem;
126
+ height: 2rem;
127
+ background-repeat: no-repeat;
128
+ background-position: 50%;
129
+ background-size: 100% 100%;
130
+ }
131
+
132
+ .carousel-control-prev-icon {
133
+ background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0'/%3e%3c/svg%3e") /*rtl:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708'/%3e%3c/svg%3e")*/;
134
+ }
135
+
136
+ .carousel-control-next-icon {
137
+ background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708'/%3e%3c/svg%3e") /*rtl:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0'/%3e%3c/svg%3e")*/;
138
+ }
139
+
140
+ .carousel-indicators {
141
+ position: absolute;
142
+ right: 0;
143
+ bottom: 0;
144
+ left: 0;
145
+ z-index: 2;
146
+ display: flex;
147
+ justify-content: center;
148
+ padding: 0;
149
+ margin-right: 15%;
150
+ margin-bottom: 1rem;
151
+ margin-left: 15%;
152
+ }
153
+ .carousel-indicators [data-bs-target] {
154
+ box-sizing: content-box;
155
+ flex: 0 1 auto;
156
+ width: 30px;
157
+ height: 3px;
158
+ padding: 0;
159
+ margin-right: 3px;
160
+ margin-left: 3px;
161
+ text-indent: -999px;
162
+ cursor: pointer;
163
+ background-color: var(--bs-carousel-indicator-active-bg);
164
+ background-clip: padding-box;
165
+ border: 0;
166
+ border-top: 10px solid transparent;
167
+ border-bottom: 10px solid transparent;
168
+ opacity: 0.5;
169
+ transition: opacity 0.6s ease;
170
+ }
171
+ @media (prefers-reduced-motion: reduce) {
172
+ .carousel-indicators [data-bs-target] {
173
+ transition: none;
174
+ }
175
+ }
176
+ .carousel-indicators .active {
177
+ opacity: 1;
178
+ }
179
+
180
+ .carousel-caption {
181
+ position: absolute;
182
+ right: 15%;
183
+ bottom: 1.25rem;
184
+ left: 15%;
185
+ padding-top: 1.25rem;
186
+ padding-bottom: 1.25rem;
187
+ color: var(--bs-carousel-caption-color);
188
+ text-align: center;
189
+ }
190
+
191
+ .carousel-dark {
192
+ --bs-carousel-indicator-active-bg: #000;
193
+ --bs-carousel-caption-color: #000;
194
+ --bs-carousel-control-icon-filter: invert(1) grayscale(100);
195
+ }
196
+
197
+ :root,
198
+ [data-bs-theme=light] {
199
+ --bs-carousel-indicator-active-bg: #fff;
200
+ --bs-carousel-caption-color: #fff;
201
+ --bs-carousel-control-icon-filter: ;
202
+ }
203
+
204
+ [data-bs-theme=dark] {
205
+ --bs-carousel-indicator-active-bg: #000;
206
+ --bs-carousel-caption-color: #000;
207
+ --bs-carousel-control-icon-filter: invert(1) grayscale(100);
208
+ }
209
+
210
+ :host,
211
+ *,
212
+ *::before,
213
+ *::after {
214
+ box-sizing: border-box;
215
+ }
216
+
217
+ :host {
218
+ display: block;
219
+ position: relative;
220
+ min-height: 100px;
221
+ max-width: 500px;
222
+ margin-inline: auto;
223
+ }
224
+
225
+ .visually-hidden {
226
+ position: absolute;
227
+ width: 1px;
228
+ height: 1px;
229
+ margin: -1px;
230
+ padding: 0;
231
+ overflow: hidden;
232
+ clip: rect(0 0 0 0);
233
+ white-space: nowrap;
234
+ border: 0;
235
+ }
236
+
237
+ .carousel-inner {
238
+ position: relative;
239
+ width: 100%;
240
+ overflow: hidden;
241
+ height: var(--mp-carousel-viewport-height, auto);
242
+ overscroll-behavior: contain;
243
+ }
244
+
245
+ .carousel-track {
246
+ display: flex;
247
+ touch-action: pan-y;
248
+ overscroll-behavior: contain;
249
+ will-change: transform;
250
+ }
251
+
252
+ :host([orientation=vertical]) .carousel-track {
253
+ flex-direction: column;
254
+ touch-action: pan-x;
255
+ }
256
+
257
+ .carousel-track .carousel-item {
258
+ display: flex;
259
+ align-items: flex-start;
260
+ justify-content: center;
261
+ float: none;
262
+ flex: 0 0 100%;
263
+ min-width: 0;
264
+ margin-right: 0;
265
+ position: relative;
266
+ transition: none;
267
+ backface-visibility: visible;
268
+ }
269
+
270
+ .carousel-item slot::slotted(*) {
271
+ width: 100% !important;
272
+ }
273
+
274
+ .carousel-item slot::slotted(img) {
275
+ height: auto;
276
+ }
277
+
278
+ :host([animation=fade]) .carousel-item {
279
+ align-items: center;
280
+ }
281
+
282
+ :host([orientation=vertical]) .carousel-item {
283
+ flex: 0 0 auto;
284
+ flex-direction: column;
285
+ align-items: center;
286
+ height: var(--mp-carousel-slide-height, auto);
287
+ }
288
+
289
+ :host([animation=fade][data-js]) .carousel-track {
290
+ display: grid;
291
+ }
292
+ :host([animation=fade][data-js]) .carousel-item {
293
+ grid-row: 1;
294
+ grid-column: 1;
295
+ opacity: 0;
296
+ transition: opacity 500ms ease-in-out;
297
+ pointer-events: none;
298
+ }
299
+ :host([animation=fade][data-js]) .carousel-item.active {
300
+ opacity: 1;
301
+ pointer-events: auto;
302
+ z-index: 1;
303
+ }
304
+ :host([animation=fade][data-js]) .carousel-clone {
305
+ display: none;
306
+ }
307
+
308
+ :host(:not([data-js])) .carousel-inner {
309
+ height: auto;
310
+ }
311
+ :host(:not([data-js])) .carousel-clone,
312
+ :host(:not([data-js])) .carousel-item[data-i] {
313
+ display: none;
314
+ }
315
+ :host(:not([data-js])) .carousel-track {
316
+ display: block;
317
+ transform: none;
318
+ }
319
+ :host(:not([data-js])) .nojs-cell {
320
+ display: flex;
321
+ justify-content: flex-start;
322
+ transition: transform 0.5s ease;
323
+ }
324
+ :host(:not([data-js])) .nojs-cell slot::slotted(*) {
325
+ flex: 0 0 100%;
326
+ width: 100% !important;
327
+ }
328
+
329
+ :host(:not([data-js])[animation=none]) .nojs-cell {
330
+ transition-duration: 0s;
331
+ }
332
+
333
+ :host(:not([data-js])[animation=fade]) .nojs-cell,
334
+ :host(:not([data-js])[orientation=vertical]) .nojs-cell {
335
+ display: grid;
336
+ transform: none !important;
337
+ }
338
+ :host(:not([data-js])[animation=fade]) .nojs-cell slot::slotted(*),
339
+ :host(:not([data-js])[orientation=vertical]) .nojs-cell slot::slotted(*) {
340
+ grid-row: 1;
341
+ grid-column: 1;
342
+ opacity: 0;
343
+ transition: opacity 0.4s ease-in-out;
344
+ }
345
+
346
+ .carousel-controls .carousel-control-prev,
347
+ .carousel-controls .carousel-control-next {
348
+ display: none;
349
+ cursor: pointer;
350
+ z-index: 10;
351
+ border: 0;
352
+ background: transparent;
353
+ }
354
+
355
+ :host([orientation=vertical]) .carousel-control-prev,
356
+ :host([orientation=vertical]) .carousel-control-next {
357
+ width: 100%;
358
+ left: 0;
359
+ right: 0;
360
+ justify-content: center;
361
+ top: 0;
362
+ bottom: auto;
363
+ height: 2.5rem;
364
+ align-items: center;
365
+ }
366
+ :host([orientation=vertical]) .carousel-control-next {
367
+ top: auto;
368
+ bottom: 0;
369
+ }
370
+ :host([orientation=vertical]) .carousel-control-prev-icon,
371
+ :host([orientation=vertical]) .carousel-control-next-icon {
372
+ background-color: rgba(0, 0, 0, 0.5);
373
+ border-radius: 50%;
374
+ padding: 1.5rem;
375
+ background-size: 50%;
376
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
377
+ transform: rotate(90deg);
378
+ }
379
+
380
+ :host(:not([indicators])) .carousel-indicators {
381
+ display: none;
382
+ }
383
+
384
+ .carousel-indicators {
385
+ z-index: 10;
386
+ }
387
+ .carousel-indicators [data-bs-target] {
388
+ background-color: var(--bs-carousel-indicator-active-bg, #fff);
389
+ cursor: pointer;
390
+ }
391
+
392
+ :host([orientation=vertical]) .carousel-indicators {
393
+ position: absolute;
394
+ left: 0;
395
+ top: 50%;
396
+ right: auto;
397
+ bottom: auto;
398
+ transform: translateY(-50%);
399
+ flex-direction: column;
400
+ justify-content: center;
401
+ align-items: center;
402
+ margin: 0;
403
+ margin-left: 0.5rem;
404
+ gap: 0.5rem;
405
+ }
406
+ :host([orientation=vertical]) .carousel-indicators [data-bs-target] {
407
+ width: 12px;
408
+ height: 12px;
409
+ border-radius: 50%;
410
+ border: none;
411
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
412
+ }
413
+
414
+ .carousel-play-pause {
415
+ position: absolute;
416
+ bottom: 3rem;
417
+ left: 50%;
418
+ transform: translateX(-50%);
419
+ z-index: 11;
420
+ margin: 0;
421
+ }
422
+
423
+ :host([orientation=vertical]) .carousel-play-pause {
424
+ bottom: auto;
425
+ top: 0.5rem;
426
+ left: auto;
427
+ right: 0.5rem;
428
+ transform: none;
429
+ }
430
+
431
+ .carousel-play-pause-btn {
432
+ display: inline-flex;
433
+ align-items: center;
434
+ justify-content: center;
435
+ width: 1.75rem;
436
+ height: 1.75rem;
437
+ padding: 0;
438
+ border: none;
439
+ border-radius: 50%;
440
+ background-color: rgba(0, 0, 0, 0.5);
441
+ color: #fff;
442
+ cursor: pointer;
443
+ transition: background-color 0.15s ease;
444
+ }
445
+ .carousel-play-pause-btn:hover, .carousel-play-pause-btn:focus-visible {
446
+ background-color: rgba(0, 0, 0, 0.75);
447
+ }
448
+ .carousel-play-pause-btn:focus-visible {
449
+ outline: 2px solid #fff;
450
+ outline-offset: 2px;
451
+ }
452
+
453
+ .carousel-play-pause-icon {
454
+ display: inline-block;
455
+ width: 0.75rem;
456
+ height: 0.75rem;
457
+ background-repeat: no-repeat;
458
+ background-position: 50%;
459
+ background-size: 100% 100%;
460
+ }
461
+
462
+ .carousel-play-pause-paused .carousel-play-pause-icon {
463
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3E%3Cpath d='M3 1.5v13a.5.5 0 0 0 .77.42l11-6.5a.5.5 0 0 0 0-.84l-11-6.5A.5.5 0 0 0 3 1.5z'/%3E%3C/svg%3E");
464
+ }
465
+
466
+ .carousel-play-pause-playing .carousel-play-pause-icon {
467
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3E%3Cpath d='M5 2h2v12H5zM9 2h2v12H9z'/%3E%3C/svg%3E");
468
+ }
469
+
470
+ @media (prefers-reduced-motion: reduce) {
471
+ .nojs-cell,
472
+ .nojs-cell slot::slotted(*),
473
+ .carousel-item,
474
+ .carousel-play-pause-btn {
475
+ transition: none !important;
476
+ }
477
+ }`);
478
+ class w extends f {
479
+ constructor() {
480
+ super(...arguments), this.#e = [], this.#i = 0, this.#f = null, this.#t = null, this.#a = null, this.#l = null, this.#n = null, this.#m = /* @__PURE__ */ new Map(), this.#g = 0, this.#c = null, this.#r = null, this.#s = null, this.#b = !1, this.togglePaused = () => {
481
+ this.#x(!this.paused);
482
+ }, this.#M = () => {
483
+ this.#p(), this.requestUpdate();
484
+ }, this.#P = (t) => {
485
+ if (t.touches.length !== 1) return;
486
+ const e = t.touches[0];
487
+ this.#a?.pointerDown(e.clientX, e.clientY);
488
+ }, this.#I = (t) => {
489
+ const e = t.touches[0];
490
+ e && this.#a?.pointerMove(e.clientX, e.clientY) && (t.preventDefault(), t.stopPropagation());
491
+ }, this.#U = (t) => {
492
+ this.#a?.pointerUp() && (t.preventDefault(), t.stopPropagation());
493
+ }, this.#B = () => {
494
+ this.#a?.abort(), this.#t?.goto(this.#i, { animate: !1 });
495
+ }, this.#H = (t) => {
496
+ if (t.target !== t.currentTarget || !this.#S) return;
497
+ const e = b(t.key, this.#o);
498
+ e && (t.preventDefault(), this.#t?.intent(e));
499
+ }, this.#N = (t) => {
500
+ const i = [...this.renderRoot?.querySelectorAll(".car-radio") ?? []].indexOf(t.target);
501
+ i >= 0 && i !== this.#i && this.#t?.goto(i);
502
+ };
503
+ }
504
+ static {
505
+ this.styles = [x];
506
+ }
507
+ static get observedAttributes() {
508
+ return [
509
+ ...super.observedAttributes ?? [],
510
+ "animation",
511
+ "orientation",
512
+ "interval",
513
+ "wrap",
514
+ "indicators",
515
+ "keyboard-events",
516
+ "paused"
517
+ ];
518
+ }
519
+ #e;
520
+ #i;
521
+ #f;
522
+ #t;
523
+ #a;
524
+ #l;
525
+ #n;
526
+ #m;
527
+ #g;
528
+ #c;
529
+ #r;
530
+ #s;
531
+ #b;
532
+ // ---- element lifecycle ----------------------------------------------------
533
+ createRenderRoot() {
534
+ if (this.shadowRoot) {
535
+ const e = [...this.shadowRoot.querySelectorAll(".car-radio")].findIndex((i) => i.checked);
536
+ return e > 0 && (this.#f = e), this.shadowRoot.replaceChildren(), m(this.shadowRoot, this.constructor.elementStyles ?? []), this.shadowRoot;
537
+ }
538
+ return super.createRenderRoot();
539
+ }
540
+ connectedCallback() {
541
+ super.connectedCallback(), this.setAttribute("data-js", ""), this.hasAttribute("role") || this.setAttribute("role", "region"), this.hasAttribute("aria-roledescription") || this.setAttribute("aria-roledescription", "carousel"), typeof window < "u" && window.matchMedia && !this.#r && (this.#r = window.matchMedia("(prefers-reduced-motion: reduce)")), this.#r?.addEventListener("change", this.#M), this.hasUpdated && (this.#L(), this.#j(), this.#p());
542
+ }
543
+ disconnectedCallback() {
544
+ super.disconnectedCallback(), this.#r?.removeEventListener("change", this.#M), this.#l?.disconnect(), this.#n?.disconnect(), this.#a?.abort(), this.#q();
545
+ }
546
+ firstUpdated() {
547
+ this.#O(), this.#L(), this.#j();
548
+ const t = this.#f;
549
+ this.#f = null, t !== null && t < this.#e.length ? this.#t?.goto(t, { animate: !1 }) : this.#u(this.#i), this.#p();
550
+ const e = this.#A;
551
+ e && (e.addEventListener("touchstart", this.#P, { passive: !0 }), e.addEventListener("touchmove", this.#I, { passive: !1 }), e.addEventListener("touchend", this.#U, { passive: !1 }), e.addEventListener("touchcancel", this.#B, { passive: !0 }));
552
+ }
553
+ attributeChangedCallback(t, e, i) {
554
+ if (super.attributeChangedCallback(t, e, i), e !== i)
555
+ switch (t) {
556
+ case "orientation":
557
+ this.#a?.setOrientation(this.#o), this.#h(), this.#u(this.#i), this.requestUpdate();
558
+ break;
559
+ case "animation":
560
+ this.#t?.setConfig({ durationMs: this.#z }), this.#h(), this.#u(this.#i), this.requestUpdate();
561
+ break;
562
+ case "wrap":
563
+ this.#t?.setConfig({ wrap: this.#k });
564
+ break;
565
+ case "interval":
566
+ this.#p(), this.requestUpdate();
567
+ break;
568
+ case "paused":
569
+ this.#p(), this.requestUpdate(), this.#b;
570
+ break;
571
+ case "keyboard-events":
572
+ case "indicators":
573
+ this.requestUpdate();
574
+ break;
575
+ }
576
+ }
577
+ // ---- public API -------------------------------------------------------------
578
+ /** Committed slide index. Setting it jumps without animation. */
579
+ get index() {
580
+ return this.#i;
581
+ }
582
+ set index(t) {
583
+ this.#t?.goto(t, { animate: !1 });
584
+ }
585
+ // Config is attribute-only, DELIBERATELY not exposed as prototype
586
+ // properties: the no-JS CSS and the DSD injector select on the attributes,
587
+ // and framework bridges (@lit/react) strip prototype-matching props from
588
+ // server HTML to set them as client-side properties — which would erase
589
+ // exactly the attributes the no-JS tier needs (navbar/shell doctrine).
590
+ // `interval` and `paused` are the exception (client-only semantics), with
591
+ // reflecting setters for property bindings.
592
+ get #v() {
593
+ const t = this.getAttribute("animation");
594
+ return t === "fade" || t === "none" ? t : "slide";
595
+ }
596
+ get #o() {
597
+ return this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal";
598
+ }
599
+ get #k() {
600
+ return this.getAttribute("wrap") !== "false";
601
+ }
602
+ get #S() {
603
+ return this.getAttribute("keyboard-events") !== "false";
604
+ }
605
+ get interval() {
606
+ const t = Number(this.getAttribute("interval"));
607
+ return Number.isFinite(t) && t > 0 ? t : 0;
608
+ }
609
+ set interval(t) {
610
+ const e = Number(t);
611
+ Number.isFinite(e) && e > 0 ? this.setAttribute("interval", String(e)) : this.removeAttribute("interval");
612
+ }
613
+ get paused() {
614
+ return this.hasAttribute("paused");
615
+ }
616
+ set paused(t) {
617
+ this.#x(t === !0 || t === "" || t === "true", !1);
618
+ }
619
+ previous() {
620
+ this.#t?.previous();
621
+ }
622
+ next() {
623
+ this.#t?.next();
624
+ }
625
+ goto(t, e = {}) {
626
+ this.#t?.goto(t, e);
627
+ }
628
+ play() {
629
+ this.#x(!1);
630
+ }
631
+ pause() {
632
+ this.#x(!0);
633
+ }
634
+ // ---- engine wiring ----------------------------------------------------------
635
+ #O() {
636
+ this.#t || (this.#t = new v(
637
+ {
638
+ applyOffsetRatio: (t) => this.#u(t),
639
+ runTransition: (t, e, i, s) => this.#F(t, e, i, s)
640
+ },
641
+ {
642
+ onIndexChange: (t) => this.#K(t),
643
+ onAnimationStart: () => {
644
+ this.#$?.setAttribute("aria-busy", "true"), this.#w("animation-start", void 0);
645
+ },
646
+ onAnimationEnd: () => {
647
+ this.#$?.removeAttribute("aria-busy"), this.#w("animation-end", void 0);
648
+ }
649
+ },
650
+ {
651
+ count: this.#e.length,
652
+ wrap: this.#k,
653
+ durationMs: this.#z,
654
+ minimumOffsetPx: 50,
655
+ prefersReducedMotion: () => this.#r?.matches ?? !1
656
+ }
657
+ ), this.#a = new y(
658
+ { orientation: this.#o },
659
+ {
660
+ onDragStart: () => this.#t?.beginDrag(),
661
+ onDragMove: (t) => this.#t?.dragBy(t, this.#R()),
662
+ onDragEnd: (t) => this.#t?.endDrag(t, this.#R())
663
+ }
664
+ ));
665
+ }
666
+ get #z() {
667
+ return this.#v === "none" ? 0 : 500;
668
+ }
669
+ /** Drag/transform distance for one slide, in px. */
670
+ #R() {
671
+ return this.#o === "horizontal" ? this.#$?.clientWidth ?? 0 : this.#g;
672
+ }
673
+ get #$() {
674
+ return this.renderRoot?.querySelector(".carousel-inner") ?? null;
675
+ }
676
+ get #A() {
677
+ return this.renderRoot?.querySelector(".carousel-track") ?? null;
678
+ }
679
+ // ---- slides -----------------------------------------------------------------
680
+ #L() {
681
+ this.#l || (this.#l = new MutationObserver(() => this.#j())), this.#l.observe(this, { childList: !0 }), !this.#n && typeof ResizeObserver < "u" && (this.#n = new ResizeObserver((t) => {
682
+ for (const e of t)
683
+ this.#m.set(e.target, e.contentRect.height);
684
+ this.#h();
685
+ }));
686
+ }
687
+ #X() {
688
+ return [...this.children].filter(
689
+ (t) => t instanceof HTMLElement && t.getAttribute("slot") !== "play-pause"
690
+ );
691
+ }
692
+ #j() {
693
+ const t = this.#X();
694
+ if (!(t.length !== this.#e.length || t.some((i, s) => i !== this.#e[s])) && !this.#s) {
695
+ t.forEach((i, s) => {
696
+ i.getAttribute("slot") !== `s${s}` && i.setAttribute("slot", `s${s}`);
697
+ });
698
+ return;
699
+ }
700
+ this.#t?.interrupt(), this.#d(), this.#e = t, t.forEach((i, s) => i.setAttribute("slot", `s${s}`)), this.#n?.disconnect(), this.#m = new Map(t.map((i) => [i, i.offsetHeight || 0])), t.forEach((i) => this.#n?.observe(i)), this.#h(), t.forEach((i, s) => {
701
+ (i instanceof HTMLImageElement ? i : i.querySelector("img"))?.setAttribute("fetchpriority", s === 0 ? "high" : "low");
702
+ }), this.#t?.setConfig({ count: t.length }), this.#i >= t.length && (this.#i = Math.max(0, t.length - 1)), this.requestUpdate(), this.updateComplete.then(() => this.#u(this.#t?.getIndex() ?? this.#i));
703
+ }
704
+ #h() {
705
+ const t = this.#e.map((r) => this.#m.get(r) ?? 0), e = t.length ? Math.max(...t) : 0, i = t[this.#i] ?? e;
706
+ this.#g = e;
707
+ const s = this.#o === "vertical" ? e : i;
708
+ s > 10 ? this.style.setProperty("--mp-carousel-viewport-height", `${s}px`) : this.style.removeProperty("--mp-carousel-viewport-height"), this.#o === "vertical" && e > 10 ? this.style.setProperty("--mp-carousel-slide-height", `${e}px`) : this.style.removeProperty("--mp-carousel-slide-height");
709
+ }
710
+ // ---- position / transitions ---------------------------------------------------
711
+ /**
712
+ * Park the track at a logical ratio (slide units; may transiently sit
713
+ * outside [0, N-1] during a wrap). Physical mapping: the wrap-before cell
714
+ * occupies position 0, so physical = ratio + 1.
715
+ */
716
+ #u(t) {
717
+ const e = this.#A;
718
+ if (e) {
719
+ if (this.#v === "fade") {
720
+ e.style.transform = "", Number.isInteger(t) && this.#C(this.#T(t));
721
+ return;
722
+ }
723
+ this.#W(t), e.style.transform = this.#E(t);
724
+ }
725
+ }
726
+ #E(t) {
727
+ const e = t + 1;
728
+ return this.#o === "horizontal" ? `translate3d(${-e * 100}%, 0, 0)` : `translate3d(0, ${-e * this.#g}px, 0)`;
729
+ }
730
+ #T(t) {
731
+ const e = this.#e.length;
732
+ return e > 0 ? (t % e + e) % e : 0;
733
+ }
734
+ /** Visual `.active` (fade opacity target) — managed imperatively, not bound. */
735
+ #C(t) {
736
+ this.renderRoot?.querySelectorAll(".carousel-item[data-i]").forEach((e) => {
737
+ e.classList.toggle("active", Number(e.dataset.i) === t);
738
+ });
739
+ }
740
+ #F(t, e, i, s) {
741
+ if (this.#v === "fade") {
742
+ this.#C(this.#T(e));
743
+ let a = setTimeout(() => {
744
+ a = null, s();
745
+ }, i);
746
+ return {
747
+ finish: () => {
748
+ a !== null && (clearTimeout(a), a = null, s());
749
+ },
750
+ cancel: () => {
751
+ a !== null && (clearTimeout(a), a = null);
752
+ }
753
+ };
754
+ }
755
+ const r = this.#A;
756
+ if (!r)
757
+ return s(), { finish: () => {
758
+ }, cancel: () => {
759
+ } };
760
+ if (this.#Y(e), typeof r.animate != "function")
761
+ return this.#d(), s(), { finish: () => {
762
+ }, cancel: () => {
763
+ } };
764
+ const o = r.animate(
765
+ [{ transform: this.#E(t) }, { transform: this.#E(e) }],
766
+ { duration: i, easing: "ease", fill: "forwards" }
767
+ );
768
+ let n = !1;
769
+ const d = (a) => {
770
+ n || (n = !0, o.cancel(), this.#d(), a && s());
771
+ };
772
+ return o.onfinish = () => d(!0), {
773
+ finish: () => d(!0),
774
+ cancel: () => d(!1)
775
+ };
776
+ }
777
+ /** Teleport the destination slide into a wrap cell for a wrapping move. */
778
+ #Y(t) {
779
+ const e = this.#e.length;
780
+ e < 2 || (t === e ? this.#y(this.#e[0], "wrapA") : t === -1 && this.#y(this.#e[e - 1], "wrapB"));
781
+ }
782
+ /** During a live drag past the deck's edges, keep the wrap cell populated. */
783
+ #W(t) {
784
+ const e = this.#e.length;
785
+ e < 2 || !this.#k || (t > e - 1 ? this.#y(this.#e[0], "wrapA") : t < 0 ? this.#y(this.#e[e - 1], "wrapB") : this.#s && Number.isInteger(t) && this.#d());
786
+ }
787
+ #y(t, e) {
788
+ !t || this.#s?.el === t || (this.#d(), this.#s = { el: t, home: t.getAttribute("slot") ?? "" }, t.setAttribute("slot", e));
789
+ }
790
+ #d() {
791
+ this.#s && (this.#s.el.setAttribute("slot", this.#s.home), this.#s = null);
792
+ }
793
+ // ---- state sync -----------------------------------------------------------
794
+ #K(t) {
795
+ this.#i = t, this.renderRoot?.querySelectorAll(".car-radio")?.forEach((i, s) => i.checked = s === t), this.#v !== "fade" && this.#C(t), this.#h(), this.requestUpdate(), this.#w("slide-change", { index: t });
796
+ }
797
+ /** Single write path for `paused` + its event (programmatic writes stay silent). */
798
+ #x(t, e = !0) {
799
+ t !== this.paused && (this.#b = !0, t ? this.setAttribute("paused", "") : this.removeAttribute("paused"), this.#b = !1, e && this.#w("paused-change", { paused: t }));
800
+ }
801
+ #M;
802
+ #p() {
803
+ this.#q();
804
+ const t = this.interval;
805
+ t > 0 && !this.paused && !(this.#r?.matches ?? !1) && this.isConnected && (this.#c = setInterval(() => this.next(), t));
806
+ }
807
+ #q() {
808
+ this.#c !== null && (clearInterval(this.#c), this.#c = null);
809
+ }
810
+ /**
811
+ * `polite` announces manual navigation; `off` keeps rotation from spamming
812
+ * the screen reader. Rotation is only actually happening when an interval is
813
+ * set, not paused, and motion isn't reduced.
814
+ */
815
+ get #G() {
816
+ return this.interval <= 0 || this.paused || this.#r?.matches ? "polite" : "off";
817
+ }
818
+ #P;
819
+ #I;
820
+ #U;
821
+ #B;
822
+ #H;
823
+ #N;
824
+ #J(t, e) {
825
+ e.preventDefault(), this.#t?.goto(t);
826
+ }
827
+ #D(t, e) {
828
+ e.preventDefault(), this.#t?.[t]();
829
+ }
830
+ #w(t, e) {
831
+ this.dispatchEvent(new CustomEvent(t, { detail: e, bubbles: !0, composed: !0 }));
832
+ }
833
+ // ---- template ---------------------------------------------------------------
834
+ /**
835
+ * Count-dependent CSS for the no-JS tier (and the `:checked`-driven control
836
+ * pair reveal, which serves both tiers). Lives HERE — in render()'s single
837
+ * source of truth — so the pre-rendered DSD chrome variants carry it too.
838
+ */
839
+ #Q(t) {
840
+ let e = "";
841
+ for (let i = 0; i < t; i++) {
842
+ const s = `#s${i}:checked`;
843
+ e += `${s} ~ .carousel-controls .ctl-prev-${i}, ${s} ~ .carousel-controls .ctl-next-${i} { display: flex; }`, e += `${s} ~ .carousel-indicators label[for="s${i}"] { opacity: 1; }`, e += `#s${i}:focus-visible ~ .carousel-indicators label[for="s${i}"] { outline: 2px solid #fff; outline-offset: 2px; }`, e += `:host(:not([data-js])) ${s} ~ .carousel-inner .nojs-cell slot::slotted(:nth-child(${i + 1})) { opacity: 1; position: relative; z-index: 1; }`, e += `:host(:not([data-js]):not([animation="fade"]):not([orientation="vertical"])) ${s} ~ .carousel-inner .nojs-cell { transform: translateX(${-i * 100}%); }`;
844
+ }
845
+ return e;
846
+ }
847
+ render() {
848
+ const t = this.#e.length || Number(this.getAttribute("slide-count")) || 0, e = this.#i, i = this.interval, s = this.hasAttribute("data-js"), r = i > 0 || s && this.querySelector('[slot="play-pause"]') !== null;
849
+ return c`
850
+ ${g(`<style>${this.#Q(t)}</style>`)}
851
+ ${h(u(t), (o) => c`
852
+ <input
853
+ type="radio"
854
+ id="s${o}"
855
+ name="car"
856
+ class="car-radio visually-hidden"
857
+ aria-label="Slide ${o + 1}"
858
+ ?checked=${o === e}
859
+ @change=${this.#N}
860
+ />
861
+ `)}
862
+ <div
863
+ class="carousel-inner"
864
+ part="inner"
865
+ tabindex=${s ? "0" : l}
866
+ aria-live=${s ? this.#G : l}
867
+ aria-atomic=${s ? "false" : l}
868
+ aria-orientation=${s ? this.#o : l}
869
+ aria-keyshortcuts=${s && this.#S ? this.#o === "horizontal" ? "ArrowLeft ArrowRight Home End" : "ArrowUp ArrowDown Home End" : l}
870
+ @keydown=${this.#H}
871
+ >
872
+ <div class="carousel-track" part="track">
873
+ <div class="carousel-item carousel-clone" aria-hidden="true"><slot name="wrapB"></slot></div>
874
+ ${h(u(t), (o) => c`
875
+ <div
876
+ class="carousel-item"
877
+ data-i=${o}
878
+ role="group"
879
+ aria-roledescription="slide"
880
+ aria-label="${o + 1} of ${t}"
881
+ aria-hidden=${o === e ? l : "true"}
882
+ >
883
+ <slot name="s${o}"></slot>
884
+ </div>
885
+ `)}
886
+ <div class="carousel-item carousel-clone" aria-hidden="true"><slot name="wrapA"></slot></div>
887
+ <div class="carousel-item nojs-cell"><slot></slot></div>
888
+ </div>
889
+ </div>
890
+ <div class="carousel-indicators" part="indicators">
891
+ ${h(u(t), (o) => c`
892
+ <label
893
+ for="s${o}"
894
+ data-bs-target
895
+ aria-label="Slide ${o + 1}"
896
+ aria-current=${o === e ? "true" : l}
897
+ @click=${(n) => this.#J(o, n)}
898
+ ></label>
899
+ `)}
900
+ </div>
901
+ <div class="carousel-controls" part="controls">
902
+ ${h(u(t), (o) => c`
903
+ <label
904
+ class="carousel-control-prev ctl-prev-${o}"
905
+ for="s${(o - 1 + t) % t}"
906
+ role="button"
907
+ aria-label="Previous"
908
+ @click=${(n) => this.#D("previous", n)}
909
+ >
910
+ <span class="carousel-control-prev-icon" aria-hidden="true"></span>
911
+ <span class="visually-hidden">Previous</span>
912
+ </label>
913
+ <label
914
+ class="carousel-control-next ctl-next-${o}"
915
+ for="s${(o + 1) % t}"
916
+ role="button"
917
+ aria-label="Next"
918
+ @click=${(n) => this.#D("next", n)}
919
+ >
920
+ <span class="carousel-control-next-icon" aria-hidden="true"></span>
921
+ <span class="visually-hidden">Next</span>
922
+ </label>
923
+ `)}
924
+ </div>
925
+ ${r ? c`
926
+ <div class="carousel-play-pause" part="play-pause">
927
+ <slot name="play-pause">
928
+ <button
929
+ type="button"
930
+ class="carousel-play-pause-btn ${this.paused ? "carousel-play-pause-paused" : "carousel-play-pause-playing"}"
931
+ aria-pressed=${String(this.paused)}
932
+ aria-label=${this.paused ? "Start automatic slide show" : "Stop automatic slide show"}
933
+ @click=${this.togglePaused}
934
+ >
935
+ <span class="carousel-play-pause-icon" aria-hidden="true"></span>
936
+ </button>
937
+ </slot>
938
+ </div>
939
+ ` : l}
940
+ `;
941
+ }
942
+ }
943
+ customElements.get("mp-carousel") || customElements.define("mp-carousel", w);
944
+ export {
945
+ w as MpCarousel,
946
+ x as carouselStyles
947
+ };