@vtex/ads-stories 0.4.0 → 0.5.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +260 -28
  3. package/dist/cdn/vtex-ads-stories.js +1073 -20
  4. package/dist/cdn/vtex-ads-stories.js.map +1 -1
  5. package/dist/cjs/index.cjs +4392 -315
  6. package/dist/cjs/index.cjs.map +1 -1
  7. package/dist/cjs/index.d.cts +198 -12
  8. package/dist/cjs/react.cjs.map +1 -1
  9. package/dist/cjs/react.d.cts +46 -5
  10. package/dist/esm/index.d.ts +198 -12
  11. package/dist/esm/index.js +2819 -291
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/react.d.ts +46 -5
  14. package/package.json +21 -4
  15. package/src/cdn.ts +7 -3
  16. package/src/components/card/card.ts +101 -111
  17. package/src/components/card/index.ts +1 -1
  18. package/src/components/carousel/carousel.ts +670 -0
  19. package/src/components/carousel/index.ts +15 -0
  20. package/src/components/events/events-controller.ts +212 -0
  21. package/src/components/events/index.ts +6 -0
  22. package/src/components/icons/assets/caret-left-bold.svg +1 -0
  23. package/src/components/icons/assets/caret-right-bold.svg +1 -0
  24. package/src/components/icons/assets/caret-up-bold.svg +1 -0
  25. package/src/components/icons/index.ts +30 -9
  26. package/src/components/media/index.ts +3 -0
  27. package/src/components/media/media.ts +70 -0
  28. package/src/components/media/video-controller.ts +125 -0
  29. package/src/components/player/index.ts +6 -2
  30. package/src/components/player/player.ts +946 -134
  31. package/src/components/product/cta.ts +56 -0
  32. package/src/components/product/index.ts +20 -0
  33. package/src/components/product/price.ts +86 -0
  34. package/src/components/product/product.styles.ts +369 -0
  35. package/src/components/product/product.ts +235 -0
  36. package/src/index.ts +9 -1
  37. package/src/locales/en.ts +29 -0
  38. package/src/locales/es.ts +30 -0
  39. package/src/locales/index.ts +36 -0
  40. package/src/locales/pt.ts +29 -0
  41. package/src/locales/types.ts +24 -0
  42. package/src/react.ts +49 -7
  43. package/src/story/index.ts +5 -1
  44. package/src/story/story.ts +528 -93
  45. package/src/tag-name.ts +1 -0
  46. package/src/types.ts +8 -12
  47. package/src/utils/fetch-story.ts +113 -0
  48. package/src/utils/http-url.ts +12 -0
  49. package/src/utils/hydrate-products.ts +88 -0
  50. package/src/utils/send-event.ts +71 -0
  51. package/src/utils/with-timeout.ts +43 -0
@@ -21,59 +21,2231 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  TAG_NAME: () => TAG_NAME,
24
- VtexAdsStoryElement: () => VtexAdsStoryElement,
25
- defineVtexAdsStories: () => defineVtexAdsStories
24
+ VtexAdsStoryCarouselElement: () => VtexAdsStoryCarouselElement,
25
+ defineVtexAdsStoryCarousel: () => defineVtexAdsStoryCarousel
26
26
  });
27
27
  module.exports = __toCommonJS(index_exports);
28
28
 
29
+ // ../../node_modules/.pnpm/@lit-labs+ssr-dom-shim@1.6.0/node_modules/@lit-labs/ssr-dom-shim/lib/element-internals.js
30
+ var ElementInternalsShim = class ElementInternals {
31
+ get shadowRoot() {
32
+ return this.__host.__shadowRoot;
33
+ }
34
+ constructor(_host) {
35
+ this.ariaActiveDescendantElement = null;
36
+ this.ariaAtomic = "";
37
+ this.ariaAutoComplete = "";
38
+ this.ariaBrailleLabel = "";
39
+ this.ariaBrailleRoleDescription = "";
40
+ this.ariaBusy = "";
41
+ this.ariaChecked = "";
42
+ this.ariaColCount = "";
43
+ this.ariaColIndex = "";
44
+ this.ariaColIndexText = "";
45
+ this.ariaColSpan = "";
46
+ this.ariaControlsElements = null;
47
+ this.ariaCurrent = "";
48
+ this.ariaDescribedByElements = null;
49
+ this.ariaDescription = "";
50
+ this.ariaDetailsElements = null;
51
+ this.ariaDisabled = "";
52
+ this.ariaErrorMessageElements = null;
53
+ this.ariaExpanded = "";
54
+ this.ariaFlowToElements = null;
55
+ this.ariaHasPopup = "";
56
+ this.ariaHidden = "";
57
+ this.ariaInvalid = "";
58
+ this.ariaKeyShortcuts = "";
59
+ this.ariaLabel = "";
60
+ this.ariaLabelledByElements = null;
61
+ this.ariaLevel = "";
62
+ this.ariaLive = "";
63
+ this.ariaModal = "";
64
+ this.ariaMultiLine = "";
65
+ this.ariaMultiSelectable = "";
66
+ this.ariaOrientation = "";
67
+ this.ariaOwnsElements = null;
68
+ this.ariaPlaceholder = "";
69
+ this.ariaPosInSet = "";
70
+ this.ariaPressed = "";
71
+ this.ariaReadOnly = "";
72
+ this.ariaRelevant = "";
73
+ this.ariaRequired = "";
74
+ this.ariaRoleDescription = "";
75
+ this.ariaRowCount = "";
76
+ this.ariaRowIndex = "";
77
+ this.ariaRowIndexText = "";
78
+ this.ariaRowSpan = "";
79
+ this.ariaSelected = "";
80
+ this.ariaSetSize = "";
81
+ this.ariaSort = "";
82
+ this.ariaValueMax = "";
83
+ this.ariaValueMin = "";
84
+ this.ariaValueNow = "";
85
+ this.ariaValueText = "";
86
+ this.role = "";
87
+ this.form = null;
88
+ this.labels = [];
89
+ this.states = /* @__PURE__ */ new Set();
90
+ this.validationMessage = "";
91
+ this.validity = {};
92
+ this.willValidate = true;
93
+ this.__host = _host;
94
+ }
95
+ checkValidity() {
96
+ console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true.");
97
+ return true;
98
+ }
99
+ reportValidity() {
100
+ return true;
101
+ }
102
+ setFormValue() {
103
+ }
104
+ setValidity() {
105
+ }
106
+ };
107
+
108
+ // ../../node_modules/.pnpm/@lit-labs+ssr-dom-shim@1.6.0/node_modules/@lit-labs/ssr-dom-shim/lib/events.js
109
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f4) {
110
+ if (kind === "m") throw new TypeError("Private method is not writable");
111
+ if (kind === "a" && !f4) throw new TypeError("Private accessor was defined without a setter");
112
+ if (typeof state === "function" ? receiver !== state || !f4 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
113
+ return kind === "a" ? f4.call(receiver, value) : f4 ? f4.value = value : state.set(receiver, value), value;
114
+ };
115
+ var __classPrivateFieldGet = function(receiver, state, kind, f4) {
116
+ if (kind === "a" && !f4) throw new TypeError("Private accessor was defined without a getter");
117
+ if (typeof state === "function" ? receiver !== state || !f4 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
118
+ return kind === "m" ? f4 : kind === "a" ? f4.call(receiver) : f4 ? f4.value : state.get(receiver);
119
+ };
120
+ var _Event_cancelable;
121
+ var _Event_bubbles;
122
+ var _Event_composed;
123
+ var _Event_defaultPrevented;
124
+ var _Event_timestamp;
125
+ var _Event_propagationStopped;
126
+ var _Event_type;
127
+ var _Event_target;
128
+ var _Event_isBeingDispatched;
129
+ var _a;
130
+ var _CustomEvent_detail;
131
+ var _b;
132
+ var NONE = 0;
133
+ var CAPTURING_PHASE = 1;
134
+ var AT_TARGET = 2;
135
+ var BUBBLING_PHASE = 3;
136
+ var enumerableProperty = { __proto__: null };
137
+ enumerableProperty.enumerable = true;
138
+ Object.freeze(enumerableProperty);
139
+ var EventShim = (_a = class Event {
140
+ constructor(type, options = {}) {
141
+ _Event_cancelable.set(this, false);
142
+ _Event_bubbles.set(this, false);
143
+ _Event_composed.set(this, false);
144
+ _Event_defaultPrevented.set(this, false);
145
+ _Event_timestamp.set(this, Date.now());
146
+ _Event_propagationStopped.set(this, false);
147
+ _Event_type.set(this, void 0);
148
+ _Event_target.set(this, void 0);
149
+ _Event_isBeingDispatched.set(this, void 0);
150
+ this.NONE = NONE;
151
+ this.CAPTURING_PHASE = CAPTURING_PHASE;
152
+ this.AT_TARGET = AT_TARGET;
153
+ this.BUBBLING_PHASE = BUBBLING_PHASE;
154
+ if (arguments.length === 0)
155
+ throw new Error(`The type argument must be specified`);
156
+ if (typeof options !== "object" || !options) {
157
+ throw new Error(`The "options" argument must be an object`);
158
+ }
159
+ const { bubbles, cancelable, composed } = options;
160
+ __classPrivateFieldSet(this, _Event_cancelable, !!cancelable, "f");
161
+ __classPrivateFieldSet(this, _Event_bubbles, !!bubbles, "f");
162
+ __classPrivateFieldSet(this, _Event_composed, !!composed, "f");
163
+ __classPrivateFieldSet(this, _Event_type, `${type}`, "f");
164
+ __classPrivateFieldSet(this, _Event_target, null, "f");
165
+ __classPrivateFieldSet(this, _Event_isBeingDispatched, false, "f");
166
+ }
167
+ initEvent(_type, _bubbles, _cancelable) {
168
+ throw new Error("Method not implemented.");
169
+ }
170
+ stopImmediatePropagation() {
171
+ this.stopPropagation();
172
+ }
173
+ preventDefault() {
174
+ __classPrivateFieldSet(this, _Event_defaultPrevented, true, "f");
175
+ }
176
+ get target() {
177
+ return __classPrivateFieldGet(this, _Event_target, "f");
178
+ }
179
+ get currentTarget() {
180
+ return __classPrivateFieldGet(this, _Event_target, "f");
181
+ }
182
+ get srcElement() {
183
+ return __classPrivateFieldGet(this, _Event_target, "f");
184
+ }
185
+ get type() {
186
+ return __classPrivateFieldGet(this, _Event_type, "f");
187
+ }
188
+ get cancelable() {
189
+ return __classPrivateFieldGet(this, _Event_cancelable, "f");
190
+ }
191
+ get defaultPrevented() {
192
+ return __classPrivateFieldGet(this, _Event_cancelable, "f") && __classPrivateFieldGet(this, _Event_defaultPrevented, "f");
193
+ }
194
+ get timeStamp() {
195
+ return __classPrivateFieldGet(this, _Event_timestamp, "f");
196
+ }
197
+ composedPath() {
198
+ return __classPrivateFieldGet(this, _Event_isBeingDispatched, "f") ? [__classPrivateFieldGet(this, _Event_target, "f")] : [];
199
+ }
200
+ get returnValue() {
201
+ return !__classPrivateFieldGet(this, _Event_cancelable, "f") || !__classPrivateFieldGet(this, _Event_defaultPrevented, "f");
202
+ }
203
+ get bubbles() {
204
+ return __classPrivateFieldGet(this, _Event_bubbles, "f");
205
+ }
206
+ get composed() {
207
+ return __classPrivateFieldGet(this, _Event_composed, "f");
208
+ }
209
+ get eventPhase() {
210
+ return __classPrivateFieldGet(this, _Event_isBeingDispatched, "f") ? _a.AT_TARGET : _a.NONE;
211
+ }
212
+ get cancelBubble() {
213
+ return __classPrivateFieldGet(this, _Event_propagationStopped, "f");
214
+ }
215
+ set cancelBubble(value) {
216
+ if (value) {
217
+ __classPrivateFieldSet(this, _Event_propagationStopped, true, "f");
218
+ }
219
+ }
220
+ stopPropagation() {
221
+ __classPrivateFieldSet(this, _Event_propagationStopped, true, "f");
222
+ }
223
+ get isTrusted() {
224
+ return false;
225
+ }
226
+ }, _Event_cancelable = /* @__PURE__ */ new WeakMap(), _Event_bubbles = /* @__PURE__ */ new WeakMap(), _Event_composed = /* @__PURE__ */ new WeakMap(), _Event_defaultPrevented = /* @__PURE__ */ new WeakMap(), _Event_timestamp = /* @__PURE__ */ new WeakMap(), _Event_propagationStopped = /* @__PURE__ */ new WeakMap(), _Event_type = /* @__PURE__ */ new WeakMap(), _Event_target = /* @__PURE__ */ new WeakMap(), _Event_isBeingDispatched = /* @__PURE__ */ new WeakMap(), _a.NONE = NONE, _a.CAPTURING_PHASE = CAPTURING_PHASE, _a.AT_TARGET = AT_TARGET, _a.BUBBLING_PHASE = BUBBLING_PHASE, _a);
227
+ Object.defineProperties(EventShim.prototype, {
228
+ initEvent: enumerableProperty,
229
+ stopImmediatePropagation: enumerableProperty,
230
+ preventDefault: enumerableProperty,
231
+ target: enumerableProperty,
232
+ currentTarget: enumerableProperty,
233
+ srcElement: enumerableProperty,
234
+ type: enumerableProperty,
235
+ cancelable: enumerableProperty,
236
+ defaultPrevented: enumerableProperty,
237
+ timeStamp: enumerableProperty,
238
+ composedPath: enumerableProperty,
239
+ returnValue: enumerableProperty,
240
+ bubbles: enumerableProperty,
241
+ composed: enumerableProperty,
242
+ eventPhase: enumerableProperty,
243
+ cancelBubble: enumerableProperty,
244
+ stopPropagation: enumerableProperty,
245
+ isTrusted: enumerableProperty
246
+ });
247
+ var CustomEventShim = (_b = class CustomEvent extends EventShim {
248
+ constructor(type, options = {}) {
249
+ var _a13;
250
+ super(type, options);
251
+ _CustomEvent_detail.set(this, void 0);
252
+ __classPrivateFieldSet(this, _CustomEvent_detail, (_a13 = options == null ? void 0 : options.detail) != null ? _a13 : null, "f");
253
+ }
254
+ initCustomEvent(_type, _bubbles, _cancelable, _detail) {
255
+ throw new Error("Method not implemented.");
256
+ }
257
+ get detail() {
258
+ return __classPrivateFieldGet(this, _CustomEvent_detail, "f");
259
+ }
260
+ }, _CustomEvent_detail = /* @__PURE__ */ new WeakMap(), _b);
261
+ Object.defineProperties(CustomEventShim.prototype, {
262
+ detail: enumerableProperty
263
+ });
264
+ var EventShimWithRealType = EventShim;
265
+ var CustomEventShimWithRealType = CustomEventShim;
266
+
267
+ // ../../node_modules/.pnpm/@lit-labs+ssr-dom-shim@1.6.0/node_modules/@lit-labs/ssr-dom-shim/lib/css.js
268
+ var _a2;
269
+ var CSSRuleShim = (_a2 = class CSSRule {
270
+ constructor() {
271
+ this.STYLE_RULE = 1;
272
+ this.CHARSET_RULE = 2;
273
+ this.IMPORT_RULE = 3;
274
+ this.MEDIA_RULE = 4;
275
+ this.FONT_FACE_RULE = 5;
276
+ this.PAGE_RULE = 6;
277
+ this.NAMESPACE_RULE = 10;
278
+ this.KEYFRAMES_RULE = 7;
279
+ this.KEYFRAME_RULE = 8;
280
+ this.SUPPORTS_RULE = 12;
281
+ this.COUNTER_STYLE_RULE = 11;
282
+ this.FONT_FEATURE_VALUES_RULE = 14;
283
+ this.MARGIN_RULE = 9;
284
+ this.__parentStyleSheet = null;
285
+ this.cssText = "";
286
+ }
287
+ get parentRule() {
288
+ return null;
289
+ }
290
+ get parentStyleSheet() {
291
+ return this.__parentStyleSheet;
292
+ }
293
+ get type() {
294
+ return 0;
295
+ }
296
+ }, _a2.STYLE_RULE = 1, _a2.CHARSET_RULE = 2, _a2.IMPORT_RULE = 3, _a2.MEDIA_RULE = 4, _a2.FONT_FACE_RULE = 5, _a2.PAGE_RULE = 6, _a2.NAMESPACE_RULE = 10, _a2.KEYFRAMES_RULE = 7, _a2.KEYFRAME_RULE = 8, _a2.SUPPORTS_RULE = 12, _a2.COUNTER_STYLE_RULE = 11, _a2.FONT_FEATURE_VALUES_RULE = 14, _a2.MARGIN_RULE = 9, _a2);
297
+
298
+ // ../../node_modules/.pnpm/@lit-labs+ssr-dom-shim@1.6.0/node_modules/@lit-labs/ssr-dom-shim/index.js
299
+ var _a3;
300
+ (_a3 = globalThis.Event) != null ? _a3 : globalThis.Event = EventShimWithRealType;
301
+ var _a4;
302
+ (_a4 = globalThis.CustomEvent) != null ? _a4 : globalThis.CustomEvent = CustomEventShimWithRealType;
303
+ var constructionToken = Symbol();
304
+ var isCaptureEventListener = (options) => {
305
+ var _a13;
306
+ return typeof options === "boolean" ? options : (_a13 = options == null ? void 0 : options.capture) != null ? _a13 : false;
307
+ };
308
+ var enumerableProperty2 = { __proto__: null };
309
+ enumerableProperty2.enumerable = true;
310
+ Object.freeze(enumerableProperty2);
311
+ var EventTarget = class {
312
+ constructor() {
313
+ this.__eventListeners = /* @__PURE__ */ new Map();
314
+ this.__captureEventListeners = /* @__PURE__ */ new Map();
315
+ }
316
+ addEventListener(type, callback, options) {
317
+ var _a13;
318
+ if (callback === void 0 || callback === null) {
319
+ return;
320
+ }
321
+ const eventListenersMap = isCaptureEventListener(options) ? this.__captureEventListeners : this.__eventListeners;
322
+ let eventListeners = eventListenersMap.get(type);
323
+ if (eventListeners === void 0) {
324
+ eventListeners = /* @__PURE__ */ new Map();
325
+ eventListenersMap.set(type, eventListeners);
326
+ } else if (eventListeners.has(callback)) {
327
+ return;
328
+ }
329
+ const normalizedOptions = typeof options === "object" && options ? options : {};
330
+ (_a13 = normalizedOptions.signal) == null ? void 0 : _a13.addEventListener("abort", () => this.removeEventListener(type, callback, options));
331
+ eventListeners.set(callback, normalizedOptions != null ? normalizedOptions : {});
332
+ }
333
+ removeEventListener(type, callback, options) {
334
+ if (callback === void 0 || callback === null) {
335
+ return;
336
+ }
337
+ const eventListenersMap = isCaptureEventListener(options) ? this.__captureEventListeners : this.__eventListeners;
338
+ const eventListeners = eventListenersMap.get(type);
339
+ if (eventListeners !== void 0) {
340
+ eventListeners.delete(callback);
341
+ if (!eventListeners.size) {
342
+ eventListenersMap.delete(type);
343
+ }
344
+ }
345
+ }
346
+ dispatchEvent(event) {
347
+ let composedPath = this.__resolveFullEventPath();
348
+ if (!event.composed && this.__host) {
349
+ composedPath = composedPath.slice(0, composedPath.indexOf(this.__host));
350
+ }
351
+ let stopPropagation = false;
352
+ let stopImmediatePropagation = false;
353
+ let eventPhase = EventShimWithRealType.NONE;
354
+ let target = null;
355
+ let tmpTarget = null;
356
+ let currentTarget = null;
357
+ const originalStopPropagation = event.stopPropagation;
358
+ const originalStopImmediatePropagation = event.stopImmediatePropagation;
359
+ Object.defineProperties(event, {
360
+ target: {
361
+ get() {
362
+ return target != null ? target : tmpTarget;
363
+ },
364
+ ...enumerableProperty2
365
+ },
366
+ srcElement: {
367
+ get() {
368
+ return event.target;
369
+ },
370
+ ...enumerableProperty2
371
+ },
372
+ currentTarget: {
373
+ get() {
374
+ return currentTarget;
375
+ },
376
+ ...enumerableProperty2
377
+ },
378
+ eventPhase: {
379
+ get() {
380
+ return eventPhase;
381
+ },
382
+ ...enumerableProperty2
383
+ },
384
+ composedPath: {
385
+ value: () => composedPath,
386
+ ...enumerableProperty2
387
+ },
388
+ stopPropagation: {
389
+ value: () => {
390
+ stopPropagation = true;
391
+ originalStopPropagation.call(event);
392
+ },
393
+ ...enumerableProperty2
394
+ },
395
+ stopImmediatePropagation: {
396
+ value: () => {
397
+ stopImmediatePropagation = true;
398
+ originalStopImmediatePropagation.call(event);
399
+ },
400
+ ...enumerableProperty2
401
+ }
402
+ });
403
+ const invokeEventListener = (listener, options, eventListenerMap) => {
404
+ if (typeof listener === "function") {
405
+ listener(event);
406
+ } else if (typeof (listener == null ? void 0 : listener.handleEvent) === "function") {
407
+ listener.handleEvent(event);
408
+ }
409
+ if (options.once) {
410
+ eventListenerMap.delete(listener);
411
+ }
412
+ };
413
+ const finishDispatch = () => {
414
+ currentTarget = null;
415
+ eventPhase = EventShimWithRealType.NONE;
416
+ return !event.defaultPrevented;
417
+ };
418
+ const captureEventPath = composedPath.slice().reverse();
419
+ target = !this.__host || !event.composed ? this : null;
420
+ const retarget = (eventTargets) => {
421
+ tmpTarget = this;
422
+ while (tmpTarget.__host && eventTargets.includes(tmpTarget.__host)) {
423
+ tmpTarget = tmpTarget.__host;
424
+ }
425
+ };
426
+ for (const eventTarget of captureEventPath) {
427
+ if (!target && (!tmpTarget || tmpTarget === eventTarget.__host)) {
428
+ retarget(captureEventPath.slice(captureEventPath.indexOf(eventTarget)));
429
+ }
430
+ currentTarget = eventTarget;
431
+ eventPhase = eventTarget === event.target ? EventShimWithRealType.AT_TARGET : EventShimWithRealType.CAPTURING_PHASE;
432
+ const captureEventListeners = eventTarget.__captureEventListeners.get(event.type);
433
+ if (captureEventListeners) {
434
+ for (const [listener, options] of captureEventListeners) {
435
+ invokeEventListener(listener, options, captureEventListeners);
436
+ if (stopImmediatePropagation) {
437
+ return finishDispatch();
438
+ }
439
+ }
440
+ }
441
+ if (stopPropagation) {
442
+ return finishDispatch();
443
+ }
444
+ }
445
+ const bubbleEventPath = event.bubbles ? composedPath : [this];
446
+ tmpTarget = null;
447
+ for (const eventTarget of bubbleEventPath) {
448
+ if (!target && (!tmpTarget || eventTarget === tmpTarget.__host)) {
449
+ retarget(bubbleEventPath.slice(0, bubbleEventPath.indexOf(eventTarget) + 1));
450
+ }
451
+ currentTarget = eventTarget;
452
+ eventPhase = eventTarget === event.target ? EventShimWithRealType.AT_TARGET : EventShimWithRealType.BUBBLING_PHASE;
453
+ const eventListeners = eventTarget.__eventListeners.get(event.type);
454
+ if (eventListeners) {
455
+ for (const [listener, options] of eventListeners) {
456
+ invokeEventListener(listener, options, eventListeners);
457
+ if (stopImmediatePropagation) {
458
+ return finishDispatch();
459
+ }
460
+ }
461
+ }
462
+ if (stopPropagation) {
463
+ return finishDispatch();
464
+ }
465
+ }
466
+ return finishDispatch();
467
+ }
468
+ __resolveFullEventPath() {
469
+ if (this.__eventPathCache) {
470
+ return this.__eventPathCache;
471
+ } else if (!this.__eventTargetParent) {
472
+ return this.__eventPathCache = [this, documentShim, windowShim];
473
+ } else {
474
+ return this.__eventPathCache = [
475
+ this,
476
+ ...this.__eventTargetParent.__resolveFullEventPath()
477
+ ];
478
+ }
479
+ }
480
+ };
481
+ var attributes = /* @__PURE__ */ new WeakMap();
482
+ var attributesForElement = (element) => {
483
+ let attrs = attributes.get(element);
484
+ if (attrs === void 0) {
485
+ attributes.set(element, attrs = /* @__PURE__ */ new Map());
486
+ }
487
+ return attrs;
488
+ };
489
+ var NodeShim = class Node extends EventTarget {
490
+ getRootNode(options) {
491
+ var _a13;
492
+ if (options == null ? void 0 : options.composed) {
493
+ return document2;
494
+ }
495
+ const host = this.__host;
496
+ return (_a13 = host == null ? void 0 : host.__shadowRoot) != null ? _a13 : document2;
497
+ }
498
+ };
499
+ var DocumentShim = class Document2 extends NodeShim {
500
+ get adoptedStyleSheets() {
501
+ return [];
502
+ }
503
+ createTreeWalker() {
504
+ return {};
505
+ }
506
+ createTextNode() {
507
+ return {};
508
+ }
509
+ createElement() {
510
+ return {};
511
+ }
512
+ };
513
+ var documentShim = new DocumentShim();
514
+ var document2 = documentShim;
515
+ var WindowShim = class Window extends NodeShim {
516
+ constructor(token) {
517
+ super();
518
+ if (token !== constructionToken) {
519
+ throw new TypeError("Illegal constructor");
520
+ }
521
+ Object.assign(this, globalThis, {
522
+ CustomElementRegistry,
523
+ customElements: customElements2,
524
+ document: document2,
525
+ Document: DocumentShim,
526
+ Element: ElementShim,
527
+ EventTarget,
528
+ HTMLElement: HTMLElementShim,
529
+ Node: NodeShim,
530
+ ShadowRoot: ShadowRootShim,
531
+ window: this,
532
+ Window: WindowShim
533
+ });
534
+ }
535
+ };
536
+ var ElementShim = class Element extends NodeShim {
537
+ constructor() {
538
+ super(...arguments);
539
+ this.__shadowRootMode = null;
540
+ this.__shadowRoot = null;
541
+ this.__internals = null;
542
+ }
543
+ get attributes() {
544
+ return Array.from(attributesForElement(this)).map(([name, value]) => ({
545
+ name,
546
+ value
547
+ }));
548
+ }
549
+ get shadowRoot() {
550
+ if (this.__shadowRootMode === "closed") {
551
+ return null;
552
+ }
553
+ return this.__shadowRoot;
554
+ }
555
+ get localName() {
556
+ return this.constructor.__localName;
557
+ }
558
+ get tagName() {
559
+ var _a13;
560
+ return (_a13 = this.localName) == null ? void 0 : _a13.toUpperCase();
561
+ }
562
+ setAttribute(name, value) {
563
+ attributesForElement(this).set(name, String(value));
564
+ }
565
+ removeAttribute(name) {
566
+ attributesForElement(this).delete(name);
567
+ }
568
+ toggleAttribute(name, force) {
569
+ if (this.hasAttribute(name)) {
570
+ if (force === void 0 || !force) {
571
+ this.removeAttribute(name);
572
+ return false;
573
+ }
574
+ } else {
575
+ if (force === void 0 || force) {
576
+ this.setAttribute(name, "");
577
+ return true;
578
+ } else {
579
+ return false;
580
+ }
581
+ }
582
+ return true;
583
+ }
584
+ hasAttribute(name) {
585
+ return attributesForElement(this).has(name);
586
+ }
587
+ attachShadow(init) {
588
+ this.__shadowRootMode = init.mode;
589
+ const shadowRoot = new ShadowRootShim(constructionToken, init);
590
+ shadowRoot.__eventTargetParent = this;
591
+ shadowRoot.__host = this;
592
+ return this.__shadowRoot = shadowRoot;
593
+ }
594
+ attachInternals() {
595
+ if (this.__internals !== null) {
596
+ throw new Error(`Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);
597
+ }
598
+ const internals = new ElementInternalsShim(this);
599
+ this.__internals = internals;
600
+ return internals;
601
+ }
602
+ getAttribute(name) {
603
+ const value = attributesForElement(this).get(name);
604
+ return value != null ? value : null;
605
+ }
606
+ };
607
+ var HTMLElementShim = class HTMLElement2 extends ElementShim {
608
+ };
609
+ var HTMLElementShimWithRealType = HTMLElementShim;
610
+ var ShadowRootShim = class ShadowRoot extends NodeShim {
611
+ get host() {
612
+ return this.__host;
613
+ }
614
+ constructor(constructionToken2, init) {
615
+ super();
616
+ if (constructionToken2 !== constructionToken2) {
617
+ throw new TypeError("Illegal constructor");
618
+ }
619
+ this.mode = init.mode;
620
+ }
621
+ };
622
+ var _a5;
623
+ (_a5 = globalThis.litServerRoot) != null ? _a5 : globalThis.litServerRoot = Object.defineProperty(new HTMLElementShimWithRealType(), "localName", {
624
+ // Patch localName (and tagName) to return a unique name.
625
+ get() {
626
+ return "lit-server-root";
627
+ }
628
+ });
629
+ function promiseWithResolvers() {
630
+ let resolve;
631
+ let reject;
632
+ const promise = new Promise((res, rej) => {
633
+ resolve = res;
634
+ reject = rej;
635
+ });
636
+ return { promise, resolve, reject };
637
+ }
638
+ var CustomElementRegistry = class {
639
+ constructor() {
640
+ this.__definitions = /* @__PURE__ */ new Map();
641
+ this.__reverseDefinitions = /* @__PURE__ */ new Map();
642
+ this.__pendingWhenDefineds = /* @__PURE__ */ new Map();
643
+ }
644
+ define(name, ctor) {
645
+ var _a13, _b3;
646
+ if (this.__definitions.has(name)) {
647
+ if (process.env.NODE_ENV === "development") {
648
+ console.warn(`'CustomElementRegistry' already has "${name}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
649
+ Make sure to test your application with a production build as repeat registrations will throw in production.`);
650
+ } else {
651
+ throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${name}" has already been used with this registry`);
652
+ }
653
+ }
654
+ if (this.__reverseDefinitions.has(ctor)) {
655
+ throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(ctor)}`);
656
+ }
657
+ ctor.__localName = name;
658
+ this.__definitions.set(name, {
659
+ ctor,
660
+ // Note it's important we read `observedAttributes` in case it is a getter
661
+ // with side-effects, as is the case in Lit, where it triggers class
662
+ // finalization.
663
+ //
664
+ // TODO(aomarks) To be spec compliant, we should also capture the
665
+ // registration-time lifecycle methods like `connectedCallback`. For them
666
+ // to be actually accessible to e.g. the Lit SSR element renderer, though,
667
+ // we'd need to introduce a new API for accessing them (since `get` only
668
+ // returns the constructor).
669
+ observedAttributes: (_a13 = ctor.observedAttributes) != null ? _a13 : []
670
+ });
671
+ this.__reverseDefinitions.set(ctor, name);
672
+ (_b3 = this.__pendingWhenDefineds.get(name)) == null ? void 0 : _b3.resolve(ctor);
673
+ this.__pendingWhenDefineds.delete(name);
674
+ }
675
+ get(name) {
676
+ const definition = this.__definitions.get(name);
677
+ return definition == null ? void 0 : definition.ctor;
678
+ }
679
+ getName(ctor) {
680
+ var _a13;
681
+ return (_a13 = this.__reverseDefinitions.get(ctor)) != null ? _a13 : null;
682
+ }
683
+ initialize(_root) {
684
+ throw new Error(`customElements.initialize is not currently supported in SSR. Please file a bug if you need it.`);
685
+ }
686
+ upgrade(_element) {
687
+ throw new Error(`customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.`);
688
+ }
689
+ async whenDefined(name) {
690
+ const definition = this.__definitions.get(name);
691
+ if (definition) {
692
+ return definition.ctor;
693
+ }
694
+ let withResolvers = this.__pendingWhenDefineds.get(name);
695
+ if (!withResolvers) {
696
+ withResolvers = promiseWithResolvers();
697
+ this.__pendingWhenDefineds.set(name, withResolvers);
698
+ }
699
+ return withResolvers.promise;
700
+ }
701
+ };
702
+ var CustomElementRegistryShimWithRealType = CustomElementRegistry;
703
+ var customElements2 = new CustomElementRegistryShimWithRealType();
704
+ var windowShim = new WindowShim(constructionToken);
705
+
706
+ // ../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/node/css-tag.js
707
+ var t = globalThis;
708
+ var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
709
+ var s = Symbol();
710
+ var o = /* @__PURE__ */ new WeakMap();
711
+ var n = class {
712
+ constructor(t5, e6, o9) {
713
+ if (this._$cssResult$ = true, o9 !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
714
+ this.cssText = t5, this.t = e6;
715
+ }
716
+ get styleSheet() {
717
+ let t5 = this.o;
718
+ const s6 = this.t;
719
+ if (e && void 0 === t5) {
720
+ const e6 = void 0 !== s6 && 1 === s6.length;
721
+ e6 && (t5 = o.get(s6)), void 0 === t5 && ((this.o = t5 = new CSSStyleSheet()).replaceSync(this.cssText), e6 && o.set(s6, t5));
722
+ }
723
+ return t5;
724
+ }
725
+ toString() {
726
+ return this.cssText;
727
+ }
728
+ };
729
+ var r = (t5) => new n("string" == typeof t5 ? t5 : t5 + "", void 0, s);
730
+ var i = (t5, ...e6) => {
731
+ const o9 = 1 === t5.length ? t5[0] : e6.reduce((e7, s6, o10) => e7 + ((t6) => {
732
+ if (true === t6._$cssResult$) return t6.cssText;
733
+ if ("number" == typeof t6) return t6;
734
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + t6 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
735
+ })(s6) + t5[o10 + 1], t5[0]);
736
+ return new n(o9, t5, s);
737
+ };
738
+ var S = (s6, o9) => {
739
+ if (e) s6.adoptedStyleSheets = o9.map((t5) => t5 instanceof CSSStyleSheet ? t5 : t5.styleSheet);
740
+ else for (const e6 of o9) {
741
+ const o10 = document.createElement("style"), n7 = t.litNonce;
742
+ void 0 !== n7 && o10.setAttribute("nonce", n7), o10.textContent = e6.cssText, s6.appendChild(o10);
743
+ }
744
+ };
745
+ var c = e || void 0 === t.CSSStyleSheet ? (t5) => t5 : (t5) => t5 instanceof CSSStyleSheet ? ((t6) => {
746
+ let e6 = "";
747
+ for (const s6 of t6.cssRules) e6 += s6.cssText;
748
+ return r(e6);
749
+ })(t5) : t5;
750
+
751
+ // ../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/node/reactive-element.js
752
+ var { is: h, defineProperty: r2, getOwnPropertyDescriptor: o2, getOwnPropertyNames: n2, getOwnPropertySymbols: a, getPrototypeOf: c2 } = Object;
753
+ var l = globalThis;
754
+ var _a6;
755
+ (_a6 = l.customElements) != null ? _a6 : l.customElements = customElements2;
756
+ var p = l.trustedTypes;
757
+ var d = p ? p.emptyScript : "";
758
+ var u = l.reactiveElementPolyfillSupport;
759
+ var f = (t5, s6) => t5;
760
+ var b = { toAttribute(t5, s6) {
761
+ switch (s6) {
762
+ case Boolean:
763
+ t5 = t5 ? d : null;
764
+ break;
765
+ case Object:
766
+ case Array:
767
+ t5 = null == t5 ? t5 : JSON.stringify(t5);
768
+ }
769
+ return t5;
770
+ }, fromAttribute(t5, s6) {
771
+ let i7 = t5;
772
+ switch (s6) {
773
+ case Boolean:
774
+ i7 = null !== t5;
775
+ break;
776
+ case Number:
777
+ i7 = null === t5 ? null : Number(t5);
778
+ break;
779
+ case Object:
780
+ case Array:
781
+ try {
782
+ i7 = JSON.parse(t5);
783
+ } catch (t6) {
784
+ i7 = null;
785
+ }
786
+ }
787
+ return i7;
788
+ } };
789
+ var m = (t5, s6) => !h(t5, s6);
790
+ var y = { attribute: true, type: String, converter: b, reflect: false, useDefault: false, hasChanged: m };
791
+ var _a7, _b2;
792
+ (_a7 = Symbol.metadata) != null ? _a7 : Symbol.metadata = Symbol("metadata"), (_b2 = l.litPropertyMetadata) != null ? _b2 : l.litPropertyMetadata = /* @__PURE__ */ new WeakMap();
793
+ var _a8;
794
+ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElementShimWithRealType) {
795
+ static addInitializer(t5) {
796
+ var _a13;
797
+ this._$Ei(), ((_a13 = this.l) != null ? _a13 : this.l = []).push(t5);
798
+ }
799
+ static get observedAttributes() {
800
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
801
+ }
802
+ static createProperty(t5, s6 = y) {
803
+ if (s6.state && (s6.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t5) && ((s6 = Object.create(s6)).wrapped = true), this.elementProperties.set(t5, s6), !s6.noAccessor) {
804
+ const i7 = Symbol(), e6 = this.getPropertyDescriptor(t5, i7, s6);
805
+ void 0 !== e6 && r2(this.prototype, t5, e6);
806
+ }
807
+ }
808
+ static getPropertyDescriptor(t5, s6, i7) {
809
+ var _a13;
810
+ const { get: e6, set: h6 } = (_a13 = o2(this.prototype, t5)) != null ? _a13 : { get() {
811
+ return this[s6];
812
+ }, set(t6) {
813
+ this[s6] = t6;
814
+ } };
815
+ return { get: e6, set(s7) {
816
+ const r6 = e6 == null ? void 0 : e6.call(this);
817
+ h6 == null ? void 0 : h6.call(this, s7), this.requestUpdate(t5, r6, i7);
818
+ }, configurable: true, enumerable: true };
819
+ }
820
+ static getPropertyOptions(t5) {
821
+ var _a13;
822
+ return (_a13 = this.elementProperties.get(t5)) != null ? _a13 : y;
823
+ }
824
+ static _$Ei() {
825
+ if (this.hasOwnProperty(f("elementProperties"))) return;
826
+ const t5 = c2(this);
827
+ t5.finalize(), void 0 !== t5.l && (this.l = [...t5.l]), this.elementProperties = new Map(t5.elementProperties);
828
+ }
829
+ static finalize() {
830
+ if (this.hasOwnProperty(f("finalized"))) return;
831
+ if (this.finalized = true, this._$Ei(), this.hasOwnProperty(f("properties"))) {
832
+ const t6 = this.properties, s6 = [...n2(t6), ...a(t6)];
833
+ for (const i7 of s6) this.createProperty(i7, t6[i7]);
834
+ }
835
+ const t5 = this[Symbol.metadata];
836
+ if (null !== t5) {
837
+ const s6 = litPropertyMetadata.get(t5);
838
+ if (void 0 !== s6) for (const [t6, i7] of s6) this.elementProperties.set(t6, i7);
839
+ }
840
+ this._$Eh = /* @__PURE__ */ new Map();
841
+ for (const [t6, s6] of this.elementProperties) {
842
+ const i7 = this._$Eu(t6, s6);
843
+ void 0 !== i7 && this._$Eh.set(i7, t6);
844
+ }
845
+ this.elementStyles = this.finalizeStyles(this.styles);
846
+ }
847
+ static finalizeStyles(t5) {
848
+ const s6 = [];
849
+ if (Array.isArray(t5)) {
850
+ const e6 = new Set(t5.flat(1 / 0).reverse());
851
+ for (const t6 of e6) s6.unshift(c(t6));
852
+ } else void 0 !== t5 && s6.push(c(t5));
853
+ return s6;
854
+ }
855
+ static _$Eu(t5, s6) {
856
+ const i7 = s6.attribute;
857
+ return false === i7 ? void 0 : "string" == typeof i7 ? i7 : "string" == typeof t5 ? t5.toLowerCase() : void 0;
858
+ }
859
+ constructor() {
860
+ super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
861
+ }
862
+ _$Ev() {
863
+ var _a13;
864
+ this._$ES = new Promise((t5) => this.enableUpdating = t5), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (_a13 = this.constructor.l) == null ? void 0 : _a13.forEach((t5) => t5(this));
865
+ }
866
+ addController(t5) {
867
+ var _a13, _b3;
868
+ ((_a13 = this._$EO) != null ? _a13 : this._$EO = /* @__PURE__ */ new Set()).add(t5), void 0 !== this.renderRoot && this.isConnected && ((_b3 = t5.hostConnected) == null ? void 0 : _b3.call(t5));
869
+ }
870
+ removeController(t5) {
871
+ var _a13;
872
+ (_a13 = this._$EO) == null ? void 0 : _a13.delete(t5);
873
+ }
874
+ _$E_() {
875
+ const t5 = /* @__PURE__ */ new Map(), s6 = this.constructor.elementProperties;
876
+ for (const i7 of s6.keys()) this.hasOwnProperty(i7) && (t5.set(i7, this[i7]), delete this[i7]);
877
+ t5.size > 0 && (this._$Ep = t5);
878
+ }
879
+ createRenderRoot() {
880
+ var _a13;
881
+ const t5 = (_a13 = this.shadowRoot) != null ? _a13 : this.attachShadow(this.constructor.shadowRootOptions);
882
+ return S(t5, this.constructor.elementStyles), t5;
883
+ }
884
+ connectedCallback() {
885
+ var _a13, _b3;
886
+ (_a13 = this.renderRoot) != null ? _a13 : this.renderRoot = this.createRenderRoot(), this.enableUpdating(true), (_b3 = this._$EO) == null ? void 0 : _b3.forEach((t5) => {
887
+ var _a14;
888
+ return (_a14 = t5.hostConnected) == null ? void 0 : _a14.call(t5);
889
+ });
890
+ }
891
+ enableUpdating(t5) {
892
+ }
893
+ disconnectedCallback() {
894
+ var _a13;
895
+ (_a13 = this._$EO) == null ? void 0 : _a13.forEach((t5) => {
896
+ var _a14;
897
+ return (_a14 = t5.hostDisconnected) == null ? void 0 : _a14.call(t5);
898
+ });
899
+ }
900
+ attributeChangedCallback(t5, s6, i7) {
901
+ this._$AK(t5, i7);
902
+ }
903
+ _$ET(t5, s6) {
904
+ var _a13;
905
+ const i7 = this.constructor.elementProperties.get(t5), e6 = this.constructor._$Eu(t5, i7);
906
+ if (void 0 !== e6 && true === i7.reflect) {
907
+ const h6 = (void 0 !== ((_a13 = i7.converter) == null ? void 0 : _a13.toAttribute) ? i7.converter : b).toAttribute(s6, i7.type);
908
+ this._$Em = t5, null == h6 ? this.removeAttribute(e6) : this.setAttribute(e6, h6), this._$Em = null;
909
+ }
910
+ }
911
+ _$AK(t5, s6) {
912
+ var _a13, _b3, _c;
913
+ const i7 = this.constructor, e6 = i7._$Eh.get(t5);
914
+ if (void 0 !== e6 && this._$Em !== e6) {
915
+ const t6 = i7.getPropertyOptions(e6), h6 = "function" == typeof t6.converter ? { fromAttribute: t6.converter } : void 0 !== ((_a13 = t6.converter) == null ? void 0 : _a13.fromAttribute) ? t6.converter : b;
916
+ this._$Em = e6;
917
+ const r6 = h6.fromAttribute(s6, t6.type);
918
+ this[e6] = (_c = r6 != null ? r6 : (_b3 = this._$Ej) == null ? void 0 : _b3.get(e6)) != null ? _c : r6, this._$Em = null;
919
+ }
920
+ }
921
+ requestUpdate(t5, s6, i7, e6 = false, h6) {
922
+ var _a13, _b3;
923
+ if (void 0 !== t5) {
924
+ const r6 = this.constructor;
925
+ if (false === e6 && (h6 = this[t5]), i7 != null ? i7 : i7 = r6.getPropertyOptions(t5), !(((_a13 = i7.hasChanged) != null ? _a13 : m)(h6, s6) || i7.useDefault && i7.reflect && h6 === ((_b3 = this._$Ej) == null ? void 0 : _b3.get(t5)) && !this.hasAttribute(r6._$Eu(t5, i7)))) return;
926
+ this.C(t5, s6, i7);
927
+ }
928
+ false === this.isUpdatePending && (this._$ES = this._$EP());
929
+ }
930
+ C(t5, s6, { useDefault: i7, reflect: e6, wrapped: h6 }, r6) {
931
+ var _a13, _b3, _c;
932
+ i7 && !((_a13 = this._$Ej) != null ? _a13 : this._$Ej = /* @__PURE__ */ new Map()).has(t5) && (this._$Ej.set(t5, (_b3 = r6 != null ? r6 : s6) != null ? _b3 : this[t5]), true !== h6 || void 0 !== r6) || (this._$AL.has(t5) || (this.hasUpdated || i7 || (s6 = void 0), this._$AL.set(t5, s6)), true === e6 && this._$Em !== t5 && ((_c = this._$Eq) != null ? _c : this._$Eq = /* @__PURE__ */ new Set()).add(t5));
933
+ }
934
+ async _$EP() {
935
+ this.isUpdatePending = true;
936
+ try {
937
+ await this._$ES;
938
+ } catch (t6) {
939
+ Promise.reject(t6);
940
+ }
941
+ const t5 = this.scheduleUpdate();
942
+ return null != t5 && await t5, !this.isUpdatePending;
943
+ }
944
+ scheduleUpdate() {
945
+ return this.performUpdate();
946
+ }
947
+ performUpdate() {
948
+ var _a13, _b3;
949
+ if (!this.isUpdatePending) return;
950
+ if (!this.hasUpdated) {
951
+ if ((_a13 = this.renderRoot) != null ? _a13 : this.renderRoot = this.createRenderRoot(), this._$Ep) {
952
+ for (const [t7, s7] of this._$Ep) this[t7] = s7;
953
+ this._$Ep = void 0;
954
+ }
955
+ const t6 = this.constructor.elementProperties;
956
+ if (t6.size > 0) for (const [s7, i7] of t6) {
957
+ const { wrapped: t7 } = i7, e6 = this[s7];
958
+ true !== t7 || this._$AL.has(s7) || void 0 === e6 || this.C(s7, void 0, i7, e6);
959
+ }
960
+ }
961
+ let t5 = false;
962
+ const s6 = this._$AL;
963
+ try {
964
+ t5 = this.shouldUpdate(s6), t5 ? (this.willUpdate(s6), (_b3 = this._$EO) == null ? void 0 : _b3.forEach((t6) => {
965
+ var _a14;
966
+ return (_a14 = t6.hostUpdate) == null ? void 0 : _a14.call(t6);
967
+ }), this.update(s6)) : this._$EM();
968
+ } catch (s7) {
969
+ throw t5 = false, this._$EM(), s7;
970
+ }
971
+ t5 && this._$AE(s6);
972
+ }
973
+ willUpdate(t5) {
974
+ }
975
+ _$AE(t5) {
976
+ var _a13;
977
+ (_a13 = this._$EO) == null ? void 0 : _a13.forEach((t6) => {
978
+ var _a14;
979
+ return (_a14 = t6.hostUpdated) == null ? void 0 : _a14.call(t6);
980
+ }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t5)), this.updated(t5);
981
+ }
982
+ _$EM() {
983
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
984
+ }
985
+ get updateComplete() {
986
+ return this.getUpdateComplete();
987
+ }
988
+ getUpdateComplete() {
989
+ return this._$ES;
990
+ }
991
+ shouldUpdate(t5) {
992
+ return true;
993
+ }
994
+ update(t5) {
995
+ this._$Eq && (this._$Eq = this._$Eq.forEach((t6) => this._$ET(t6, this[t6]))), this._$EM();
996
+ }
997
+ updated(t5) {
998
+ }
999
+ firstUpdated(t5) {
1000
+ }
1001
+ };
1002
+ var _a9;
1003
+ g.elementStyles = [], g.shadowRootOptions = { mode: "open" }, g[f("elementProperties")] = /* @__PURE__ */ new Map(), g[f("finalized")] = /* @__PURE__ */ new Map(), u == null ? void 0 : u({ ReactiveElement: g }), ((_a9 = l.reactiveElementVersions) != null ? _a9 : l.reactiveElementVersions = []).push("2.1.2");
1004
+
1005
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/lit-html.js
1006
+ var t2 = globalThis;
1007
+ var i2 = (t5) => t5;
1008
+ var s2 = t2.trustedTypes;
1009
+ var e2 = s2 ? s2.createPolicy("lit-html", { createHTML: (t5) => t5 }) : void 0;
1010
+ var h2 = "$lit$";
1011
+ var o3 = `lit$${Math.random().toFixed(9).slice(2)}$`;
1012
+ var n3 = "?" + o3;
1013
+ var r3 = `<${n3}>`;
1014
+ var l2 = void 0 === t2.document ? { createTreeWalker: () => ({}) } : document;
1015
+ var c3 = () => l2.createComment("");
1016
+ var a2 = (t5) => null === t5 || "object" != typeof t5 && "function" != typeof t5;
1017
+ var u2 = Array.isArray;
1018
+ var d2 = (t5) => u2(t5) || "function" == typeof (t5 == null ? void 0 : t5[Symbol.iterator]);
1019
+ var f2 = "[ \n\f\r]";
1020
+ var v = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
1021
+ var _ = /-->/g;
1022
+ var m2 = />/g;
1023
+ var p2 = RegExp(`>|${f2}(?:([^\\s"'>=/]+)(${f2}*=${f2}*(?:[^
1024
+ \f\r"'\`<>=]|("|')|))|$)`, "g");
1025
+ var g2 = /'/g;
1026
+ var $ = /"/g;
1027
+ var y2 = /^(?:script|style|textarea|title)$/i;
1028
+ var x = (t5) => (i7, ...s6) => ({ _$litType$: t5, strings: i7, values: s6 });
1029
+ var T = x(1);
1030
+ var b2 = x(2);
1031
+ var w = x(3);
1032
+ var E = Symbol.for("lit-noChange");
1033
+ var A = Symbol.for("lit-nothing");
1034
+ var C = /* @__PURE__ */ new WeakMap();
1035
+ var P = l2.createTreeWalker(l2, 129);
1036
+ function V(t5, i7) {
1037
+ if (!u2(t5) || !t5.hasOwnProperty("raw")) throw Error("invalid template strings array");
1038
+ return void 0 !== e2 ? e2.createHTML(i7) : i7;
1039
+ }
1040
+ var N = (t5, i7) => {
1041
+ const s6 = t5.length - 1, e6 = [];
1042
+ let n7, l3 = 2 === i7 ? "<svg>" : 3 === i7 ? "<math>" : "", c6 = v;
1043
+ for (let i8 = 0; i8 < s6; i8++) {
1044
+ const s7 = t5[i8];
1045
+ let a3, u5, d3 = -1, f4 = 0;
1046
+ for (; f4 < s7.length && (c6.lastIndex = f4, u5 = c6.exec(s7), null !== u5); ) f4 = c6.lastIndex, c6 === v ? "!--" === u5[1] ? c6 = _ : void 0 !== u5[1] ? c6 = m2 : void 0 !== u5[2] ? (y2.test(u5[2]) && (n7 = RegExp("</" + u5[2], "g")), c6 = p2) : void 0 !== u5[3] && (c6 = p2) : c6 === p2 ? ">" === u5[0] ? (c6 = n7 != null ? n7 : v, d3 = -1) : void 0 === u5[1] ? d3 = -2 : (d3 = c6.lastIndex - u5[2].length, a3 = u5[1], c6 = void 0 === u5[3] ? p2 : '"' === u5[3] ? $ : g2) : c6 === $ || c6 === g2 ? c6 = p2 : c6 === _ || c6 === m2 ? c6 = v : (c6 = p2, n7 = void 0);
1047
+ const x2 = c6 === p2 && t5[i8 + 1].startsWith("/>") ? " " : "";
1048
+ l3 += c6 === v ? s7 + r3 : d3 >= 0 ? (e6.push(a3), s7.slice(0, d3) + h2 + s7.slice(d3) + o3 + x2) : s7 + o3 + (-2 === d3 ? i8 : x2);
1049
+ }
1050
+ return [V(t5, l3 + (t5[s6] || "<?>") + (2 === i7 ? "</svg>" : 3 === i7 ? "</math>" : "")), e6];
1051
+ };
1052
+ var S2 = class _S {
1053
+ constructor({ strings: t5, _$litType$: i7 }, e6) {
1054
+ let r6;
1055
+ this.parts = [];
1056
+ let l3 = 0, a3 = 0;
1057
+ const u5 = t5.length - 1, d3 = this.parts, [f4, v3] = N(t5, i7);
1058
+ if (this.el = _S.createElement(f4, e6), P.currentNode = this.el.content, 2 === i7 || 3 === i7) {
1059
+ const t6 = this.el.content.firstChild;
1060
+ t6.replaceWith(...t6.childNodes);
1061
+ }
1062
+ for (; null !== (r6 = P.nextNode()) && d3.length < u5; ) {
1063
+ if (1 === r6.nodeType) {
1064
+ if (r6.hasAttributes()) for (const t6 of r6.getAttributeNames()) if (t6.endsWith(h2)) {
1065
+ const i8 = v3[a3++], s6 = r6.getAttribute(t6).split(o3), e7 = /([.?@])?(.*)/.exec(i8);
1066
+ d3.push({ type: 1, index: l3, name: e7[2], strings: s6, ctor: "." === e7[1] ? I : "?" === e7[1] ? L : "@" === e7[1] ? z : H }), r6.removeAttribute(t6);
1067
+ } else t6.startsWith(o3) && (d3.push({ type: 6, index: l3 }), r6.removeAttribute(t6));
1068
+ if (y2.test(r6.tagName)) {
1069
+ const t6 = r6.textContent.split(o3), i8 = t6.length - 1;
1070
+ if (i8 > 0) {
1071
+ r6.textContent = s2 ? s2.emptyScript : "";
1072
+ for (let s6 = 0; s6 < i8; s6++) r6.append(t6[s6], c3()), P.nextNode(), d3.push({ type: 2, index: ++l3 });
1073
+ r6.append(t6[i8], c3());
1074
+ }
1075
+ }
1076
+ } else if (8 === r6.nodeType) if (r6.data === n3) d3.push({ type: 2, index: l3 });
1077
+ else {
1078
+ let t6 = -1;
1079
+ for (; -1 !== (t6 = r6.data.indexOf(o3, t6 + 1)); ) d3.push({ type: 7, index: l3 }), t6 += o3.length - 1;
1080
+ }
1081
+ l3++;
1082
+ }
1083
+ }
1084
+ static createElement(t5, i7) {
1085
+ const s6 = l2.createElement("template");
1086
+ return s6.innerHTML = t5, s6;
1087
+ }
1088
+ };
1089
+ function M(t5, i7, s6 = t5, e6) {
1090
+ var _a13, _b3, _c;
1091
+ if (i7 === E) return i7;
1092
+ let h6 = void 0 !== e6 ? (_a13 = s6._$Co) == null ? void 0 : _a13[e6] : s6._$Cl;
1093
+ const o9 = a2(i7) ? void 0 : i7._$litDirective$;
1094
+ return (h6 == null ? void 0 : h6.constructor) !== o9 && ((_b3 = h6 == null ? void 0 : h6._$AO) == null ? void 0 : _b3.call(h6, false), void 0 === o9 ? h6 = void 0 : (h6 = new o9(t5), h6._$AT(t5, s6, e6)), void 0 !== e6 ? ((_c = s6._$Co) != null ? _c : s6._$Co = [])[e6] = h6 : s6._$Cl = h6), void 0 !== h6 && (i7 = M(t5, h6._$AS(t5, i7.values), h6, e6)), i7;
1095
+ }
1096
+ var k = class {
1097
+ constructor(t5, i7) {
1098
+ this._$AV = [], this._$AN = void 0, this._$AD = t5, this._$AM = i7;
1099
+ }
1100
+ get parentNode() {
1101
+ return this._$AM.parentNode;
1102
+ }
1103
+ get _$AU() {
1104
+ return this._$AM._$AU;
1105
+ }
1106
+ u(t5) {
1107
+ var _a13;
1108
+ const { el: { content: i7 }, parts: s6 } = this._$AD, e6 = ((_a13 = t5 == null ? void 0 : t5.creationScope) != null ? _a13 : l2).importNode(i7, true);
1109
+ P.currentNode = e6;
1110
+ let h6 = P.nextNode(), o9 = 0, n7 = 0, r6 = s6[0];
1111
+ for (; void 0 !== r6; ) {
1112
+ if (o9 === r6.index) {
1113
+ let i8;
1114
+ 2 === r6.type ? i8 = new R(h6, h6.nextSibling, this, t5) : 1 === r6.type ? i8 = new r6.ctor(h6, r6.name, r6.strings, this, t5) : 6 === r6.type && (i8 = new W(h6, this, t5)), this._$AV.push(i8), r6 = s6[++n7];
1115
+ }
1116
+ o9 !== (r6 == null ? void 0 : r6.index) && (h6 = P.nextNode(), o9++);
1117
+ }
1118
+ return P.currentNode = l2, e6;
1119
+ }
1120
+ p(t5) {
1121
+ let i7 = 0;
1122
+ for (const s6 of this._$AV) void 0 !== s6 && (void 0 !== s6.strings ? (s6._$AI(t5, s6, i7), i7 += s6.strings.length - 2) : s6._$AI(t5[i7])), i7++;
1123
+ }
1124
+ };
1125
+ var R = class _R {
1126
+ get _$AU() {
1127
+ var _a13, _b3;
1128
+ return (_b3 = (_a13 = this._$AM) == null ? void 0 : _a13._$AU) != null ? _b3 : this._$Cv;
1129
+ }
1130
+ constructor(t5, i7, s6, e6) {
1131
+ var _a13;
1132
+ this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t5, this._$AB = i7, this._$AM = s6, this.options = e6, this._$Cv = (_a13 = e6 == null ? void 0 : e6.isConnected) != null ? _a13 : true;
1133
+ }
1134
+ get parentNode() {
1135
+ let t5 = this._$AA.parentNode;
1136
+ const i7 = this._$AM;
1137
+ return void 0 !== i7 && 11 === (t5 == null ? void 0 : t5.nodeType) && (t5 = i7.parentNode), t5;
1138
+ }
1139
+ get startNode() {
1140
+ return this._$AA;
1141
+ }
1142
+ get endNode() {
1143
+ return this._$AB;
1144
+ }
1145
+ _$AI(t5, i7 = this) {
1146
+ t5 = M(this, t5, i7), a2(t5) ? t5 === A || null == t5 || "" === t5 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t5 !== this._$AH && t5 !== E && this._(t5) : void 0 !== t5._$litType$ ? this.$(t5) : void 0 !== t5.nodeType ? this.T(t5) : d2(t5) ? this.k(t5) : this._(t5);
1147
+ }
1148
+ O(t5) {
1149
+ return this._$AA.parentNode.insertBefore(t5, this._$AB);
1150
+ }
1151
+ T(t5) {
1152
+ this._$AH !== t5 && (this._$AR(), this._$AH = this.O(t5));
1153
+ }
1154
+ _(t5) {
1155
+ this._$AH !== A && a2(this._$AH) ? this._$AA.nextSibling.data = t5 : this.T(l2.createTextNode(t5)), this._$AH = t5;
1156
+ }
1157
+ $(t5) {
1158
+ var _a13;
1159
+ const { values: i7, _$litType$: s6 } = t5, e6 = "number" == typeof s6 ? this._$AC(t5) : (void 0 === s6.el && (s6.el = S2.createElement(V(s6.h, s6.h[0]), this.options)), s6);
1160
+ if (((_a13 = this._$AH) == null ? void 0 : _a13._$AD) === e6) this._$AH.p(i7);
1161
+ else {
1162
+ const t6 = new k(e6, this), s7 = t6.u(this.options);
1163
+ t6.p(i7), this.T(s7), this._$AH = t6;
1164
+ }
1165
+ }
1166
+ _$AC(t5) {
1167
+ let i7 = C.get(t5.strings);
1168
+ return void 0 === i7 && C.set(t5.strings, i7 = new S2(t5)), i7;
1169
+ }
1170
+ k(t5) {
1171
+ u2(this._$AH) || (this._$AH = [], this._$AR());
1172
+ const i7 = this._$AH;
1173
+ let s6, e6 = 0;
1174
+ for (const h6 of t5) e6 === i7.length ? i7.push(s6 = new _R(this.O(c3()), this.O(c3()), this, this.options)) : s6 = i7[e6], s6._$AI(h6), e6++;
1175
+ e6 < i7.length && (this._$AR(s6 && s6._$AB.nextSibling, e6), i7.length = e6);
1176
+ }
1177
+ _$AR(t5 = this._$AA.nextSibling, s6) {
1178
+ var _a13;
1179
+ for ((_a13 = this._$AP) == null ? void 0 : _a13.call(this, false, true, s6); t5 !== this._$AB; ) {
1180
+ const s7 = i2(t5).nextSibling;
1181
+ i2(t5).remove(), t5 = s7;
1182
+ }
1183
+ }
1184
+ setConnected(t5) {
1185
+ var _a13;
1186
+ void 0 === this._$AM && (this._$Cv = t5, (_a13 = this._$AP) == null ? void 0 : _a13.call(this, t5));
1187
+ }
1188
+ };
1189
+ var H = class {
1190
+ get tagName() {
1191
+ return this.element.tagName;
1192
+ }
1193
+ get _$AU() {
1194
+ return this._$AM._$AU;
1195
+ }
1196
+ constructor(t5, i7, s6, e6, h6) {
1197
+ this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t5, this.name = i7, this._$AM = e6, this.options = h6, s6.length > 2 || "" !== s6[0] || "" !== s6[1] ? (this._$AH = Array(s6.length - 1).fill(new String()), this.strings = s6) : this._$AH = A;
1198
+ }
1199
+ _$AI(t5, i7 = this, s6, e6) {
1200
+ const h6 = this.strings;
1201
+ let o9 = false;
1202
+ if (void 0 === h6) t5 = M(this, t5, i7, 0), o9 = !a2(t5) || t5 !== this._$AH && t5 !== E, o9 && (this._$AH = t5);
1203
+ else {
1204
+ const e7 = t5;
1205
+ let n7, r6;
1206
+ for (t5 = h6[0], n7 = 0; n7 < h6.length - 1; n7++) r6 = M(this, e7[s6 + n7], i7, n7), r6 === E && (r6 = this._$AH[n7]), o9 || (o9 = !a2(r6) || r6 !== this._$AH[n7]), r6 === A ? t5 = A : t5 !== A && (t5 += (r6 != null ? r6 : "") + h6[n7 + 1]), this._$AH[n7] = r6;
1207
+ }
1208
+ o9 && !e6 && this.j(t5);
1209
+ }
1210
+ j(t5) {
1211
+ t5 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t5 != null ? t5 : "");
1212
+ }
1213
+ };
1214
+ var I = class extends H {
1215
+ constructor() {
1216
+ super(...arguments), this.type = 3;
1217
+ }
1218
+ j(t5) {
1219
+ this.element[this.name] = t5 === A ? void 0 : t5;
1220
+ }
1221
+ };
1222
+ var L = class extends H {
1223
+ constructor() {
1224
+ super(...arguments), this.type = 4;
1225
+ }
1226
+ j(t5) {
1227
+ this.element.toggleAttribute(this.name, !!t5 && t5 !== A);
1228
+ }
1229
+ };
1230
+ var z = class extends H {
1231
+ constructor(t5, i7, s6, e6, h6) {
1232
+ super(t5, i7, s6, e6, h6), this.type = 5;
1233
+ }
1234
+ _$AI(t5, i7 = this) {
1235
+ var _a13;
1236
+ if ((t5 = (_a13 = M(this, t5, i7, 0)) != null ? _a13 : A) === E) return;
1237
+ const s6 = this._$AH, e6 = t5 === A && s6 !== A || t5.capture !== s6.capture || t5.once !== s6.once || t5.passive !== s6.passive, h6 = t5 !== A && (s6 === A || e6);
1238
+ e6 && this.element.removeEventListener(this.name, this, s6), h6 && this.element.addEventListener(this.name, this, t5), this._$AH = t5;
1239
+ }
1240
+ handleEvent(t5) {
1241
+ var _a13, _b3;
1242
+ "function" == typeof this._$AH ? this._$AH.call((_b3 = (_a13 = this.options) == null ? void 0 : _a13.host) != null ? _b3 : this.element, t5) : this._$AH.handleEvent(t5);
1243
+ }
1244
+ };
1245
+ var W = class {
1246
+ constructor(t5, i7, s6) {
1247
+ this.element = t5, this.type = 6, this._$AN = void 0, this._$AM = i7, this.options = s6;
1248
+ }
1249
+ get _$AU() {
1250
+ return this._$AM._$AU;
1251
+ }
1252
+ _$AI(t5) {
1253
+ M(this, t5);
1254
+ }
1255
+ };
1256
+ var Z = { M: h2, P: o3, A: n3, C: 1, L: N, R: k, D: d2, V: M, I: R, H, N: L, U: z, B: I, F: W };
1257
+ var j = t2.litHtmlPolyfillSupport;
1258
+ var _a10;
1259
+ j == null ? void 0 : j(S2, R), ((_a10 = t2.litHtmlVersions) != null ? _a10 : t2.litHtmlVersions = []).push("3.3.3");
1260
+ var B = (t5, i7, s6) => {
1261
+ var _a13, _b3;
1262
+ const e6 = (_a13 = s6 == null ? void 0 : s6.renderBefore) != null ? _a13 : i7;
1263
+ let h6 = e6._$litPart$;
1264
+ if (void 0 === h6) {
1265
+ const t6 = (_b3 = s6 == null ? void 0 : s6.renderBefore) != null ? _b3 : null;
1266
+ e6._$litPart$ = h6 = new R(i7.insertBefore(c3(), t6), t6, void 0, s6 != null ? s6 : {});
1267
+ }
1268
+ return h6._$AI(t5), h6;
1269
+ };
1270
+
1271
+ // ../../node_modules/.pnpm/lit-element@4.2.2/node_modules/lit-element/lit-element.js
1272
+ var s3 = globalThis;
1273
+ var i3 = class extends g {
1274
+ constructor() {
1275
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
1276
+ }
1277
+ createRenderRoot() {
1278
+ var _a13, _b3;
1279
+ const t5 = super.createRenderRoot();
1280
+ return (_b3 = (_a13 = this.renderOptions).renderBefore) != null ? _b3 : _a13.renderBefore = t5.firstChild, t5;
1281
+ }
1282
+ update(t5) {
1283
+ const r6 = this.render();
1284
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t5), this._$Do = B(r6, this.renderRoot, this.renderOptions);
1285
+ }
1286
+ connectedCallback() {
1287
+ var _a13;
1288
+ super.connectedCallback(), (_a13 = this._$Do) == null ? void 0 : _a13.setConnected(true);
1289
+ }
1290
+ disconnectedCallback() {
1291
+ var _a13;
1292
+ super.disconnectedCallback(), (_a13 = this._$Do) == null ? void 0 : _a13.setConnected(false);
1293
+ }
1294
+ render() {
1295
+ return E;
1296
+ }
1297
+ };
1298
+ var _a11;
1299
+ i3._$litElement$ = true, i3["finalized"] = true, (_a11 = s3.litElementHydrateSupport) == null ? void 0 : _a11.call(s3, { LitElement: i3 });
1300
+ var o4 = s3.litElementPolyfillSupport;
1301
+ o4 == null ? void 0 : o4({ LitElement: i3 });
1302
+ var _a12;
1303
+ ((_a12 = s3.litElementVersions) != null ? _a12 : s3.litElementVersions = []).push("4.2.2");
1304
+
1305
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directive-helpers.js
1306
+ var { I: t3 } = Z;
1307
+ var i4 = (o9) => o9;
1308
+ var r4 = (o9) => void 0 === o9.strings;
1309
+ var s4 = () => document.createComment("");
1310
+ var v2 = (o9, n7, e6) => {
1311
+ var _a13;
1312
+ const l3 = o9._$AA.parentNode, d3 = void 0 === n7 ? o9._$AB : n7._$AA;
1313
+ if (void 0 === e6) {
1314
+ const i7 = l3.insertBefore(s4(), d3), n8 = l3.insertBefore(s4(), d3);
1315
+ e6 = new t3(i7, n8, o9, o9.options);
1316
+ } else {
1317
+ const t5 = e6._$AB.nextSibling, n8 = e6._$AM, c6 = n8 !== o9;
1318
+ if (c6) {
1319
+ let t6;
1320
+ (_a13 = e6._$AQ) == null ? void 0 : _a13.call(e6, o9), e6._$AM = o9, void 0 !== e6._$AP && (t6 = o9._$AU) !== n8._$AU && e6._$AP(t6);
1321
+ }
1322
+ if (t5 !== d3 || c6) {
1323
+ let o10 = e6._$AA;
1324
+ for (; o10 !== t5; ) {
1325
+ const t6 = i4(o10).nextSibling;
1326
+ i4(l3).insertBefore(o10, d3), o10 = t6;
1327
+ }
1328
+ }
1329
+ }
1330
+ return e6;
1331
+ };
1332
+ var u3 = (o9, t5, i7 = o9) => (o9._$AI(t5, i7), o9);
1333
+ var m3 = {};
1334
+ var p3 = (o9, t5 = m3) => o9._$AH = t5;
1335
+ var M2 = (o9) => o9._$AH;
1336
+ var h3 = (o9) => {
1337
+ o9._$AR(), o9._$AA.remove();
1338
+ };
1339
+
1340
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directive.js
1341
+ var t4 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 };
1342
+ var e3 = (t5) => (...e6) => ({ _$litDirective$: t5, values: e6 });
1343
+ var i5 = class {
1344
+ constructor(t5) {
1345
+ }
1346
+ get _$AU() {
1347
+ return this._$AM._$AU;
1348
+ }
1349
+ _$AT(t5, e6, i7) {
1350
+ this._$Ct = t5, this._$AM = e6, this._$Ci = i7;
1351
+ }
1352
+ _$AS(t5, e6) {
1353
+ return this.update(t5, e6);
1354
+ }
1355
+ update(t5, e6) {
1356
+ return this.render(...e6);
1357
+ }
1358
+ };
1359
+
1360
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/async-directive.js
1361
+ var s5 = (i7, t5) => {
1362
+ var _a13;
1363
+ const e6 = i7._$AN;
1364
+ if (void 0 === e6) return false;
1365
+ for (const i8 of e6) (_a13 = i8._$AO) == null ? void 0 : _a13.call(i8, t5, false), s5(i8, t5);
1366
+ return true;
1367
+ };
1368
+ var o5 = (i7) => {
1369
+ let t5, e6;
1370
+ do {
1371
+ if (void 0 === (t5 = i7._$AM)) break;
1372
+ e6 = t5._$AN, e6.delete(i7), i7 = t5;
1373
+ } while (0 === (e6 == null ? void 0 : e6.size));
1374
+ };
1375
+ var r5 = (i7) => {
1376
+ for (let t5; t5 = i7._$AM; i7 = t5) {
1377
+ let e6 = t5._$AN;
1378
+ if (void 0 === e6) t5._$AN = e6 = /* @__PURE__ */ new Set();
1379
+ else if (e6.has(i7)) break;
1380
+ e6.add(i7), c4(t5);
1381
+ }
1382
+ };
1383
+ function h4(i7) {
1384
+ void 0 !== this._$AN ? (o5(this), this._$AM = i7, r5(this)) : this._$AM = i7;
1385
+ }
1386
+ function n4(i7, t5 = false, e6 = 0) {
1387
+ const r6 = this._$AH, h6 = this._$AN;
1388
+ if (void 0 !== h6 && 0 !== h6.size) if (t5) if (Array.isArray(r6)) for (let i8 = e6; i8 < r6.length; i8++) s5(r6[i8], false), o5(r6[i8]);
1389
+ else null != r6 && (s5(r6, false), o5(r6));
1390
+ else s5(this, i7);
1391
+ }
1392
+ var c4 = (i7) => {
1393
+ var _a13, _b3;
1394
+ i7.type == t4.CHILD && ((_a13 = i7._$AP) != null ? _a13 : i7._$AP = n4, (_b3 = i7._$AQ) != null ? _b3 : i7._$AQ = h4);
1395
+ };
1396
+ var f3 = class extends i5 {
1397
+ constructor() {
1398
+ super(...arguments), this._$AN = void 0;
1399
+ }
1400
+ _$AT(i7, t5, e6) {
1401
+ super._$AT(i7, t5, e6), r5(this), this.isConnected = i7._$AU;
1402
+ }
1403
+ _$AO(i7, t5 = true) {
1404
+ var _a13, _b3;
1405
+ i7 !== this.isConnected && (this.isConnected = i7, i7 ? (_a13 = this.reconnected) == null ? void 0 : _a13.call(this) : (_b3 = this.disconnected) == null ? void 0 : _b3.call(this)), t5 && (s5(this, i7), o5(this));
1406
+ }
1407
+ setValue(t5) {
1408
+ if (r4(this._$Ct)) this._$Ct._$AI(t5, this);
1409
+ else {
1410
+ const i7 = [...this._$Ct._$AH];
1411
+ i7[this._$Ci] = t5, this._$Ct._$AI(i7, this, 0);
1412
+ }
1413
+ }
1414
+ disconnected() {
1415
+ }
1416
+ reconnected() {
1417
+ }
1418
+ };
1419
+
1420
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/ref.js
1421
+ var e4 = () => new h5();
1422
+ var h5 = class {
1423
+ };
1424
+ var o6 = /* @__PURE__ */ new WeakMap();
1425
+ var n5 = e3(class extends f3 {
1426
+ render(i7) {
1427
+ return A;
1428
+ }
1429
+ update(i7, [s6]) {
1430
+ var _a13;
1431
+ const e6 = s6 !== this.G;
1432
+ return e6 && this.rt(void 0), (e6 || this.lt !== this.ct) && (this.G = s6, this.ht = (_a13 = i7.options) == null ? void 0 : _a13.host, this.rt(this.ct = i7.element)), A;
1433
+ }
1434
+ rt(t5) {
1435
+ var _a13;
1436
+ if (void 0 !== this.G) if (this.isConnected || (t5 = void 0), "function" == typeof this.G) {
1437
+ const i7 = (_a13 = this.ht) != null ? _a13 : globalThis;
1438
+ let s6 = o6.get(i7);
1439
+ void 0 === s6 && (s6 = /* @__PURE__ */ new WeakMap(), o6.set(i7, s6)), void 0 !== s6.get(this.G) && this.G.call(this.ht, void 0), s6.set(this.G, t5), void 0 !== t5 && this.G.call(this.ht, t5);
1440
+ } else this.G.value = t5;
1441
+ }
1442
+ get lt() {
1443
+ var _a13, _b3, _c;
1444
+ return "function" == typeof this.G ? (_b3 = o6.get((_a13 = this.ht) != null ? _a13 : globalThis)) == null ? void 0 : _b3.get(this.G) : (_c = this.G) == null ? void 0 : _c.value;
1445
+ }
1446
+ disconnected() {
1447
+ this.lt === this.ct && this.rt(void 0);
1448
+ }
1449
+ reconnected() {
1450
+ this.rt(this.ct);
1451
+ }
1452
+ });
1453
+
1454
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/unsafe-html.js
1455
+ var e5 = class extends i5 {
1456
+ constructor(i7) {
1457
+ if (super(i7), this.it = A, i7.type !== t4.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
1458
+ }
1459
+ render(r6) {
1460
+ if (r6 === A || null == r6) return this._t = void 0, this.it = r6;
1461
+ if (r6 === E) return r6;
1462
+ if ("string" != typeof r6) throw Error(this.constructor.directiveName + "() called with a non-string value");
1463
+ if (r6 === this.it) return this._t;
1464
+ this.it = r6;
1465
+ const s6 = [r6];
1466
+ return s6.raw = s6, this._t = { _$litType$: this.constructor.resultType, strings: s6, values: [] };
1467
+ }
1468
+ };
1469
+ e5.directiveName = "unsafeHTML", e5.resultType = 1;
1470
+ var o7 = e3(e5);
1471
+
1472
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-left-bold.svg
1473
+ var caret_left_bold_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z"/></svg>\n';
1474
+
1475
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-right-bold.svg
1476
+ var caret_right_bold_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z"/></svg>\n';
1477
+
29
1478
  // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg
30
1479
  var close_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/></svg>\n';
31
1480
 
32
- // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg
33
- var collapse_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z"/></svg>\n';
1481
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-up-bold.svg
1482
+ var caret_up_bold_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"/></svg>';
1483
+
1484
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg
1485
+ var collapse_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z"/></svg>\n';
1486
+
1487
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg
1488
+ var expand_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z"/></svg>\n';
1489
+
1490
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg
1491
+ var pause_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z"/></svg>\n';
1492
+
1493
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg
1494
+ var play_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z"/></svg>\n';
1495
+
1496
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg
1497
+ var speaker_x_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M245.66,146.34a8,8,0,0,1-11.32,11.32L216,139.31l-18.34,18.35a8,8,0,0,1-11.32-11.32L204.69,128l-18.35-18.34a8,8,0,0,1,11.32-11.32L216,116.69l18.34-18.35a8,8,0,0,1,11.32,11.32L227.31,128ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm97.15-54.15a8,8,0,0,0-10-.16l-65.57,51A4,4,0,0,0,80,79.84v96.32a4,4,0,0,0,1.55,3.15l65.57,51a8,8,0,0,0,9,.56,8.29,8.29,0,0,0,3.91-7.18V32.25A8.27,8.27,0,0,0,157.12,25.85Z"/></svg>\n';
1498
+
1499
+ // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg
1500
+ var speaker_high_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"/></svg>\n';
1501
+
1502
+ // src/components/icons/index.ts
1503
+ var icons = {
1504
+ caretUp: caret_up_bold_default,
1505
+ close: close_default,
1506
+ collapse: collapse_default,
1507
+ expand: expand_default,
1508
+ next: caret_right_bold_default,
1509
+ pause: pause_fill_default,
1510
+ play: play_fill_default,
1511
+ previous: caret_left_bold_default,
1512
+ soundOff: speaker_x_fill_default,
1513
+ soundOn: speaker_high_fill_default
1514
+ };
1515
+ var markup = Object.fromEntries(
1516
+ Object.entries(icons).map(([name, svg]) => [
1517
+ name,
1518
+ svg.replace(
1519
+ "<svg",
1520
+ '<svg class="icon" aria-hidden="true" focusable="false"'
1521
+ )
1522
+ ])
1523
+ );
1524
+ function icon(name) {
1525
+ return o7(markup[name]);
1526
+ }
1527
+
1528
+ // src/utils/http-url.ts
1529
+ function httpUrl(value) {
1530
+ if (!value) return null;
1531
+ try {
1532
+ const { protocol } = new URL(value);
1533
+ return protocol === "https:" || protocol === "http:" ? value : null;
1534
+ } catch (e6) {
1535
+ return null;
1536
+ }
1537
+ }
1538
+
1539
+ // src/components/media/media.ts
1540
+ function prefersReducedMotion() {
1541
+ var _a13, _b3;
1542
+ return (_b3 = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis, "(prefers-reduced-motion: reduce)").matches) != null ? _b3 : false;
1543
+ }
1544
+ function hasVideo(story, video) {
1545
+ return !video.failed && httpUrl(story.media_url) !== null;
1546
+ }
1547
+ function renderMedia(story, video, { withVideo = true, loop = true, onEnded } = {}) {
1548
+ const posterUrl = httpUrl(story.poster_url);
1549
+ const mediaUrl = withVideo ? httpUrl(story.media_url) : null;
1550
+ return T`
1551
+ ${posterUrl ? T`<img class="poster" alt="" src=${posterUrl} />` : A}
1552
+ ${mediaUrl && !video.failed ? T`
1553
+ <video
1554
+ class="video"
1555
+ muted
1556
+ playsinline
1557
+ ?loop=${loop}
1558
+ preload="metadata"
1559
+ .muted=${true}
1560
+ ?autoplay=${!prefersReducedMotion()}
1561
+ poster=${posterUrl != null ? posterUrl : A}
1562
+ src=${mediaUrl}
1563
+ ${n5(video.ref)}
1564
+ @play=${video.sync}
1565
+ @pause=${video.sync}
1566
+ @volumechange=${video.sync}
1567
+ @error=${video.fail}
1568
+ @ended=${onEnded}
1569
+ ></video>
1570
+ ` : A}
1571
+ `;
1572
+ }
1573
+
1574
+ // src/components/media/video-controller.ts
1575
+ function playVideo(video) {
1576
+ var _a13;
1577
+ (_a13 = video.play()) == null ? void 0 : _a13.catch(() => void 0);
1578
+ }
1579
+ var VideoController = class {
1580
+ constructor(host) {
1581
+ this.host = host;
1582
+ /** Bound to the <video> by renderMedia. */
1583
+ this.ref = e4();
1584
+ this.paused = true;
1585
+ // The video always starts muted: that is what browsers allow to autoplay.
1586
+ this.muted = true;
1587
+ /** The video could not load: only the cover is shown. */
1588
+ this.failed = false;
1589
+ /** Listener for the video's play, pause and volumechange events. */
1590
+ this.sync = () => {
1591
+ const video = this.ref.value;
1592
+ if (!video) return;
1593
+ this.paused = video.paused;
1594
+ this.muted = video.muted;
1595
+ this.host.requestUpdate();
1596
+ };
1597
+ /** Listener for the video's error event. */
1598
+ this.fail = () => {
1599
+ this.failed = true;
1600
+ this.host.requestUpdate();
1601
+ };
1602
+ }
1603
+ /** The rendered <video> is on the page and playing. */
1604
+ get playing() {
1605
+ const video = this.ref.value;
1606
+ return !!video && video.isConnected && !video.paused;
1607
+ }
1608
+ /** For a new <video>, such as each time the player opens. */
1609
+ reset() {
1610
+ this.paused = true;
1611
+ this.muted = true;
1612
+ this.failed = false;
1613
+ }
1614
+ play() {
1615
+ const video = this.ref.value;
1616
+ if (video) playVideo(video);
1617
+ }
1618
+ pause() {
1619
+ var _a13;
1620
+ (_a13 = this.ref.value) == null ? void 0 : _a13.pause();
1621
+ }
1622
+ /** Plays again if the video plays on its own (see renderMedia). */
1623
+ resume() {
1624
+ const video = this.ref.value;
1625
+ if (video == null ? void 0 : video.autoplay) playVideo(video);
1626
+ }
1627
+ togglePlayback() {
1628
+ const video = this.ref.value;
1629
+ if (!video) return;
1630
+ if (video.paused) playVideo(video);
1631
+ else video.pause();
1632
+ }
1633
+ mute() {
1634
+ const video = this.ref.value;
1635
+ if (video) video.muted = true;
1636
+ }
1637
+ /**
1638
+ * Plays from the start, with the sound on if `withSound`. A new src starts
1639
+ * there anyway; the same src (two Stories with one video) would otherwise
1640
+ * go on where it was.
1641
+ */
1642
+ restart({ withSound = false } = {}) {
1643
+ const video = this.ref.value;
1644
+ if (!video) return;
1645
+ video.currentTime = 0;
1646
+ if (withSound) this.playWithSound();
1647
+ else playVideo(video);
1648
+ }
1649
+ /**
1650
+ * Plays with the sound on. A browser that blocks playing with sound (for
1651
+ * example, without a recent tap) gets it muted instead: the video keeps
1652
+ * playing, and the sound button offers to turn it on. Not if the video was
1653
+ * replaced or removed meanwhile (the request then fails for that reason):
1654
+ * it would play out of sight.
1655
+ */
1656
+ playWithSound() {
1657
+ var _a13;
1658
+ const video = this.ref.value;
1659
+ if (!video) return;
1660
+ video.muted = false;
1661
+ (_a13 = video.play()) == null ? void 0 : _a13.catch((error) => {
1662
+ const blocked = error instanceof DOMException && error.name === "NotAllowedError";
1663
+ if (!blocked || this.ref.value !== video || !video.isConnected) return;
1664
+ video.muted = true;
1665
+ playVideo(video);
1666
+ });
1667
+ }
1668
+ toggleMuted() {
1669
+ const video = this.ref.value;
1670
+ if (video) video.muted = !video.muted;
1671
+ }
1672
+ };
1673
+
1674
+ // src/components/product/price.ts
1675
+ var DEFAULT_LOCALE = "pt-BR";
1676
+ var DEFAULT_CURRENCY = "BRL";
1677
+ function toAmount(value) {
1678
+ let amount = Number.NaN;
1679
+ if (typeof value === "number") amount = value;
1680
+ else if (typeof value === "string" && value.trim() !== "") {
1681
+ amount = Number(value);
1682
+ }
1683
+ return Number.isFinite(amount) && amount > 0 ? amount : void 0;
1684
+ }
1685
+ function readProductPrice(metadata) {
1686
+ const regular = toAmount(metadata == null ? void 0 : metadata.price);
1687
+ const promotional = toAmount(metadata == null ? void 0 : metadata.promotional_price);
1688
+ if (promotional !== void 0 && (regular === void 0 || promotional < regular)) {
1689
+ return regular === void 0 ? { price: promotional } : { price: promotional, listPrice: regular };
1690
+ }
1691
+ return regular === void 0 ? void 0 : { price: regular };
1692
+ }
1693
+ function isLocale(locale) {
1694
+ try {
1695
+ return Intl.NumberFormat.supportedLocalesOf(locale).length > 0;
1696
+ } catch (e6) {
1697
+ return false;
1698
+ }
1699
+ }
1700
+ var intl = Intl;
1701
+ function isCurrency(currency) {
1702
+ var _a13;
1703
+ if (!/^[a-z]{3}$/i.test(currency)) return false;
1704
+ const known = (_a13 = intl.supportedValuesOf) == null ? void 0 : _a13.call(intl, "currency");
1705
+ return known ? known.includes(currency.toUpperCase()) : true;
1706
+ }
1707
+ function priceFormatter(locale, currency) {
1708
+ const format = new Intl.NumberFormat(
1709
+ locale && isLocale(locale) ? locale : DEFAULT_LOCALE,
1710
+ {
1711
+ style: "currency",
1712
+ currency: currency && isCurrency(currency) ? currency : DEFAULT_CURRENCY
1713
+ }
1714
+ );
1715
+ return (amount) => format.format(amount);
1716
+ }
1717
+
1718
+ // src/components/product/product.ts
1719
+ function toCardProduct(story, format, labels, fetched) {
1720
+ var _a13, _b3, _c, _d;
1721
+ const product = story.product;
1722
+ const name = (_a13 = product == null ? void 0 : product.product_name) == null ? void 0 : _a13.trim();
1723
+ if (!product || !name) return void 0;
1724
+ const base = {
1725
+ name,
1726
+ imageUrl: (_b3 = httpUrl(product.image_url)) != null ? _b3 : void 0,
1727
+ url: (_c = httpUrl(story.destination_url)) != null ? _c : void 0
1728
+ };
1729
+ if (fetched === "loading") {
1730
+ return { ...base, label: labels.product(name), isLoading: true };
1731
+ }
1732
+ if ((fetched == null ? void 0 : fetched.available) === false) {
1733
+ return {
1734
+ ...base,
1735
+ label: labels.product(name, labels.soldOut),
1736
+ soldOut: labels.soldOut
1737
+ };
1738
+ }
1739
+ const amounts = (_d = fetched == null ? void 0 : fetched.price) != null ? _d : readProductPrice(product.product_metadata);
1740
+ const price = amounts && format(amounts.price);
1741
+ const listPrice = (amounts == null ? void 0 : amounts.listPrice) === void 0 ? void 0 : format(amounts.listPrice);
1742
+ return {
1743
+ ...base,
1744
+ price,
1745
+ listPrice,
1746
+ label: labels.product(name, price, listPrice)
1747
+ };
1748
+ }
1749
+ var priceSkeleton = T`
1750
+ <span
1751
+ class="product-price product-loading product-price-loading"
1752
+ aria-hidden="true"
1753
+ ></span>
1754
+ `;
1755
+ var addToCartSkeleton = T`
1756
+ <span
1757
+ class="product-loading product-add-to-cart-loading"
1758
+ aria-hidden="true"
1759
+ ></span>
1760
+ `;
1761
+ function renderPrice({ isLoading, soldOut, price, listPrice }) {
1762
+ if (isLoading) return priceSkeleton;
1763
+ if (soldOut) {
1764
+ return T`<span class="product-price product-sold-out">${soldOut}</span>`;
1765
+ }
1766
+ if (!price) return A;
1767
+ return T`
1768
+ <span class="product-price">
1769
+ <span>${price}</span>
1770
+ ${listPrice ? T`<s class="product-list-price">${listPrice}</s>` : A}
1771
+ </span>
1772
+ `;
1773
+ }
1774
+ function renderSummary(product) {
1775
+ return T`
1776
+ ${product.imageUrl ? T`<img class="product-image" alt="" src=${product.imageUrl} />` : A}
1777
+ <span class="product-info">
1778
+ <span class="product-name">${product.name}</span>
1779
+ ${renderPrice(product)}
1780
+ </span>
1781
+ `;
1782
+ }
1783
+ function renderProduct(product, onSelect) {
1784
+ return T`
1785
+ <button
1786
+ type="button"
1787
+ class="card-product"
1788
+ aria-label=${product.label}
1789
+ @click=${onSelect}
1790
+ >
1791
+ ${renderSummary(product)}
1792
+ </button>
1793
+ `;
1794
+ }
1795
+ function renderAddToCart({ isLoading, soldOut }, { labels }) {
1796
+ if (isLoading) return addToCartSkeleton;
1797
+ if (soldOut) {
1798
+ return T`
1799
+ <button type="button" class="product-action product-unavailable" disabled>
1800
+ ${labels.unavailable}
1801
+ </button>
1802
+ `;
1803
+ }
1804
+ return T`
1805
+ <button type="button" class="product-action product-add-to-cart">
1806
+ ${labels.addToCart}
1807
+ </button>
1808
+ `;
1809
+ }
1810
+ function renderExpandableProduct(product, options) {
1811
+ const { open } = options;
1812
+ return T`
1813
+ <div class="card-product product-expandable" ?data-open=${open}>
1814
+ <button
1815
+ type="button"
1816
+ class="product-summary"
1817
+ aria-label=${product.label}
1818
+ aria-expanded=${open ? "true" : "false"}
1819
+ aria-controls=${options.panelId}
1820
+ @click=${options.onToggle}
1821
+ >
1822
+ ${renderSummary(product)}
1823
+ <span class="product-toggle">${icon("caretUp")}</span>
1824
+ </button>
1825
+ <div id=${options.panelId} class="product-panel" ?inert=${!open}>
1826
+ <div class="product-actions">
1827
+ ${renderAddToCart(product, options)}
1828
+ ${product.url ? T`
1829
+ <a
1830
+ class="product-action product-view"
1831
+ href=${product.url}
1832
+ target="_blank"
1833
+ rel="noopener noreferrer"
1834
+ >
1835
+ ${options.labels.viewProduct}
1836
+ </a>
1837
+ ` : A}
1838
+ </div>
1839
+ </div>
1840
+ </div>
1841
+ `;
1842
+ }
1843
+
1844
+ // src/components/product/cta.ts
1845
+ function toCardCta(story) {
1846
+ var _a13;
1847
+ if (story.product) return void 0;
1848
+ const label = (_a13 = story.call_to_action) == null ? void 0 : _a13.trim();
1849
+ const url = httpUrl(story.destination_url);
1850
+ return label && url ? { label, url } : void 0;
1851
+ }
1852
+ function renderCta(cta, onSelect) {
1853
+ const onClick = onSelect ? (event) => {
1854
+ event.preventDefault();
1855
+ onSelect();
1856
+ } : void 0;
1857
+ return T`
1858
+ <a
1859
+ class="card-cta"
1860
+ href=${cta.url}
1861
+ target="_blank"
1862
+ rel="noopener noreferrer"
1863
+ @click=${onClick}
1864
+ >
1865
+ <span class="cta-label">${cta.label}</span>
1866
+ ${icon("next")}
1867
+ </a>
1868
+ `;
1869
+ }
1870
+
1871
+ // src/components/product/product.styles.ts
1872
+ var productStyles = i`
1873
+ /* A glass pill at the bottom of the card, above its button: the product or
1874
+ the call to action. */
1875
+ .card-product,
1876
+ .card-cta {
1877
+ position: absolute;
1878
+ right: 12px;
1879
+ bottom: 12px;
1880
+ left: 12px;
1881
+ z-index: 1;
1882
+ display: flex;
1883
+ gap: 8px;
1884
+ align-items: center;
1885
+ box-sizing: border-box;
1886
+ padding: 8px;
1887
+ border: 0;
1888
+ border-radius: 16px;
1889
+ background: rgba(255, 255, 255, 0.15);
1890
+ backdrop-filter: blur(5px);
1891
+ color: #fff;
1892
+ font: inherit;
1893
+ text-align: left;
1894
+ isolation: isolate;
1895
+ transition: transform 0.2s ease;
1896
+ }
1897
+
1898
+ /* The glass's tint and inner light, darker on hover. */
1899
+ .card-product::before,
1900
+ .card-cta::before {
1901
+ position: absolute;
1902
+ inset: 0;
1903
+ z-index: -1;
1904
+ border-radius: inherit;
1905
+ background: rgba(0, 0, 0, 0.15);
1906
+ box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);
1907
+ content: "";
1908
+ transition: background-color 0.2s ease;
1909
+ }
1910
+
1911
+ button.card-product,
1912
+ .card-cta {
1913
+ cursor: pointer;
1914
+ }
1915
+
1916
+ .card-product:focus-visible,
1917
+ .card-cta:focus-visible {
1918
+ outline: 2px solid #fff;
1919
+ outline-offset: 2px;
1920
+ }
1921
+
1922
+ @media (hover: hover) and (pointer: fine) {
1923
+ .card-product:hover,
1924
+ .card-cta:hover {
1925
+ transform: translateY(-2px);
1926
+ }
1927
+
1928
+ .card-product:hover::before,
1929
+ .card-cta:hover::before {
1930
+ background: rgba(0, 0, 0, 0.32);
1931
+ }
1932
+ }
1933
+
1934
+ /* A Story with a link: the pill is the call to action, its text centered
1935
+ with a caret after it. */
1936
+ .card-cta {
1937
+ justify-content: center;
1938
+ gap: 6px;
1939
+ height: 48px;
1940
+ padding: 0 16px;
1941
+ font-size: 14px;
1942
+ font-weight: 700;
1943
+ line-height: 1;
1944
+ text-decoration: none;
1945
+ }
1946
+
1947
+ .cta-label {
1948
+ min-width: 0;
1949
+ overflow: hidden;
1950
+ text-overflow: ellipsis;
1951
+ white-space: nowrap;
1952
+ }
1953
+
1954
+ .card-cta .icon {
1955
+ flex: none;
1956
+ width: 14px;
1957
+ height: 14px;
1958
+ }
1959
+
1960
+ /* In the player: the pill is a toggle, with the actions panel below. */
1961
+ .product-expandable {
1962
+ display: block;
1963
+ padding: 0;
1964
+ transition:
1965
+ background-color 0.3s ease,
1966
+ color 0.3s ease,
1967
+ box-shadow 0.3s ease,
1968
+ transform 0.2s ease;
1969
+ }
1970
+
1971
+ .product-expandable::before {
1972
+ transition:
1973
+ opacity 0.3s ease,
1974
+ background-color 0.2s ease;
1975
+ }
1976
+
1977
+ .product-summary {
1978
+ display: flex;
1979
+ gap: 8px;
1980
+ align-items: center;
1981
+ box-sizing: border-box;
1982
+ width: 100%;
1983
+ padding: 8px;
1984
+ border: 0;
1985
+ border-radius: inherit;
1986
+ background: transparent;
1987
+ color: inherit;
1988
+ font: inherit;
1989
+ text-align: left;
1990
+ cursor: pointer;
1991
+ transition: padding 0.3s ease;
1992
+ }
1993
+
1994
+ .product-summary:focus-visible {
1995
+ outline: 2px solid currentColor;
1996
+ outline-offset: 2px;
1997
+ }
1998
+
1999
+ /* The caret points up while closed and down while open. */
2000
+ .product-toggle {
2001
+ display: grid;
2002
+ flex: none;
2003
+ margin-right: 4px;
2004
+ opacity: 0.7;
2005
+ transition:
2006
+ transform 0.3s ease,
2007
+ opacity 0.2s ease;
2008
+ }
2009
+
2010
+ .product-toggle .icon {
2011
+ width: 14px;
2012
+ height: 14px;
2013
+ }
2014
+
2015
+ .product-summary:hover .product-toggle {
2016
+ opacity: 1;
2017
+ }
2018
+
2019
+ /* Closed: 0 rows tall, so it grows smoothly when it opens. */
2020
+ .product-panel {
2021
+ display: grid;
2022
+ grid-template-rows: 0fr;
2023
+ transition: grid-template-rows 0.3s ease;
2024
+ }
2025
+
2026
+ .product-actions {
2027
+ display: grid;
2028
+ gap: 8px;
2029
+ min-height: 0;
2030
+ overflow: hidden;
2031
+ padding: 0 12px;
2032
+ opacity: 0;
2033
+ transition:
2034
+ padding 0.3s ease,
2035
+ opacity 0.2s ease;
2036
+ }
2037
+
2038
+ .product-action {
2039
+ display: flex;
2040
+ align-items: center;
2041
+ justify-content: center;
2042
+ box-sizing: border-box;
2043
+ height: 48px;
2044
+ padding: 0 16px;
2045
+ border: 1px solid var(--vtex-ads-story-color-accent, #1b75a8);
2046
+ border-radius: 50px;
2047
+ font: inherit;
2048
+ font-size: 14px;
2049
+ font-weight: 700;
2050
+ text-decoration: none;
2051
+ cursor: pointer;
2052
+ transition: background-color 0.2s ease;
2053
+ }
2054
+
2055
+ .product-action:focus-visible {
2056
+ outline: 2px solid var(--vtex-ads-story-color-accent, #1b75a8);
2057
+ outline-offset: 2px;
2058
+ }
2059
+
2060
+ .product-add-to-cart {
2061
+ background: var(--vtex-ads-story-color-accent, #1b75a8);
2062
+ color: var(--vtex-ads-story-color-accent-contrast, #fff);
2063
+ }
2064
+
2065
+ .product-add-to-cart:hover {
2066
+ background: color-mix(
2067
+ in srgb,
2068
+ var(--vtex-ads-story-color-accent, #1b75a8) 85%,
2069
+ #000
2070
+ );
2071
+ }
2072
+
2073
+ /* Sold out: add to cart, disabled and grayed. */
2074
+ .product-unavailable {
2075
+ border-color: transparent;
2076
+ background: rgba(0, 0, 0, 0.06);
2077
+ color: var(--vtex-ads-story-color-muted, #6b6b6b);
2078
+ cursor: not-allowed;
2079
+ }
2080
+
2081
+ .product-view {
2082
+ background: var(--vtex-ads-story-color-surface, #fff);
2083
+ color: var(--vtex-ads-story-color-accent, #1b75a8);
2084
+ }
2085
+
2086
+ /* A light tint of the accent. */
2087
+ .product-view:hover {
2088
+ background: color-mix(
2089
+ in srgb,
2090
+ var(--vtex-ads-story-color-accent, #1b75a8) 8%,
2091
+ var(--vtex-ads-story-color-surface, #fff)
2092
+ );
2093
+ }
34
2094
 
35
- // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg
36
- var expand_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z"/></svg>\n';
2095
+ /* Open: a solid card (white by default), without the glass. */
2096
+ .product-expandable[data-open] {
2097
+ background: var(--vtex-ads-story-color-surface, #fff);
2098
+ color: var(--vtex-ads-story-color-text, #242424);
2099
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
2100
+ }
37
2101
 
38
- // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg
39
- var pause_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z"/></svg>\n';
2102
+ .product-expandable[data-open]::before {
2103
+ opacity: 0;
2104
+ }
40
2105
 
41
- // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg
42
- var play_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z"/></svg>\n';
2106
+ .product-expandable[data-open] .product-price {
2107
+ color: inherit;
2108
+ }
43
2109
 
44
- // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg
45
- var speaker_x_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M245.66,146.34a8,8,0,0,1-11.32,11.32L216,139.31l-18.34,18.35a8,8,0,0,1-11.32-11.32L204.69,128l-18.35-18.34a8,8,0,0,1,11.32-11.32L216,116.69l18.34-18.35a8,8,0,0,1,11.32,11.32L227.31,128ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm97.15-54.15a8,8,0,0,0-10-.16l-65.57,51A4,4,0,0,0,80,79.84v96.32a4,4,0,0,0,1.55,3.15l65.57,51a8,8,0,0,0,9,.56,8.29,8.29,0,0,0,3.91-7.18V32.25A8.27,8.27,0,0,0,157.12,25.85Z"/></svg>\n';
2110
+ .product-expandable[data-open] .product-list-price {
2111
+ color: var(--vtex-ads-story-color-muted, #6b6b6b);
2112
+ opacity: 1;
2113
+ }
46
2114
 
47
- // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg
48
- var speaker_high_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"/></svg>\n';
2115
+ .product-expandable[data-open] .product-summary {
2116
+ padding: 12px;
2117
+ }
49
2118
 
50
- // src/components/icons/index.ts
51
- var icons = {
52
- close: close_default,
53
- collapse: collapse_default,
54
- expand: expand_default,
55
- pause: pause_fill_default,
56
- play: play_fill_default,
57
- soundOff: speaker_x_fill_default,
58
- soundOn: speaker_high_fill_default
59
- };
60
- function createIcon(name) {
61
- const template = document.createElement("template");
62
- template.innerHTML = icons[name];
63
- const svg = template.content.firstElementChild;
64
- svg.classList.add("icon");
65
- svg.setAttribute("aria-hidden", "true");
66
- svg.setAttribute("focusable", "false");
67
- return svg;
68
- }
2119
+ .product-expandable[data-open] .product-toggle {
2120
+ transform: rotate(180deg);
2121
+ }
2122
+
2123
+ .product-expandable[data-open] .product-panel {
2124
+ grid-template-rows: 1fr;
2125
+ }
2126
+
2127
+ .product-expandable[data-open] .product-actions {
2128
+ padding: 0 12px 12px;
2129
+ opacity: 1;
2130
+ transition:
2131
+ padding 0.3s ease,
2132
+ opacity 0.25s ease 0.1s;
2133
+ }
2134
+
2135
+ /* Open, it stays in place on hover. */
2136
+ @media (hover: hover) and (pointer: fine) {
2137
+ .product-expandable[data-open]:hover {
2138
+ transform: none;
2139
+ }
2140
+ }
2141
+
2142
+ @media (prefers-reduced-motion: reduce) {
2143
+ .card-product,
2144
+ .card-product:hover,
2145
+ .card-cta,
2146
+ .card-cta:hover {
2147
+ transform: none;
2148
+ transition: none;
2149
+ }
2150
+
2151
+ .card-product::before,
2152
+ .card-cta::before,
2153
+ .product-summary,
2154
+ .product-toggle,
2155
+ .product-panel,
2156
+ .product-actions,
2157
+ .product-expandable[data-open] .product-actions {
2158
+ transition: none;
2159
+ }
2160
+ }
2161
+
2162
+ .product-image {
2163
+ flex: none;
2164
+ width: 60px;
2165
+ height: 60px;
2166
+ border-radius: 8px;
2167
+ background: #fff;
2168
+ object-fit: contain;
2169
+ }
2170
+
2171
+ .product-info {
2172
+ display: grid;
2173
+ flex: 1;
2174
+ gap: 4px;
2175
+ min-width: 0;
2176
+ font-size: 12px;
2177
+ font-weight: 700;
2178
+ line-height: 16px;
2179
+ }
2180
+
2181
+ .product-name {
2182
+ display: -webkit-box;
2183
+ overflow: hidden;
2184
+ -webkit-box-orient: vertical;
2185
+ -webkit-line-clamp: 2;
2186
+ overflow-wrap: anywhere;
2187
+ }
2188
+
2189
+ .product-price {
2190
+ display: flex;
2191
+ flex-wrap: wrap;
2192
+ gap: 0 6px;
2193
+ }
2194
+
2195
+ .product-list-price {
2196
+ font-weight: 400;
2197
+ opacity: 0.5;
2198
+ }
2199
+
2200
+ /* In place of the price, for a product that can't be bought. */
2201
+ .product-sold-out {
2202
+ font-weight: 700;
2203
+ opacity: 0.75;
2204
+ }
2205
+
2206
+ /* Placeholders while the product loads, pulsing gently. */
2207
+ .product-loading {
2208
+ background: currentColor;
2209
+ opacity: 0.25;
2210
+ animation: product-loading-pulse 1.2s ease-in-out infinite alternate;
2211
+ }
2212
+
2213
+ @keyframes product-loading-pulse {
2214
+ to {
2215
+ opacity: 0.1;
2216
+ }
2217
+ }
2218
+
2219
+ /* The price's: a line its height (the info's line height). */
2220
+ .product-price-loading {
2221
+ width: 64px;
2222
+ height: 16px;
2223
+ border-radius: 4px;
2224
+ }
2225
+
2226
+ /* The add to cart button's: its size and shape. */
2227
+ .product-add-to-cart-loading {
2228
+ display: block;
2229
+ height: 48px;
2230
+ border-radius: 50px;
2231
+ }
2232
+
2233
+ @media (prefers-reduced-motion: reduce) {
2234
+ .product-loading {
2235
+ animation: none;
2236
+ }
2237
+ }
2238
+ `;
69
2239
 
70
2240
  // src/components/card/card.ts
71
- var cardStyles = `
2241
+ var cardStyles = i`
2242
+ /* 9:16 at the height its container gives it (--card-height, default
2243
+ 500px). */
72
2244
  .card {
73
2245
  position: relative;
74
2246
  box-sizing: border-box;
75
- width: calc(500px * 9 / 16);
76
- height: 500px;
2247
+ width: calc(var(--card-height, 500px) * 9 / 16);
2248
+ height: var(--card-height, 500px);
77
2249
  overflow: hidden;
78
2250
  border-radius: var(--vtex-ads-story-radius, 20px);
79
2251
  background: #000;
@@ -159,105 +2331,835 @@ var cardStyles = `
159
2331
  width: 20px;
160
2332
  height: 20px;
161
2333
  }
162
-
163
- /* With a mouse, the play button shows only on hover or keyboard focus.
164
- Touch screens have no hover, so it stays visible there. */
165
- @media (hover: hover) and (pointer: fine) {
166
- .play {
167
- opacity: 0;
168
- transform: translate(-50%, -50%) scale(0.9);
2334
+
2335
+ /* With a mouse, the play button shows only on hover or keyboard focus.
2336
+ Touch screens have no hover, so it stays visible there. */
2337
+ @media (hover: hover) and (pointer: fine) {
2338
+ .play {
2339
+ opacity: 0;
2340
+ transform: translate(-50%, -50%) scale(0.9);
2341
+ }
2342
+
2343
+ .card:hover .play,
2344
+ .card-open:focus-visible .play {
2345
+ opacity: 1;
2346
+ transform: translate(-50%, -50%);
2347
+ }
2348
+ }
2349
+ `;
2350
+ function renderSoundButton(video, options) {
2351
+ return T`
2352
+ <button
2353
+ type="button"
2354
+ class="card-sound"
2355
+ aria-label=${video.muted ? options.labels.soundOn : options.labels.soundOff}
2356
+ @click=${() => video.toggleMuted()}
2357
+ >
2358
+ ${icon(video.muted ? "soundOff" : "soundOn")}
2359
+ </button>
2360
+ `;
2361
+ }
2362
+ function renderCard(story, video, options) {
2363
+ var _a13, _b3;
2364
+ const withVideo = (_a13 = options.withVideo) != null ? _a13 : true;
2365
+ return T`
2366
+ <div
2367
+ class="card"
2368
+ ${n5(options.ref)}
2369
+ @click=${{ handleEvent: () => {
2370
+ var _a14;
2371
+ return (_a14 = options.onPress) == null ? void 0 : _a14.call(options);
2372
+ }, capture: true }}
2373
+ >
2374
+ ${renderMedia(story, video, { withVideo })}
2375
+ <button
2376
+ type="button"
2377
+ class="card-open"
2378
+ ${n5(options.openRef)}
2379
+ aria-label=${options.label}
2380
+ @click=${options.onSelect}
2381
+ >
2382
+ <span class="play" aria-hidden="true">${icon("play")}</span>
2383
+ </button>
2384
+ ${withVideo && hasVideo(story, video) && !video.paused ? renderSoundButton(video, options) : A}
2385
+ ${options.product ? renderProduct(
2386
+ options.product,
2387
+ (_b3 = options.onProductSelect) != null ? _b3 : options.onSelect
2388
+ ) : A}
2389
+ ${options.cta ? renderCta(options.cta, options.onCtaSelect) : A}
2390
+ </div>
2391
+ `;
2392
+ }
2393
+
2394
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/repeat.js
2395
+ var u4 = (e6, s6, t5) => {
2396
+ const r6 = /* @__PURE__ */ new Map();
2397
+ for (let l3 = s6; l3 <= t5; l3++) r6.set(e6[l3], l3);
2398
+ return r6;
2399
+ };
2400
+ var c5 = e3(class extends i5 {
2401
+ constructor(e6) {
2402
+ if (super(e6), e6.type !== t4.CHILD) throw Error("repeat() can only be used in text expressions");
2403
+ }
2404
+ dt(e6, s6, t5) {
2405
+ let r6;
2406
+ void 0 === t5 ? t5 = s6 : void 0 !== s6 && (r6 = s6);
2407
+ const l3 = [], o9 = [];
2408
+ let i7 = 0;
2409
+ for (const s7 of e6) l3[i7] = r6 ? r6(s7, i7) : i7, o9[i7] = t5(s7, i7), i7++;
2410
+ return { values: o9, keys: l3 };
2411
+ }
2412
+ render(e6, s6, t5) {
2413
+ return this.dt(e6, s6, t5).values;
2414
+ }
2415
+ update(s6, [t5, r6, c6]) {
2416
+ var _a13;
2417
+ const d3 = M2(s6), { values: p4, keys: a3 } = this.dt(t5, r6, c6);
2418
+ if (!Array.isArray(d3)) return this.ut = a3, p4;
2419
+ const h6 = (_a13 = this.ut) != null ? _a13 : this.ut = [], v3 = [];
2420
+ let m4, y3, x2 = 0, j2 = d3.length - 1, k2 = 0, w2 = p4.length - 1;
2421
+ for (; x2 <= j2 && k2 <= w2; ) if (null === d3[x2]) x2++;
2422
+ else if (null === d3[j2]) j2--;
2423
+ else if (h6[x2] === a3[k2]) v3[k2] = u3(d3[x2], p4[k2]), x2++, k2++;
2424
+ else if (h6[j2] === a3[w2]) v3[w2] = u3(d3[j2], p4[w2]), j2--, w2--;
2425
+ else if (h6[x2] === a3[w2]) v3[w2] = u3(d3[x2], p4[w2]), v2(s6, v3[w2 + 1], d3[x2]), x2++, w2--;
2426
+ else if (h6[j2] === a3[k2]) v3[k2] = u3(d3[j2], p4[k2]), v2(s6, d3[x2], d3[j2]), j2--, k2++;
2427
+ else if (void 0 === m4 && (m4 = u4(a3, k2, w2), y3 = u4(h6, x2, j2)), m4.has(h6[x2])) if (m4.has(h6[j2])) {
2428
+ const e6 = y3.get(a3[k2]), t6 = void 0 !== e6 ? d3[e6] : null;
2429
+ if (null === t6) {
2430
+ const e7 = v2(s6, d3[x2]);
2431
+ u3(e7, p4[k2]), v3[k2] = e7;
2432
+ } else v3[k2] = u3(t6, p4[k2]), v2(s6, d3[x2], t6), d3[e6] = null;
2433
+ k2++;
2434
+ } else h3(d3[j2]), j2--;
2435
+ else h3(d3[x2]), x2++;
2436
+ for (; k2 <= w2; ) {
2437
+ const e6 = v2(s6, v3[w2 + 1]);
2438
+ u3(e6, p4[k2]), v3[k2++] = e6;
2439
+ }
2440
+ for (; x2 <= j2; ) {
2441
+ const e6 = d3[x2++];
2442
+ null !== e6 && h3(e6);
2443
+ }
2444
+ return this.ut = a3, p3(s6, v3), E;
2445
+ }
2446
+ });
2447
+
2448
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/style-map.js
2449
+ var n6 = "important";
2450
+ var i6 = " !" + n6;
2451
+ var o8 = e3(class extends i5 {
2452
+ constructor(t5) {
2453
+ var _a13;
2454
+ if (super(t5), t5.type !== t4.ATTRIBUTE || "style" !== t5.name || ((_a13 = t5.strings) == null ? void 0 : _a13.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
2455
+ }
2456
+ render(t5) {
2457
+ return Object.keys(t5).reduce((e6, r6) => {
2458
+ const s6 = t5[r6];
2459
+ return null == s6 ? e6 : e6 + `${r6 = r6.includes("-") ? r6 : r6.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s6};`;
2460
+ }, "");
2461
+ }
2462
+ update(e6, [r6]) {
2463
+ const { style: s6 } = e6.element;
2464
+ if (void 0 === this.ft) return this.ft = new Set(Object.keys(r6)), this.render(r6);
2465
+ for (const t5 of this.ft) null == r6[t5] && (this.ft.delete(t5), t5.includes("-") ? s6.removeProperty(t5) : s6[t5] = null);
2466
+ for (const t5 in r6) {
2467
+ const e7 = r6[t5];
2468
+ if (null != e7) {
2469
+ this.ft.add(t5);
2470
+ const r7 = "string" == typeof e7 && e7.endsWith(i6);
2471
+ t5.includes("-") || r7 ? s6.setProperty(t5, r7 ? e7.slice(0, -11) : e7, r7 ? n6 : "") : s6[t5] = e7;
2472
+ }
2473
+ }
2474
+ return E;
2475
+ }
2476
+ });
2477
+
2478
+ // src/components/carousel/carousel.ts
2479
+ var STAGE_HEIGHT = i`500px`;
2480
+ var SOLO_PADDING = i`24px`;
2481
+ var AUTO_ADVANCE_MS = 5e3;
2482
+ var SWIPE_DISTANCE = 40;
2483
+ var NARROW_SCREEN = i`(max-width: 576px)`;
2484
+ var VISIBLE_SIDE = 2;
2485
+ var RENDERED_SIDE = VISIBLE_SIDE + 3;
2486
+ var carouselStyles = i`
2487
+ .carousel {
2488
+ position: relative;
2489
+ box-sizing: border-box;
2490
+ display: grid;
2491
+ height: ${STAGE_HEIGHT};
2492
+ place-items: center;
2493
+ --card-height: ${STAGE_HEIGHT};
2494
+ user-select: none;
2495
+ }
2496
+
2497
+ .carousel[data-layout="solo"] {
2498
+ padding: ${SOLO_PADDING};
2499
+ border-radius: var(--vtex-ads-story-radius, 20px);
2500
+ background: var(--vtex-ads-story-color-surface, #fafafa);
2501
+ --card-height: calc(${STAGE_HEIGHT} - 2 * ${SOLO_PADDING});
2502
+ }
2503
+
2504
+ .carousel[data-layout="solo"] .card {
2505
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
2506
+ }
2507
+
2508
+ .track {
2509
+ position: absolute;
2510
+ inset: 0;
2511
+ overflow: hidden;
2512
+ touch-action: pan-y;
2513
+ }
2514
+
2515
+ /* Each slide starts centered, then moves by its own transform. */
2516
+ .slide {
2517
+ --ease: cubic-bezier(0.25, 1, 0.5, 1);
2518
+ --duration: var(--slide-duration, 0.4s);
2519
+ position: absolute;
2520
+ top: 0;
2521
+ left: 50%;
2522
+ width: calc(${STAGE_HEIGHT} * 9 / 16);
2523
+ height: 100%;
2524
+ margin-left: calc(${STAGE_HEIGHT} * 9 / -32);
2525
+ opacity: 0.5;
2526
+ transition:
2527
+ transform var(--duration) var(--ease),
2528
+ opacity var(--duration) var(--ease),
2529
+ visibility 0s;
2530
+ }
2531
+
2532
+ .slide[data-active] {
2533
+ opacity: 1;
2534
+ }
2535
+
2536
+ /* Pair: --side is -1 for the first card, 1 for the second. The highlighted
2537
+ card sits 47.5% of its width off center, the other (scaled to 0.9)
2538
+ 52.5%, so the gap between them stays 8px. */
2539
+ .carousel[data-layout="pair"] .slide {
2540
+ --side: 1;
2541
+ --offset: 52.5%;
2542
+ --scale: 0.9;
2543
+ transform: translateX(calc(var(--side) * (var(--offset) + 4px)))
2544
+ scale(var(--scale));
2545
+ }
2546
+
2547
+ .carousel[data-layout="pair"] .slide[data-index="0"] {
2548
+ --side: -1;
2549
+ }
2550
+
2551
+ .carousel[data-layout="pair"] .slide[data-active] {
2552
+ --offset: 47.5%;
2553
+ --scale: 1;
2554
+ }
2555
+
2556
+ /* Rolling: --place is the slide's distance from the highlighted one, in
2557
+ cards, 8px apart. A hidden slide fades out, then stops being visible. */
2558
+ .carousel[data-layout="rolling"] .slide {
2559
+ transform: translateX(calc(var(--place) * (100% + 8px))) scale(0.9);
2560
+ }
2561
+
2562
+ .carousel[data-layout="rolling"] .slide[data-active] {
2563
+ transform: translateX(0) scale(1);
2564
+ }
2565
+
2566
+ .slide[data-hidden] {
2567
+ opacity: 0;
2568
+ visibility: hidden;
2569
+ transition:
2570
+ transform var(--duration) var(--ease),
2571
+ opacity var(--duration) var(--ease),
2572
+ visibility 0s var(--duration);
2573
+ }
2574
+
2575
+ /* Only the highlighted card opens the player, so only it shows play. Its
2576
+ sound is the only one to turn on: the others play muted, if at all. */
2577
+ .slide:not([data-active]) .play,
2578
+ .slide:not([data-active]) .card-sound {
2579
+ display: none;
2580
+ }
2581
+
2582
+ .arrow {
2583
+ position: absolute;
2584
+ top: 50%;
2585
+ z-index: 2;
2586
+ display: grid;
2587
+ width: 32px;
2588
+ height: 32px;
2589
+ place-items: center;
2590
+ padding: 0;
2591
+ border: 1px solid rgba(133, 133, 133, 0.3);
2592
+ border-radius: 50%;
2593
+ background: rgba(0, 0, 0, 0.3);
2594
+ backdrop-filter: blur(5px);
2595
+ color: #fff;
2596
+ cursor: pointer;
2597
+ transform: translateY(-50%);
2598
+ transition: background-color 0.2s;
2599
+ }
2600
+
2601
+ .arrow:hover {
2602
+ background: #262626;
2603
+ }
2604
+
2605
+ .arrow:disabled {
2606
+ cursor: default;
2607
+ opacity: 0.5;
2608
+ }
2609
+
2610
+ .arrow .icon {
2611
+ width: 16px;
2612
+ height: 16px;
2613
+ }
2614
+
2615
+ .arrow-previous {
2616
+ left: 3px;
2617
+ }
2618
+
2619
+ .arrow-next {
2620
+ right: 3px;
2621
+ }
2622
+
2623
+ @media ${NARROW_SCREEN} {
2624
+ .carousel[data-layout="solo"] {
2625
+ padding: 0;
2626
+ background: none;
2627
+ --card-height: ${STAGE_HEIGHT};
2628
+ }
2629
+
2630
+ .carousel[data-layout="solo"] .card {
2631
+ box-shadow: none;
2632
+ }
2633
+ }
2634
+
2635
+ @media (prefers-reduced-motion: reduce) {
2636
+ .slide,
2637
+ .slide[data-hidden] {
2638
+ transition: none;
2639
+ }
2640
+ }
2641
+ `;
2642
+ var wrap = (value, count) => (value % count + count) % count;
2643
+ function tracker(elements, slide) {
2644
+ let last;
2645
+ return (element) => {
2646
+ if (last) elements.delete(last);
2647
+ last = element;
2648
+ if (element) elements.set(element, slide);
2649
+ };
2650
+ }
2651
+ var CarouselController = class {
2652
+ constructor(host, options) {
2653
+ this.host = host;
2654
+ this.options = options;
2655
+ /**
2656
+ * Steps taken since the Stories loaded, back and forth, not wrapped: the
2657
+ * rolling layout keys its slides by it.
2658
+ */
2659
+ this.position = 0;
2660
+ /** Stories moved by the last step: longer jumps animate a bit slower. */
2661
+ this.distance = 1;
2662
+ this.count = 0;
2663
+ this.narrow = false;
2664
+ this.connected = false;
2665
+ this.hovered = false;
2666
+ this.focused = false;
2667
+ /** The rendered cards, as their cardRef reported them. */
2668
+ this.cards = /* @__PURE__ */ new Map();
2669
+ /** The rendered cards' focus targets, as their focusRef reported them. */
2670
+ this.focusTargets = /* @__PURE__ */ new Map();
2671
+ this.onMediaChange = (event) => {
2672
+ var _a13, _b3;
2673
+ const layout = this.layout;
2674
+ this.narrow = event.matches;
2675
+ if (this.layout === layout) return;
2676
+ (_b3 = (_a13 = this.options).onLayoutChange) == null ? void 0 : _b3.call(_a13);
2677
+ this.host.requestUpdate();
2678
+ };
2679
+ this.onPointerEnter = () => {
2680
+ this.hovered = true;
2681
+ this.syncTimer();
2682
+ };
2683
+ this.onPointerLeave = () => {
2684
+ this.hovered = false;
2685
+ this.syncTimer();
2686
+ };
2687
+ // Only keyboard focus stops the advance: a click also focuses the button
2688
+ // it hits, and the advance would then stay stopped after the pointer left.
2689
+ this.onFocusIn = (event) => {
2690
+ this.focused = event.target.matches(":focus-visible");
2691
+ this.syncTimer();
2692
+ };
2693
+ this.onFocusOut = (event) => {
2694
+ const carousel = event.currentTarget;
2695
+ const next = event.relatedTarget;
2696
+ if (!next || !carousel.contains(next)) this.focused = false;
2697
+ this.syncTimer();
2698
+ };
2699
+ // The release is listened for on the window: a mouse drag can end over an
2700
+ // arrow or off the carousel, where the track never gets the pointerup.
2701
+ this.onPointerDown = (event) => {
2702
+ this.endSwipe();
2703
+ this.swipe = { x: event.clientX, moved: false };
2704
+ globalThis.addEventListener("pointerup", this.onPointerUp);
2705
+ globalThis.addEventListener("pointercancel", this.onPointerCancel);
2706
+ };
2707
+ this.onPointerUp = (event) => {
2708
+ const { swipe } = this;
2709
+ this.removeSwipeListeners();
2710
+ if (!swipe) return;
2711
+ const distance = event.clientX - swipe.x;
2712
+ if (Math.abs(distance) > SWIPE_DISTANCE) {
2713
+ swipe.moved = true;
2714
+ this.step(distance < 0 ? 1 : -1);
2715
+ }
2716
+ };
2717
+ this.onPointerCancel = () => this.endSwipe();
2718
+ // A swipe ends with a click on the card under the pointer: it must not
2719
+ // open the player or select that card.
2720
+ this.onClickCapture = {
2721
+ handleEvent: (event) => {
2722
+ var _a13;
2723
+ if ((_a13 = this.swipe) == null ? void 0 : _a13.moved) {
2724
+ event.stopPropagation();
2725
+ event.preventDefault();
2726
+ }
2727
+ this.swipe = void 0;
2728
+ },
2729
+ capture: true
2730
+ };
2731
+ host.addController(this);
2732
+ }
2733
+ /** Index of the highlighted Story. */
2734
+ get active() {
2735
+ return this.count ? wrap(this.position, this.count) : 0;
2736
+ }
2737
+ get layout() {
2738
+ if (this.count < 2) return "solo";
2739
+ return this.count === 2 && !this.narrow ? "pair" : "rolling";
2740
+ }
2741
+ /** Key (see Slide) of the highlighted slide. */
2742
+ get activeKey() {
2743
+ if (this.layout === "rolling") return this.position;
2744
+ return this.active;
2745
+ }
2746
+ /**
2747
+ * The cards on screen, with their slide: not the hidden ones kept for the
2748
+ * slide in.
2749
+ */
2750
+ *visibleCards() {
2751
+ for (const [card, slide] of this.cards) {
2752
+ if (!slide.hidden) yield [card, slide];
2753
+ }
2754
+ }
2755
+ /** Moves the keyboard focus to the highlighted card, once rendered. */
2756
+ focusActive() {
2757
+ for (const [target, slide] of this.focusTargets) {
2758
+ if (slide.active && target instanceof HTMLElement) {
2759
+ target.focus();
2760
+ return;
2761
+ }
2762
+ }
2763
+ }
2764
+ hostConnected() {
2765
+ var _a13, _b3, _c, _d;
2766
+ this.connected = true;
2767
+ this.media = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis, NARROW_SCREEN.toString());
2768
+ (_b3 = this.media) == null ? void 0 : _b3.addEventListener("change", this.onMediaChange);
2769
+ this.narrow = (_d = (_c = this.media) == null ? void 0 : _c.matches) != null ? _d : false;
2770
+ this.syncTimer();
2771
+ }
2772
+ hostDisconnected() {
2773
+ var _a13;
2774
+ this.connected = false;
2775
+ (_a13 = this.media) == null ? void 0 : _a13.removeEventListener("change", this.onMediaChange);
2776
+ this.media = void 0;
2777
+ this.endSwipe();
2778
+ this.syncTimer();
2779
+ }
2780
+ // Whatever the host changed (the player opening, new Stories) may start or
2781
+ // stop the automatic advance.
2782
+ hostUpdated() {
2783
+ this.syncTimer();
2784
+ }
2785
+ /** For a new list of Stories: the first one gets the highlight. */
2786
+ reset(count) {
2787
+ this.count = count;
2788
+ this.position = 0;
2789
+ this.distance = 1;
2790
+ this.hovered = false;
2791
+ this.focused = false;
2792
+ this.restartTimer();
2793
+ }
2794
+ /**
2795
+ * Moves the highlight by `delta` Stories, wrapping around the ends. While
2796
+ * locked, only with `evenIfLocked` (for example, the player stepping to
2797
+ * the next Story it shows).
2798
+ */
2799
+ step(delta, { evenIfLocked = false } = {}) {
2800
+ var _a13, _b3, _c, _d;
2801
+ if (this.count < 2 || delta === 0) return;
2802
+ if (((_b3 = (_a13 = this.options).locked) == null ? void 0 : _b3.call(_a13)) && !evenIfLocked) return;
2803
+ const from = this.activeKey;
2804
+ this.position += delta;
2805
+ this.distance = Math.abs(delta);
2806
+ this.host.requestUpdate();
2807
+ (_d = (_c = this.options).onStep) == null ? void 0 : _d.call(_c, from, this.activeKey);
2808
+ this.restartTimer();
2809
+ }
2810
+ get shouldAdvance() {
2811
+ var _a13, _b3;
2812
+ return this.connected && this.count > 1 && !this.hovered && !this.focused && !((_b3 = (_a13 = this.options).locked) == null ? void 0 : _b3.call(_a13));
2813
+ }
2814
+ syncTimer() {
2815
+ if (this.shouldAdvance && !this.timer) {
2816
+ this.timer = setInterval(() => this.step(1), AUTO_ADVANCE_MS);
2817
+ } else if (!this.shouldAdvance && this.timer) {
2818
+ this.stopTimer();
2819
+ }
2820
+ }
2821
+ stopTimer() {
2822
+ clearInterval(this.timer);
2823
+ this.timer = void 0;
2824
+ }
2825
+ restartTimer() {
2826
+ this.stopTimer();
2827
+ this.syncTimer();
2828
+ }
2829
+ endSwipe() {
2830
+ this.removeSwipeListeners();
2831
+ this.swipe = void 0;
2832
+ }
2833
+ removeSwipeListeners() {
2834
+ globalThis.removeEventListener("pointerup", this.onPointerUp);
2835
+ globalThis.removeEventListener("pointercancel", this.onPointerCancel);
2836
+ }
2837
+ slide(fields) {
2838
+ const slide = {
2839
+ ...fields,
2840
+ cardRef: (element) => track(element),
2841
+ focusRef: (element) => trackFocus(element)
2842
+ };
2843
+ const track = tracker(this.cards, slide);
2844
+ const trackFocus = tracker(this.focusTargets, slide);
2845
+ return slide;
2846
+ }
2847
+ /** Pair: both Stories, each keyed by its index. */
2848
+ pairSlides() {
2849
+ const { active } = this;
2850
+ return [0, 1].map(
2851
+ (index) => this.slide({
2852
+ key: index,
2853
+ index,
2854
+ offset: index - active,
2855
+ active: index === active,
2856
+ hidden: false
2857
+ })
2858
+ );
2859
+ }
2860
+ /**
2861
+ * Rolling: the slides around the highlighted one, keyed by their position.
2862
+ * Up to VISIBLE_SIDE show on each side, fewer when there aren't enough
2863
+ * Stories to fill both sides without repeating: half on each side, the
2864
+ * extra one after it. With four, the Story opposite the highlighted one
2865
+ * shows at both ends; with two (narrow screens), the other one shows on
2866
+ * both sides.
2867
+ */
2868
+ rollingSlides() {
2869
+ const { count } = this;
2870
+ const even = count === 2 || count === 4;
2871
+ const before = even ? count / 2 : Math.floor((count - 1) / 2);
2872
+ const after = even ? count / 2 : count - 1 - before;
2873
+ const slides = [];
2874
+ for (let offset = -RENDERED_SIDE; offset <= RENDERED_SIDE; offset += 1) {
2875
+ slides.push(
2876
+ this.slide({
2877
+ key: this.position + offset,
2878
+ index: wrap(this.position + offset, count),
2879
+ offset,
2880
+ active: offset === 0,
2881
+ hidden: Math.abs(offset) > VISIBLE_SIDE || offset < -before || offset > after
2882
+ })
2883
+ );
2884
+ }
2885
+ return slides;
2886
+ }
2887
+ renderSlides(items, renderSlide) {
2888
+ const { layout } = this;
2889
+ const slides = layout === "pair" ? this.pairSlides() : this.rollingSlides();
2890
+ return c5(
2891
+ slides,
2892
+ (slide) => `${layout}:${slide.key}`,
2893
+ (slide) => {
2894
+ const { index } = slide;
2895
+ return T`
2896
+ <div
2897
+ class="slide"
2898
+ data-index=${index}
2899
+ ?data-active=${slide.active}
2900
+ ?data-hidden=${slide.hidden}
2901
+ ?inert=${slide.hidden}
2902
+ style=${o8({ "--place": String(slide.offset) })}
2903
+ >
2904
+ ${renderSlide(items[index], slide)}
2905
+ </div>
2906
+ `;
2907
+ }
2908
+ );
2909
+ }
2910
+ /**
2911
+ * One item: the card centered over the background. More: the cards in the
2912
+ * pair or rolling layout, with the arrows.
2913
+ */
2914
+ render(items, renderSlide, labels) {
2915
+ var _a13, _b3, _c;
2916
+ if (this.layout === "solo") {
2917
+ return T`
2918
+ <div class="carousel" data-layout="solo">
2919
+ ${renderSlide(
2920
+ items[0],
2921
+ this.slide({
2922
+ key: 0,
2923
+ index: 0,
2924
+ offset: 0,
2925
+ active: true,
2926
+ hidden: false
2927
+ })
2928
+ )}
2929
+ </div>
2930
+ `;
2931
+ }
2932
+ const locked = (_c = (_b3 = (_a13 = this.options).locked) == null ? void 0 : _b3.call(_a13)) != null ? _c : false;
2933
+ return T`
2934
+ <div
2935
+ class="carousel"
2936
+ data-layout=${this.layout}
2937
+ role="region"
2938
+ aria-roledescription=${labels.carouselRole}
2939
+ aria-label=${labels.carousel}
2940
+ @pointerenter=${this.onPointerEnter}
2941
+ @pointerleave=${this.onPointerLeave}
2942
+ @focusin=${this.onFocusIn}
2943
+ @focusout=${this.onFocusOut}
2944
+ >
2945
+ <div
2946
+ class="track"
2947
+ style=${o8({
2948
+ "--slide-duration": this.distance > 1 ? "0.52s" : "0.4s"
2949
+ })}
2950
+ @pointerdown=${this.onPointerDown}
2951
+ @click=${this.onClickCapture}
2952
+ >
2953
+ ${this.renderSlides(items, renderSlide)}
2954
+ </div>
2955
+ <button
2956
+ type="button"
2957
+ class="arrow arrow-previous"
2958
+ aria-label=${labels.previous}
2959
+ ?disabled=${locked}
2960
+ @click=${() => this.step(-1)}
2961
+ >
2962
+ ${icon("previous")}
2963
+ </button>
2964
+ <button
2965
+ type="button"
2966
+ class="arrow arrow-next"
2967
+ aria-label=${labels.next}
2968
+ ?disabled=${locked}
2969
+ @click=${() => this.step(1)}
2970
+ >
2971
+ ${icon("next")}
2972
+ </button>
2973
+ </div>
2974
+ `;
2975
+ }
2976
+ };
2977
+
2978
+ // src/tag-name.ts
2979
+ var TAG_NAME = "vtex-ads-story-carousel";
2980
+
2981
+ // src/utils/send-event.ts
2982
+ var CONTENT_TYPE = "text/plain;charset=utf-8";
2983
+ function sendEvent(url, { sessionId, userId }) {
2984
+ var _a13, _b3;
2985
+ const target = httpUrl(url);
2986
+ if (!target || globalThis.window === void 0) return false;
2987
+ const body = JSON.stringify(
2988
+ userId ? { session_id: sessionId, user_id: userId } : { session_id: sessionId }
2989
+ );
2990
+ try {
2991
+ const queued = (_b3 = (_a13 = globalThis.navigator) == null ? void 0 : _a13.sendBeacon) == null ? void 0 : _b3.call(
2992
+ _a13,
2993
+ target,
2994
+ new Blob([body], { type: CONTENT_TYPE })
2995
+ );
2996
+ if (queued) return true;
2997
+ } catch (e6) {
2998
+ }
2999
+ if (typeof globalThis.fetch !== "function") return false;
3000
+ globalThis.fetch(target, {
3001
+ method: "POST",
3002
+ headers: { "Content-Type": CONTENT_TYPE },
3003
+ body,
3004
+ keepalive: true,
3005
+ credentials: "omit"
3006
+ }).catch((error) => {
3007
+ console.error(`[${TAG_NAME}] Event request failed`, {
3008
+ url: target,
3009
+ error
3010
+ });
3011
+ });
3012
+ return true;
3013
+ }
3014
+
3015
+ // src/components/events/events-controller.ts
3016
+ var VIEW_THRESHOLD = 0.5;
3017
+ var VIEW_DURATION_MS = 2e3;
3018
+ var URL_FIELD = {
3019
+ impression: "impression_url",
3020
+ view: "view_url",
3021
+ click: "click_url"
3022
+ };
3023
+ var StoryEventsController = class {
3024
+ constructor(host, options) {
3025
+ this.host = host;
3026
+ this.options = options;
3027
+ this.sent = {
3028
+ impression: /* @__PURE__ */ new Set(),
3029
+ view: /* @__PURE__ */ new Set(),
3030
+ click: /* @__PURE__ */ new Set()
3031
+ };
3032
+ this.pendingImpressions = [];
3033
+ this.watched = /* @__PURE__ */ new Map();
3034
+ this.onIntersect = (entries) => {
3035
+ for (const entry of entries) {
3036
+ const watched = this.watched.get(entry.target);
3037
+ if (!watched) continue;
3038
+ watched.visible = entry.isIntersecting && entry.intersectionRatio >= VIEW_THRESHOLD;
3039
+ if (watched.visible) this.startTimer(watched);
3040
+ else this.stopTimer(watched);
3041
+ }
3042
+ };
3043
+ // A hidden page (another tab, minimized) breaks the 2 seconds: they start
3044
+ // over when it shows again.
3045
+ this.onVisibilityChange = () => {
3046
+ for (const watched of this.watched.values()) {
3047
+ if (document.hidden) this.stopTimer(watched);
3048
+ else if (watched.visible) this.startTimer(watched);
3049
+ }
3050
+ };
3051
+ host.addController(this);
3052
+ }
3053
+ hostConnected() {
3054
+ var _a13;
3055
+ if (typeof IntersectionObserver === "function") {
3056
+ this.observer = new IntersectionObserver(this.onIntersect, {
3057
+ threshold: VIEW_THRESHOLD
3058
+ });
3059
+ }
3060
+ (_a13 = globalThis.document) == null ? void 0 : _a13.addEventListener(
3061
+ "visibilitychange",
3062
+ this.onVisibilityChange
3063
+ );
3064
+ this.host.updateComplete.then(() => this.syncViewTargets());
3065
+ }
3066
+ hostDisconnected() {
3067
+ var _a13, _b3;
3068
+ (_a13 = globalThis.document) == null ? void 0 : _a13.removeEventListener(
3069
+ "visibilitychange",
3070
+ this.onVisibilityChange
3071
+ );
3072
+ (_b3 = this.observer) == null ? void 0 : _b3.disconnect();
3073
+ this.observer = void 0;
3074
+ for (const watched of this.watched.values()) clearTimeout(watched.timer);
3075
+ this.watched.clear();
3076
+ this.pendingImpressions = [];
3077
+ }
3078
+ hostUpdated() {
3079
+ const stories = this.pendingImpressions;
3080
+ if (stories.length && this.options.identity().sessionId) {
3081
+ this.pendingImpressions = [];
3082
+ for (const story of stories) this.send("impression", story);
3083
+ }
3084
+ this.syncViewTargets();
3085
+ }
3086
+ /**
3087
+ * The Stories the host renders next: their impressions go out once that
3088
+ * render is done, or, without a session yet, after the first render that
3089
+ * has one. Replaces Stories passed before and not sent yet.
3090
+ */
3091
+ impress(stories) {
3092
+ this.pendingImpressions = stories;
3093
+ }
3094
+ /** A touch on the Story: its click goes out, the first time only. */
3095
+ click(story) {
3096
+ this.send("click", story);
3097
+ }
3098
+ key(sessionId, story) {
3099
+ return `${sessionId}|${story.ad_id}`;
3100
+ }
3101
+ wasSent(kind, story) {
3102
+ const { sessionId } = this.options.identity();
3103
+ return !!sessionId && this.sent[kind].has(this.key(sessionId, story));
3104
+ }
3105
+ send(kind, story) {
3106
+ const { sessionId, userId } = this.options.identity();
3107
+ if (!sessionId || this.wasSent(kind, story)) return;
3108
+ const success = sendEvent(story[URL_FIELD[kind]], { sessionId, userId });
3109
+ if (success) {
3110
+ this.sent[kind].add(this.key(sessionId, story));
3111
+ }
3112
+ }
3113
+ // Watches the elements the host shows now, and stops watching the others,
3114
+ // dropping the time they had on screen.
3115
+ syncViewTargets() {
3116
+ const { observer } = this;
3117
+ if (!observer) return;
3118
+ const current = /* @__PURE__ */ new Map();
3119
+ for (const [element, story] of this.options.viewTargets()) {
3120
+ if (!this.wasSent("view", story)) current.set(element, story);
169
3121
  }
170
-
171
- .card:hover .play,
172
- .card-open:focus-visible .play {
173
- opacity: 1;
174
- transform: translate(-50%, -50%);
3122
+ for (const [element, watched] of this.watched) {
3123
+ if (current.get(element) !== watched.story) {
3124
+ this.unwatch(element, watched);
3125
+ }
3126
+ }
3127
+ for (const [element, story] of current) {
3128
+ if (this.watched.has(element)) continue;
3129
+ this.watched.set(element, { story, visible: false });
3130
+ observer.observe(element);
175
3131
  }
176
3132
  }
177
- `;
178
- function httpUrl(value) {
179
- if (!value) return null;
180
- try {
181
- const { protocol } = new URL(value);
182
- return protocol === "https:" || protocol === "http:" ? value : null;
183
- } catch (e) {
184
- return null;
3133
+ startTimer(watched) {
3134
+ var _a13;
3135
+ if (watched.timer || ((_a13 = globalThis.document) == null ? void 0 : _a13.hidden)) return;
3136
+ watched.timer = setTimeout(() => {
3137
+ watched.timer = void 0;
3138
+ this.send("view", watched.story);
3139
+ if (this.wasSent("view", watched.story)) this.unwatchStory(watched.story);
3140
+ }, VIEW_DURATION_MS);
185
3141
  }
186
- }
187
- function prefersReducedMotion() {
188
- var _a2, _b;
189
- return (_b = (_a2 = globalThis.matchMedia) == null ? void 0 : _a2.call(globalThis, "(prefers-reduced-motion: reduce)").matches) != null ? _b : false;
190
- }
191
- function playVideo(video) {
192
- var _a2;
193
- (_a2 = video.play()) == null ? void 0 : _a2.catch(() => void 0);
194
- }
195
- function createVideo(src, poster) {
196
- const video = document.createElement("video");
197
- video.className = "video";
198
- video.muted = true;
199
- video.setAttribute("muted", "");
200
- video.setAttribute("playsinline", "");
201
- video.loop = true;
202
- video.preload = "metadata";
203
- video.autoplay = !prefersReducedMotion();
204
- if (poster) video.poster = poster;
205
- video.src = src;
206
- video.addEventListener("error", () => video.remove());
207
- return video;
208
- }
209
- function createSoundButton(video, options) {
210
- const button = document.createElement("button");
211
- button.type = "button";
212
- button.className = "card-sound";
213
- function sync() {
214
- button.setAttribute(
215
- "aria-label",
216
- video.muted ? options.soundOnLabel : options.soundOffLabel
217
- );
218
- button.replaceChildren(createIcon(video.muted ? "soundOff" : "soundOn"));
3142
+ stopTimer(watched) {
3143
+ clearTimeout(watched.timer);
3144
+ watched.timer = void 0;
219
3145
  }
220
- video.addEventListener("volumechange", sync);
221
- video.addEventListener("error", () => button.remove());
222
- button.addEventListener("click", () => {
223
- video.muted = !video.muted;
224
- });
225
- sync();
226
- return button;
227
- }
228
- function createCard(story, options) {
229
- const card = document.createElement("div");
230
- card.className = "card";
231
- const posterUrl = httpUrl(story.poster_url);
232
- if (posterUrl) {
233
- const poster = document.createElement("img");
234
- poster.className = "poster";
235
- poster.alt = "";
236
- poster.src = posterUrl;
237
- card.append(poster);
238
- }
239
- const mediaUrl = httpUrl(story.media_url);
240
- const video = mediaUrl ? createVideo(mediaUrl, posterUrl) : null;
241
- if (video) card.append(video);
242
- if (options) {
243
- const open = document.createElement("button");
244
- open.type = "button";
245
- open.className = "card-open";
246
- open.setAttribute("aria-label", options.label);
247
- const play = document.createElement("span");
248
- play.className = "play";
249
- play.setAttribute("aria-hidden", "true");
250
- play.append(createIcon("play"));
251
- open.append(play);
252
- open.addEventListener("click", options.onSelect);
253
- card.append(open);
254
- if (video) card.append(createSoundButton(video, options));
255
- }
256
- return card;
257
- }
3146
+ unwatch(element, watched) {
3147
+ var _a13;
3148
+ this.stopTimer(watched);
3149
+ (_a13 = this.observer) == null ? void 0 : _a13.unobserve(element);
3150
+ this.watched.delete(element);
3151
+ }
3152
+ unwatchStory(story) {
3153
+ for (const [element, watched] of this.watched) {
3154
+ if (watched.story.ad_id === story.ad_id) this.unwatch(element, watched);
3155
+ }
3156
+ }
3157
+ };
258
3158
 
259
3159
  // src/components/player/player.ts
260
- var playerStyles = `
3160
+ var NEAR_GAP = 72;
3161
+ var FAR_GAP = 48;
3162
+ var playerStyles = i`
261
3163
  .player {
262
3164
  position: fixed;
263
3165
  inset: auto 16px 16px auto;
@@ -290,12 +3192,28 @@ var playerStyles = `
290
3192
  background: transparent;
291
3193
  }
292
3194
 
3195
+ /* Focusable only to keep the focus in the player when its video is clicked
3196
+ (see render): no ring around the whole player. */
3197
+ .player:focus {
3198
+ outline: none;
3199
+ }
3200
+
293
3201
  .player-frame {
294
3202
  position: relative;
295
3203
  width: 100%;
296
3204
  height: 100%;
297
3205
  }
298
3206
 
3207
+ /* What moves in the expanded view, off center with two Stories and in the
3208
+ step animation: the video, its dimming and previous and next. Expand and
3209
+ close stay out of it: a transformed box becomes the one their fixed
3210
+ position, at the top right of the screen, is measured from. */
3211
+ .player-stage {
3212
+ position: relative;
3213
+ width: 100%;
3214
+ height: 100%;
3215
+ }
3216
+
299
3217
  .player .card {
300
3218
  width: 100%;
301
3219
  height: 100%;
@@ -342,6 +3260,26 @@ var playerStyles = `
342
3260
  height: 20px;
343
3261
  }
344
3262
 
3263
+ /* The product pill or the call to action. Their wrapper only stops clicks:
3264
+ the pill places itself. The product is larger than on the carousel card
3265
+ (as in the prototype). */
3266
+ .player-destination {
3267
+ display: contents;
3268
+ }
3269
+
3270
+ .player .product-info {
3271
+ font-size: 14px;
3272
+ }
3273
+
3274
+ .player .product-image {
3275
+ width: 72px;
3276
+ height: 72px;
3277
+ }
3278
+
3279
+ .player .product-price {
3280
+ color: rgba(255, 255, 255, 0.7);
3281
+ }
3282
+
345
3283
  /* Above the card: on narrow screens the expanded card can cover them. */
346
3284
  .player-controls {
347
3285
  position: absolute;
@@ -352,6 +3290,12 @@ var playerStyles = `
352
3290
  gap: 8px;
353
3291
  }
354
3292
 
3293
+ /* Previous and next Story, above the card's top left (mini player only). */
3294
+ .player-nav {
3295
+ right: auto;
3296
+ left: 0;
3297
+ }
3298
+
355
3299
  .player-button {
356
3300
  display: grid;
357
3301
  width: 36px;
@@ -405,6 +3349,116 @@ var playerStyles = `
405
3349
  height: 40px;
406
3350
  }
407
3351
 
3352
+ /* Expanded with more than one Story: the other Stories' covers beside the
3353
+ video, smaller and dimmed, as in the prototype. --side is -1 (before)
3354
+ or 1 (after), --beyond how many places past the nearest one. */
3355
+ .player[data-expanded] {
3356
+ --center-height: min(78vh, 720px);
3357
+ --side-height: min(38vh, 320px);
3358
+ --side-width: calc(var(--side-height) * 9 / 16);
3359
+ --center-half: calc(var(--center-height) * 9 / 32);
3360
+ --near-gap: ${NEAR_GAP}px;
3361
+ --far-gap: ${FAR_GAP}px;
3362
+ --near: calc(var(--center-half) + var(--near-gap) + var(--side-width) / 2);
3363
+ --pitch: calc(var(--side-width) + var(--far-gap));
3364
+ }
3365
+
3366
+ .player-neighbor {
3367
+ position: absolute;
3368
+ top: 50%;
3369
+ left: 50%;
3370
+ width: var(--side-width);
3371
+ height: var(--side-height);
3372
+ padding: 0;
3373
+ overflow: hidden;
3374
+ border: 0;
3375
+ border-radius: 16px;
3376
+ background: #111;
3377
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
3378
+ cursor: pointer;
3379
+ transform: translate(
3380
+ calc(-50% + var(--side) * var(--near) + var(--beyond) * var(--pitch)),
3381
+ -50%
3382
+ );
3383
+ }
3384
+
3385
+ .player-neighbor img {
3386
+ width: 100%;
3387
+ height: 100%;
3388
+ object-fit: cover;
3389
+ }
3390
+
3391
+ /* Fades out as the video arrives from a dimmed cover (see animateStep). */
3392
+ .player-dim {
3393
+ position: absolute;
3394
+ inset: 0;
3395
+ z-index: 3;
3396
+ border-radius: var(--vtex-ads-story-radius, 20px);
3397
+ background: rgba(0, 0, 0, 0.35);
3398
+ opacity: 0;
3399
+ pointer-events: none;
3400
+ }
3401
+
3402
+ .player-neighbor::after {
3403
+ position: absolute;
3404
+ inset: 0;
3405
+ background: rgba(0, 0, 0, 0.35);
3406
+ content: "";
3407
+ }
3408
+
3409
+ .player-neighbor:hover::after,
3410
+ .player-neighbor:focus-visible::after {
3411
+ background: rgba(0, 0, 0, 0.12);
3412
+ }
3413
+
3414
+ .player-neighbor:focus-visible {
3415
+ outline: 2px solid #fff;
3416
+ outline-offset: 2px;
3417
+ }
3418
+
3419
+ /* Two Stories: the video moves off center toward --pair-dir, and the other
3420
+ Story sits on the other side. */
3421
+ .player[data-pair] .player-stage {
3422
+ transform: translateX(
3423
+ calc(var(--pair-dir) * (var(--near-gap) + var(--side-width)) / 2)
3424
+ );
3425
+ }
3426
+
3427
+ .player[data-pair] .player-neighbor {
3428
+ transform: translate(
3429
+ calc(
3430
+ -50% + var(--pair-dir) * -1 * (var(--center-half) + var(--near-gap) / 2)
3431
+ ),
3432
+ -50%
3433
+ );
3434
+ }
3435
+
3436
+ /* Expanded previous and next: beside the video, centered on its height. */
3437
+ .player[data-expanded] .player-nav {
3438
+ position: static;
3439
+ display: contents;
3440
+ }
3441
+
3442
+ .player[data-expanded] .player-nav .player-button {
3443
+ position: absolute;
3444
+ top: 50%;
3445
+ z-index: 2;
3446
+ transform: translateY(-50%);
3447
+ }
3448
+
3449
+ .player[data-expanded] .player-previous {
3450
+ left: -56px;
3451
+ }
3452
+
3453
+ .player[data-expanded] .player-next {
3454
+ right: -56px;
3455
+ }
3456
+
3457
+ /* With two, the other Story's cover beside the video does that. */
3458
+ .player[data-expanded][data-pair] .player-nav {
3459
+ display: none;
3460
+ }
3461
+
408
3462
  @media (max-width: 576px) {
409
3463
  .player {
410
3464
  right: 12px;
@@ -412,6 +3466,18 @@ var playerStyles = `
412
3466
  height: 391px;
413
3467
  }
414
3468
 
3469
+ .player:not([data-expanded]) .product-image {
3470
+ width: 56px;
3471
+ height: 56px;
3472
+ }
3473
+
3474
+ /* "Adicionar ao carrinho" fits on one line in the narrow mini player. */
3475
+ .player:not([data-expanded]) .product-action {
3476
+ height: 40px;
3477
+ padding: 0 8px;
3478
+ font-size: 12px;
3479
+ }
3480
+
415
3481
  .player[data-expanded] {
416
3482
  background: #000;
417
3483
  }
@@ -434,6 +3500,28 @@ var playerStyles = `
434
3500
  top: 60px;
435
3501
  right: 12px;
436
3502
  }
3503
+
3504
+ /* No room for the other Stories' covers: previous and next go inside
3505
+ the video's edges instead, also with two. */
3506
+ .player-neighbor {
3507
+ display: none;
3508
+ }
3509
+
3510
+ .player[data-pair] .player-stage {
3511
+ transform: none;
3512
+ }
3513
+
3514
+ .player[data-expanded][data-pair] .player-nav {
3515
+ display: contents;
3516
+ }
3517
+
3518
+ .player[data-expanded] .player-previous {
3519
+ left: 12px;
3520
+ }
3521
+
3522
+ .player[data-expanded] .player-next {
3523
+ right: 12px;
3524
+ }
437
3525
  }
438
3526
 
439
3527
  @keyframes player-in {
@@ -449,138 +3537,759 @@ var playerStyles = `
449
3537
  }
450
3538
  }
451
3539
  `;
452
- function createButton(className, label, icon) {
453
- const button = document.createElement("button");
454
- button.type = "button";
455
- button.className = `player-button ${className}`;
456
- button.setAttribute("aria-label", label);
457
- button.append(createIcon(icon));
458
- return button;
459
- }
460
- function supportsPopover(player) {
461
- return typeof player.showPopover === "function";
462
- }
463
- function showPlayer(player) {
464
- if (supportsPopover(player)) player.showPopover();
465
- else player.show();
466
- }
467
- function playPlayer(player) {
468
- const video = player.querySelector("video");
469
- if (video) playVideo(video);
470
- }
471
- function addVideoControls(player, card, video, options) {
472
- const toggle = document.createElement("button");
473
- toggle.type = "button";
474
- toggle.className = "play player-toggle";
475
- const sound = createButton("player-sound", "", "soundOff");
476
- function syncPlayback() {
477
- player.toggleAttribute("data-paused", video.paused);
478
- toggle.setAttribute(
479
- "aria-label",
480
- video.paused ? options.playLabel : options.pauseLabel
3540
+ function neighborOffsets(count, active) {
3541
+ if (count < 2) return [];
3542
+ if (count === 2) return [active === 0 ? 1 : -1];
3543
+ const offsets = [];
3544
+ const shown = /* @__PURE__ */ new Set([0]);
3545
+ for (const offset of [-1, 1, -2, 2]) {
3546
+ const index = (offset % count + count) % count;
3547
+ if (!shown.has(index)) {
3548
+ shown.add(index);
3549
+ offsets.push(offset);
3550
+ }
3551
+ }
3552
+ return offsets;
3553
+ }
3554
+ var STEP_ANIMATION = {
3555
+ duration: 560,
3556
+ easing: "cubic-bezier(0.32, 0.72, 0, 1)"
3557
+ };
3558
+ var coverTransform = (x2, scale = 1) => `translate(-50%, -50%) translateX(${x2}px) scale(${scale})`;
3559
+ var fadeIn = (element) => element.animate([{ opacity: 0 }, { opacity: 1 }], {
3560
+ ...STEP_ANIMATION,
3561
+ pseudoElement: "::after"
3562
+ });
3563
+ function animateRailStep(frame, frameFrom, neighbors, { frameWidth, sideWidth }) {
3564
+ const placeX = (place) => {
3565
+ if (place === 0) return 0;
3566
+ const side = Math.sign(place);
3567
+ const near = frameWidth / 2 + NEAR_GAP + sideWidth / 2;
3568
+ return side * near + (place - side) * (sideWidth + FAR_GAP);
3569
+ };
3570
+ const ratio = sideWidth / frameWidth;
3571
+ const animations = [
3572
+ frame.animate(
3573
+ [
3574
+ { transform: `translateX(${placeX(frameFrom)}px) scale(${ratio})` },
3575
+ { transform: "none" }
3576
+ ],
3577
+ STEP_ANIMATION
3578
+ )
3579
+ ];
3580
+ for (const { element, offset, from } of neighbors) {
3581
+ const wasVideo = from === 0;
3582
+ animations.push(
3583
+ element.animate(
3584
+ [
3585
+ { transform: coverTransform(placeX(from), wasVideo ? 1 / ratio : 1) },
3586
+ { transform: coverTransform(placeX(offset)) }
3587
+ ],
3588
+ STEP_ANIMATION
3589
+ )
481
3590
  );
482
- toggle.replaceChildren(createIcon(video.paused ? "play" : "pause"));
3591
+ if (wasVideo) animations.push(fadeIn(element));
3592
+ }
3593
+ return animations;
3594
+ }
3595
+ function animatePairStep(frame, neighbor, direction, { frameWidth, sideWidth }) {
3596
+ const videoX = (side) => side * (NEAR_GAP + sideWidth) / 2;
3597
+ const coverX = (side) => -side * (frameWidth + NEAR_GAP) / 2;
3598
+ const ratio = sideWidth / frameWidth;
3599
+ return [
3600
+ frame.animate(
3601
+ [
3602
+ { transform: `translateX(${coverX(-direction)}px) scale(${ratio})` },
3603
+ { transform: `translateX(${videoX(direction)}px)` }
3604
+ ],
3605
+ STEP_ANIMATION
3606
+ ),
3607
+ neighbor.animate(
3608
+ [
3609
+ { transform: coverTransform(videoX(-direction), 1 / ratio) },
3610
+ { transform: coverTransform(coverX(direction)) }
3611
+ ],
3612
+ STEP_ANIMATION
3613
+ ),
3614
+ fadeIn(neighbor)
3615
+ ];
3616
+ }
3617
+ var ARROW_STEPS = {
3618
+ ArrowLeft: -1,
3619
+ ArrowRight: 1
3620
+ };
3621
+ var isFreeArrowKey = (event) => !event.defaultPrevented && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
3622
+ function supportsPopover(dialog) {
3623
+ return typeof dialog.showPopover === "function";
3624
+ }
3625
+ var PlayerController = class {
3626
+ constructor(host, options) {
3627
+ this.host = host;
3628
+ this.options = options;
3629
+ /** Rendered and, once the host has updated, shown. */
3630
+ this.isOpen = false;
3631
+ this.expanded = false;
3632
+ /** The product panel is open. Closed again on a step and on opening. */
3633
+ this.productOpen = false;
3634
+ /** Switched modes at least once: only the first opening fades in. */
3635
+ this.switched = false;
3636
+ /** The dialog is showing, in the mode `expanded` says. */
3637
+ this.shown = false;
3638
+ this.dialog = e4();
3639
+ this.expandButton = e4();
3640
+ this.closeButton = e4();
3641
+ this.stage = e4();
3642
+ this.stageCardRef = e4();
3643
+ this.dim = e4();
3644
+ /** The covers beside the expanded video, by offset, as rendered. */
3645
+ this.neighborElements = /* @__PURE__ */ new Map();
3646
+ /** One ref callback per offset: a new one each render would detach it. */
3647
+ this.neighborRefs = /* @__PURE__ */ new Map();
3648
+ /** Rendered with previous and next (see PlayerRenderOptions). */
3649
+ this.navigation = false;
3650
+ /** Side the expanded video moved to with two Stories; 0 otherwise. */
3651
+ this.pairDirection = 0;
3652
+ /** The step animation running, cancelled by the next step. */
3653
+ this.animations = [];
3654
+ this.toggleExpanded = async () => {
3655
+ var _a13;
3656
+ const dialog = this.dialog.value;
3657
+ if (!dialog) return;
3658
+ this.cancelAnimations();
3659
+ this.hide(dialog);
3660
+ this.expanded = !this.expanded;
3661
+ this.switched = true;
3662
+ this.host.requestUpdate();
3663
+ await this.host.updateComplete;
3664
+ if (!this.isOpen) return;
3665
+ this.show(dialog);
3666
+ (_a13 = this.expandButton.value) == null ? void 0 : _a13.focus();
3667
+ };
3668
+ // Escape anywhere on the page, also in the mini player, which is not modal.
3669
+ this.onKeyDown = (event) => {
3670
+ if (event.key === "Escape") this.options.onClose();
3671
+ };
3672
+ // With the focus in the player and more than one Story, the arrows step, as
3673
+ // the previous and next buttons do. Only there: the mini player leaves the
3674
+ // page usable, and the page's own arrow keys (a gallery, a slider) keep
3675
+ // working.
3676
+ this.onPlayerKeyDown = (event) => {
3677
+ var _a13, _b3;
3678
+ const delta = ARROW_STEPS[event.key];
3679
+ if (!delta || !this.navigation || !isFreeArrowKey(event)) return;
3680
+ event.preventDefault();
3681
+ (_b3 = (_a13 = this.options).onStep) == null ? void 0 : _b3.call(_a13, delta);
3682
+ };
3683
+ // Clicks on the backdrop of the expanded view reach the dialog itself.
3684
+ this.onDialogClick = (event) => {
3685
+ if (this.expanded && event.target === event.currentTarget) {
3686
+ this.options.onClose();
3687
+ }
3688
+ };
3689
+ // Escape on a modal dialog would only hide it: close the player instead.
3690
+ this.onCancel = (event) => {
3691
+ event.preventDefault();
3692
+ this.options.onClose();
3693
+ };
3694
+ /**
3695
+ * Play/pause in the middle of the video and sound on/off at its top right.
3696
+ * They follow the video's own events, so a blocked autoplay shows as
3697
+ * paused.
3698
+ */
3699
+ this.toggleProduct = () => {
3700
+ this.productOpen = !this.productOpen;
3701
+ this.host.requestUpdate();
3702
+ };
3703
+ /**
3704
+ * A click on the video: closes the product panel when it is open, plays or
3705
+ * pauses the video otherwise.
3706
+ */
3707
+ this.onVideoClick = () => {
3708
+ if (this.productOpen) this.toggleProduct();
3709
+ else this.video.togglePlayback();
3710
+ };
3711
+ host.addController(this);
3712
+ this.video = new VideoController(host);
3713
+ }
3714
+ /** Open in the expanded view, a modal over the page. */
3715
+ get isExpanded() {
3716
+ return this.isOpen && this.expanded;
3717
+ }
3718
+ /** The card with the video, while the player is open. */
3719
+ get stageCard() {
3720
+ return this.isOpen ? this.stageCardRef.value : void 0;
3721
+ }
3722
+ hostDisconnected() {
3723
+ this.close();
3724
+ }
3725
+ /**
3726
+ * Opens the mini player, plays the video and focuses the close button.
3727
+ * With `productOpen`, the product panel shows open (the shopper chose the
3728
+ * product).
3729
+ */
3730
+ async open({ productOpen = false } = {}) {
3731
+ var _a13;
3732
+ if (this.isOpen) return;
3733
+ document.addEventListener("keydown", this.onKeyDown);
3734
+ this.isOpen = true;
3735
+ this.expanded = false;
3736
+ this.productOpen = productOpen;
3737
+ this.switched = false;
3738
+ this.rendered = void 0;
3739
+ this.beforeStep = void 0;
3740
+ this.video.reset();
3741
+ this.host.requestUpdate();
3742
+ await this.host.updateComplete;
3743
+ const dialog = this.dialog.value;
3744
+ if (!this.isOpen || !dialog) return;
3745
+ this.show(dialog);
3746
+ this.video.play();
3747
+ (_a13 = this.closeButton.value) == null ? void 0 : _a13.focus();
3748
+ }
3749
+ /** Hides the player now; the host removes it on its next update. */
3750
+ close() {
3751
+ if (!this.isOpen) return;
3752
+ document.removeEventListener("keydown", this.onKeyDown);
3753
+ this.cancelAnimations();
3754
+ const dialog = this.dialog.value;
3755
+ if (dialog) this.hide(dialog);
3756
+ this.isOpen = false;
3757
+ this.host.requestUpdate();
3758
+ }
3759
+ /**
3760
+ * After the host renders a different Story in the open player, `delta`
3761
+ * places from the previous one: its video starts from the top and plays,
3762
+ * with the sound as the shopper left it. A failed load of the previous
3763
+ * video doesn't hide the new one. The expanded view animates the step.
3764
+ */
3765
+ async showNext(delta = 0) {
3766
+ if (!this.isOpen) return;
3767
+ const withSound = !this.video.muted;
3768
+ this.video.failed = false;
3769
+ this.productOpen = false;
3770
+ this.host.requestUpdate();
3771
+ await this.host.updateComplete;
3772
+ if (!this.isOpen) return;
3773
+ this.video.restart({ withSound });
3774
+ this.animateStep(delta);
3775
+ }
3776
+ /** Stops a step animation still running, leaving the CSS layout. */
3777
+ cancelAnimations() {
3778
+ for (const animation of this.animations) animation.cancel();
3779
+ this.animations = [];
3780
+ }
3781
+ /**
3782
+ * The expanded step, as in the prototype: the video grows from the cover
3783
+ * of the Story it now shows, and the covers slide to their new places, the
3784
+ * previous Story's shrinking from the video's size. With two Stories, the
3785
+ * video and the other cover swap sides. Not with reduced motion, nor
3786
+ * without covers (narrow screens).
3787
+ */
3788
+ animateStep(delta) {
3789
+ var _a13, _b3;
3790
+ if (!this.expanded || delta === 0 || prefersReducedMotion()) return;
3791
+ const frame = this.stage.value;
3792
+ const dim = this.dim.value;
3793
+ if (!frame || !dim || typeof frame.animate !== "function") return;
3794
+ const { rendered, beforeStep } = this;
3795
+ const placeBefore = (story, fallback) => {
3796
+ var _a14;
3797
+ if (!story || !beforeStep) return fallback;
3798
+ if (story === beforeStep.story) return 0;
3799
+ const cover = beforeStep.neighbors.find((n7) => n7.story === story);
3800
+ return (_a14 = cover == null ? void 0 : cover.offset) != null ? _a14 : fallback;
3801
+ };
3802
+ const neighbors = [...this.neighborElements].map(([offset, element]) => {
3803
+ var _a14;
3804
+ return {
3805
+ offset,
3806
+ element,
3807
+ from: placeBefore(
3808
+ (_a14 = rendered == null ? void 0 : rendered.neighbors.find((n7) => n7.offset === offset)) == null ? void 0 : _a14.story,
3809
+ offset + delta
3810
+ )
3811
+ };
3812
+ });
3813
+ const sizes = {
3814
+ frameWidth: frame.offsetWidth,
3815
+ sideWidth: (_b3 = (_a13 = neighbors[0]) == null ? void 0 : _a13.element.offsetWidth) != null ? _b3 : 0
3816
+ };
3817
+ if (!sizes.frameWidth || !sizes.sideWidth) return;
3818
+ this.cancelAnimations();
3819
+ this.animations = [
3820
+ dim.animate([{ opacity: 1 }, { opacity: 0 }], STEP_ANIMATION),
3821
+ ...this.pairDirection ? animatePairStep(
3822
+ frame,
3823
+ neighbors[0].element,
3824
+ this.pairDirection,
3825
+ sizes
3826
+ ) : animateRailStep(
3827
+ frame,
3828
+ placeBefore(rendered == null ? void 0 : rendered.story, delta),
3829
+ neighbors,
3830
+ sizes
3831
+ )
3832
+ ];
3833
+ }
3834
+ // Keeps neighborElements in step with the covers Lit renders.
3835
+ neighborRef(offset) {
3836
+ let callback = this.neighborRefs.get(offset);
3837
+ if (!callback) {
3838
+ callback = (element) => {
3839
+ if (element) this.neighborElements.set(offset, element);
3840
+ else this.neighborElements.delete(offset);
3841
+ };
3842
+ this.neighborRefs.set(offset, callback);
3843
+ }
3844
+ return callback;
3845
+ }
3846
+ // Mini: a manual popover, or a non-modal dialog without popover support.
3847
+ // Expanded: a modal dialog.
3848
+ // Already showing: a second expand click in the same task resumes after the
3849
+ // first one has shown the dialog, and showing it again would throw.
3850
+ show(dialog) {
3851
+ if (this.shown) return;
3852
+ if (this.expanded) dialog.showModal();
3853
+ else if (supportsPopover(dialog)) dialog.showPopover();
3854
+ else dialog.show();
3855
+ this.shown = true;
3856
+ }
3857
+ // A dialog can't be shown as a popover and as a modal at the same time, so
3858
+ // switching modes hides it first, the same way it was shown.
3859
+ hide(dialog) {
3860
+ if (!this.shown) return;
3861
+ if (!this.expanded && supportsPopover(dialog)) dialog.hidePopover();
3862
+ else dialog.close();
3863
+ this.shown = false;
3864
+ }
3865
+ /**
3866
+ * At the bottom of the video, the product pill, which opens the panel with
3867
+ * its actions, or the call to action of a link destination. Clicks on them
3868
+ * don't reach the video.
3869
+ */
3870
+ renderDestination({ product, cta, labels }) {
3871
+ let content;
3872
+ if (product) {
3873
+ content = renderExpandableProduct(product, {
3874
+ open: this.productOpen,
3875
+ onToggle: this.toggleProduct,
3876
+ panelId: "player-product-panel",
3877
+ labels
3878
+ });
3879
+ } else if (cta) {
3880
+ content = renderCta(cta);
3881
+ } else {
3882
+ return A;
3883
+ }
3884
+ return T`
3885
+ <div
3886
+ class="player-destination"
3887
+ @click=${(event) => event.stopPropagation()}
3888
+ >
3889
+ ${content}
3890
+ </div>
3891
+ `;
3892
+ }
3893
+ renderVideoControls(labels) {
3894
+ const { video } = this;
3895
+ const onToggle = (event) => {
3896
+ event.stopPropagation();
3897
+ video.togglePlayback();
3898
+ };
3899
+ const onSound = (event) => {
3900
+ event.stopPropagation();
3901
+ video.toggleMuted();
3902
+ };
3903
+ return T`
3904
+ <button
3905
+ type="button"
3906
+ class="play player-toggle"
3907
+ aria-label=${video.paused ? labels.play : labels.pause}
3908
+ @click=${onToggle}
3909
+ >
3910
+ ${icon(video.paused ? "play" : "pause")}
3911
+ </button>
3912
+ <button
3913
+ type="button"
3914
+ class="player-button player-sound"
3915
+ aria-label=${video.muted ? labels.soundOn : labels.soundOff}
3916
+ @click=${onSound}
3917
+ >
3918
+ ${icon(video.muted ? "soundOff" : "soundOn")}
3919
+ </button>
3920
+ `;
483
3921
  }
484
- function syncSound() {
485
- sound.setAttribute(
486
- "aria-label",
487
- video.muted ? options.soundOnLabel : options.soundOffLabel
3922
+ /**
3923
+ * Previous and next Story: above the mini player's top left, beside the
3924
+ * expanded video.
3925
+ */
3926
+ renderNavigation(labels) {
3927
+ const { options } = this;
3928
+ const step = (delta) => () => {
3929
+ var _a13;
3930
+ return (_a13 = options.onStep) == null ? void 0 : _a13.call(options, delta);
3931
+ };
3932
+ return T`
3933
+ <div class="player-controls player-nav">
3934
+ <button
3935
+ type="button"
3936
+ class="player-button player-previous"
3937
+ aria-label=${labels.previous}
3938
+ @click=${step(-1)}
3939
+ >
3940
+ ${icon("previous")}
3941
+ </button>
3942
+ <button
3943
+ type="button"
3944
+ class="player-button player-next"
3945
+ aria-label=${labels.next}
3946
+ @click=${step(1)}
3947
+ >
3948
+ ${icon("next")}
3949
+ </button>
3950
+ </div>
3951
+ `;
3952
+ }
3953
+ /** The other Stories' covers beside the expanded video. */
3954
+ renderNeighbors(neighbors, labels) {
3955
+ const { options } = this;
3956
+ return c5(
3957
+ neighbors,
3958
+ ({ offset }) => neighbors.length === 1 ? "single" : offset,
3959
+ ({ offset, story, label }) => {
3960
+ const poster = httpUrl(story.poster_url);
3961
+ const side = Math.sign(offset);
3962
+ return T`
3963
+ <button
3964
+ type="button"
3965
+ class="player-neighbor"
3966
+ aria-label=${label != null ? label : labels.show}
3967
+ style=${o8({
3968
+ "--side": String(side),
3969
+ "--beyond": String(offset - side)
3970
+ })}
3971
+ ${n5(this.neighborRef(offset))}
3972
+ @click=${() => {
3973
+ var _a13;
3974
+ return (_a13 = options.onStep) == null ? void 0 : _a13.call(options, offset);
3975
+ }}
3976
+ >
3977
+ ${poster ? T`<img alt="" src=${poster} />` : A}
3978
+ </button>
3979
+ `;
3980
+ }
488
3981
  );
489
- sound.replaceChildren(createIcon(video.muted ? "soundOff" : "soundOn"));
490
3982
  }
491
- function togglePlayback() {
492
- if (video.paused) playVideo(video);
493
- else video.pause();
3983
+ /** Expand or collapse, and close: above the video, or at the top right. */
3984
+ renderWindowControls(labels) {
3985
+ const { options, expanded } = this;
3986
+ return T`
3987
+ <div class="player-controls">
3988
+ <button
3989
+ type="button"
3990
+ class="player-button player-expand"
3991
+ aria-label=${expanded ? labels.collapse : labels.expand}
3992
+ ${n5(this.expandButton)}
3993
+ @click=${this.toggleExpanded}
3994
+ >
3995
+ ${icon(expanded ? "collapse" : "expand")}
3996
+ </button>
3997
+ <button
3998
+ type="button"
3999
+ class="player-button player-close"
4000
+ aria-label=${labels.close}
4001
+ ${n5(this.closeButton)}
4002
+ @click=${options.onClose}
4003
+ >
4004
+ ${icon("close")}
4005
+ </button>
4006
+ </div>
4007
+ `;
494
4008
  }
495
- video.addEventListener("play", syncPlayback);
496
- video.addEventListener("pause", syncPlayback);
497
- video.addEventListener("volumechange", syncSound);
498
- video.addEventListener("error", () => {
499
- toggle.remove();
500
- sound.remove();
501
- delete player.dataset.paused;
502
- });
503
- toggle.addEventListener("click", (event) => {
504
- event.stopPropagation();
505
- togglePlayback();
506
- });
507
- sound.addEventListener("click", (event) => {
508
- event.stopPropagation();
509
- video.muted = !video.muted;
510
- });
511
- card.addEventListener("click", () => {
512
- if (video.isConnected) togglePlayback();
513
- });
514
- syncPlayback();
515
- syncSound();
516
- card.append(toggle, sound);
517
- }
518
- function createPlayer(story, options) {
519
- const player = document.createElement("dialog");
520
- player.className = "player";
521
- player.setAttribute("popover", "manual");
522
- player.setAttribute("aria-label", options.label);
523
- const frame = document.createElement("div");
524
- frame.className = "player-frame";
525
- const controls = document.createElement("div");
526
- controls.className = "player-controls";
527
- const expand = createButton("player-expand", options.expandLabel, "expand");
528
- const close = createButton("player-close", options.closeLabel, "close");
529
- controls.append(expand, close);
530
- let expanded = false;
531
- function hide() {
532
- if (!expanded && supportsPopover(player)) player.hidePopover();
533
- else player.close();
534
- }
535
- expand.addEventListener("click", () => {
536
- hide();
537
- expanded = !expanded;
538
- player.toggleAttribute("data-expanded", expanded);
539
- player.dataset.switched = "";
540
- expand.setAttribute(
541
- "aria-label",
542
- expanded ? options.collapseLabel : options.expandLabel
4009
+ /**
4010
+ * The video with its controls and the product or call to action. With
4011
+ * `advances`, it plays once and moves on to the next Story when it ends;
4012
+ * otherwise it loops.
4013
+ */
4014
+ renderVideo(story, advances, destination) {
4015
+ const { video, options } = this;
4016
+ return T`
4017
+ <div class="card" ${n5(this.stageCardRef)} @click=${this.onVideoClick}>
4018
+ ${renderMedia(story, video, {
4019
+ loop: !advances,
4020
+ onEnded: advances ? () => {
4021
+ var _a13;
4022
+ return (_a13 = options.onStep) == null ? void 0 : _a13.call(options, 1);
4023
+ } : void 0
4024
+ })}
4025
+ ${hasVideo(story, video) ? this.renderVideoControls(destination.labels) : A}
4026
+ ${this.renderDestination(destination)}
4027
+ </div>
4028
+ `;
4029
+ }
4030
+ /**
4031
+ * Keeps what this render shows, for the step animation: the covers beside
4032
+ * the video (only in the expanded view) and the side the video moves to
4033
+ * with two Stories. A new Story makes what was shown the animation's
4034
+ * start.
4035
+ */
4036
+ track(story, neighbors) {
4037
+ const shown = this.expanded ? neighbors : [];
4038
+ this.pairDirection = shown.length === 1 ? -Math.sign(shown[0].offset) : 0;
4039
+ if (this.rendered && story !== this.rendered.story) {
4040
+ this.beforeStep = this.rendered;
4041
+ }
4042
+ this.rendered = { story, neighbors: shown };
4043
+ return shown;
4044
+ }
4045
+ /**
4046
+ * The player <dialog> while it is open. Clicking the video also plays or
4047
+ * pauses it, and keeps the focus in the player (the dialog is focusable,
4048
+ * though not by Tab), so the arrow keys still step. With `navigation`
4049
+ * (more than one Story), it has previous and next buttons and arrow keys,
4050
+ * and the expanded view moves on when the video ends instead of looping.
4051
+ * The expanded view also shows the `neighbors` beside it.
4052
+ */
4053
+ render(story, {
4054
+ labels,
4055
+ navigation = false,
4056
+ neighbors = [],
4057
+ product,
4058
+ cta,
4059
+ onPress
4060
+ }) {
4061
+ if (!this.isOpen) return A;
4062
+ const { video, expanded } = this;
4063
+ const shownNeighbors = this.track(story, neighbors);
4064
+ const pair = this.pairDirection !== 0;
4065
+ this.navigation = navigation;
4066
+ return T`
4067
+ <dialog
4068
+ class="player"
4069
+ popover="manual"
4070
+ aria-label=${labels.player}
4071
+ ?data-expanded=${expanded}
4072
+ ?data-pair=${pair}
4073
+ style=${o8({
4074
+ "--pair-dir": pair ? String(this.pairDirection) : void 0
4075
+ })}
4076
+ ?data-switched=${this.switched}
4077
+ ?data-paused=${hasVideo(story, video) && video.paused}
4078
+ tabindex="-1"
4079
+ ${n5(this.dialog)}
4080
+ @click=${this.onDialogClick}
4081
+ @cancel=${this.onCancel}
4082
+ @keydown=${this.onPlayerKeyDown}
4083
+ >
4084
+ ${this.renderNeighbors(shownNeighbors, labels)}
4085
+ <div class="player-frame">
4086
+ ${this.renderWindowControls(labels)}
4087
+ <div
4088
+ class="player-stage"
4089
+ ${n5(this.stage)}
4090
+ @click=${{
4091
+ handleEvent: (event) => {
4092
+ const card = this.stageCardRef.value;
4093
+ if (card == null ? void 0 : card.contains(event.target)) onPress == null ? void 0 : onPress();
4094
+ },
4095
+ capture: true
4096
+ }}
4097
+ >
4098
+ ${navigation ? this.renderNavigation(labels) : A}
4099
+ ${this.renderVideo(story, navigation && expanded, {
4100
+ product,
4101
+ cta,
4102
+ labels
4103
+ })}
4104
+ <span class="player-dim" aria-hidden="true" ${n5(this.dim)}></span>
4105
+ </div>
4106
+ </div>
4107
+ </dialog>
4108
+ `;
4109
+ }
4110
+ };
4111
+
4112
+ // src/utils/hydrate-products.ts
4113
+ var import_ads_core = require("@vtex/ads-core");
4114
+
4115
+ // src/utils/with-timeout.ts
4116
+ var withTimeout = (timeout, fallback, signal) => {
4117
+ const ms = timeout !== void 0 && Number.isFinite(timeout) && timeout > 0 ? timeout : fallback;
4118
+ const controller = new AbortController();
4119
+ const timer = setTimeout(
4120
+ () => controller.abort(
4121
+ new DOMException(`Timed out after ${ms} ms`, "TimeoutError")
4122
+ ),
4123
+ ms
4124
+ );
4125
+ const onAbort = () => controller.abort(signal == null ? void 0 : signal.reason);
4126
+ if (signal == null ? void 0 : signal.aborted) {
4127
+ onAbort();
4128
+ } else {
4129
+ signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
4130
+ }
4131
+ return {
4132
+ signal: controller.signal,
4133
+ clear: () => {
4134
+ clearTimeout(timer);
4135
+ signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
4136
+ }
4137
+ };
4138
+ };
4139
+
4140
+ // src/utils/hydrate-products.ts
4141
+ var DEFAULT_HYDRATION_TIMEOUT_MS = 5e3;
4142
+ var intelligentSearchHydration = {
4143
+ fetcher: import_ads_core.intelligentSearchFetcher,
4144
+ matcher: import_ads_core.intelligentSearchMatcher,
4145
+ price: import_ads_core.intelligentSearchPrice,
4146
+ available: import_ads_core.intelligentSearchAvailability
4147
+ };
4148
+ async function hydrateStoryProducts(placement, stories, hydration, identity, { signal, timeout } = {}) {
4149
+ var _a13, _b3;
4150
+ const products = /* @__PURE__ */ new Map();
4151
+ const limit = withTimeout(timeout, DEFAULT_HYDRATION_TIMEOUT_MS, signal);
4152
+ try {
4153
+ const hydrated = await (0, import_ads_core.hydrateAds)(
4154
+ { stories: { [placement]: stories } },
4155
+ hydration.fetcher,
4156
+ (product, offer) => hydration.matcher(product, offer),
4157
+ identity,
4158
+ { signal: limit.signal }
543
4159
  );
544
- expand.replaceChildren(createIcon(expanded ? "collapse" : "expand"));
545
- if (expanded) player.showModal();
546
- else showPlayer(player);
547
- expand.focus();
548
- });
549
- close.addEventListener("click", options.onClose);
550
- player.addEventListener("click", (event) => {
551
- if (expanded && event.target === player) options.onClose();
552
- });
553
- player.addEventListener("cancel", (event) => {
554
- event.preventDefault();
555
- options.onClose();
556
- });
557
- const card = createCard(story);
558
- const video = card.querySelector("video");
559
- if (video) addVideoControls(player, card, video, options);
560
- frame.append(controls, card);
561
- player.append(frame);
562
- return player;
4160
+ for (const { story, product, offer } of (_a13 = hydrated.stories[placement]) != null ? _a13 : []) {
4161
+ if (!product || !offer) continue;
4162
+ const price = hydration.price(product, offer);
4163
+ const available = (_b3 = hydration.available) == null ? void 0 : _b3.call(hydration, product, offer);
4164
+ products.set(story.ad_id, {
4165
+ ...price && { price },
4166
+ ...available !== void 0 && { available }
4167
+ });
4168
+ }
4169
+ } catch (error) {
4170
+ if (!limit.signal.aborted) {
4171
+ console.error(`[${TAG_NAME}] Product request failed`, error);
4172
+ }
4173
+ } finally {
4174
+ limit.clear();
4175
+ }
4176
+ return products;
563
4177
  }
564
4178
 
565
- // src/story/story.ts
566
- var TAG_NAME = "vtex-ads-story";
567
- var _a;
568
- var BaseElement = (_a = globalThis.HTMLElement) != null ? _a : Object;
569
- var styles = `
570
- :host {
571
- display: block;
572
- font-family: var(--vtex-ads-story-font-family, inherit);
573
- color: var(--vtex-ads-story-color-text, inherit);
4179
+ // src/utils/fetch-story.ts
4180
+ var import_ads_core2 = require("@vtex/ads-core");
4181
+ var DEFAULT_TIMEOUT_MS = 2e3;
4182
+ var DEFAULT_QUANTITY = 8;
4183
+ var toQuantity = (quantity) => quantity !== void 0 && Number.isFinite(quantity) && quantity >= 1 ? Math.floor(quantity) : DEFAULT_QUANTITY;
4184
+ async function fetchStories({
4185
+ publisherId,
4186
+ sessionId,
4187
+ placement,
4188
+ userId,
4189
+ accountName,
4190
+ channel,
4191
+ quantity
4192
+ }, { signal, timeout } = {}) {
4193
+ var _a13;
4194
+ const onServer = globalThis.window === void 0;
4195
+ if (onServer || !publisherId || !sessionId || !placement) return [];
4196
+ const limit = withTimeout(timeout, DEFAULT_TIMEOUT_MS, signal);
4197
+ const count = toQuantity(quantity);
4198
+ try {
4199
+ const { stories } = await (0, import_ads_core2.getRawAds)(
4200
+ {
4201
+ identity: {
4202
+ accountName: accountName != null ? accountName : "",
4203
+ publisherId,
4204
+ sessionId,
4205
+ userId,
4206
+ channel
4207
+ },
4208
+ search: {},
4209
+ placements: {
4210
+ [placement]: { quantity: count, types: ["story"] }
4211
+ }
4212
+ },
4213
+ { signal: limit.signal }
4214
+ );
4215
+ return ((_a13 = stories[placement]) != null ? _a13 : []).slice(0, count);
4216
+ } catch (error) {
4217
+ if (!limit.signal.aborted) {
4218
+ console.error(`[${TAG_NAME}] Story request failed`, {
4219
+ placement,
4220
+ publisherId,
4221
+ error
4222
+ });
4223
+ }
4224
+ return [];
4225
+ } finally {
4226
+ limit.clear();
574
4227
  }
575
- ${cardStyles}
576
- ${playerStyles}
577
- `;
578
- var PLACEHOLDER_STORY = {
579
- poster_url: "https://dummyimage.com/1080x1920/e31c57/fff",
580
- media_url: "https://samplelib.com/mp4/sample-10s-vp9.mp4"
4228
+ }
4229
+
4230
+ // src/locales/en.ts
4231
+ var en = {
4232
+ watch: "Watch video",
4233
+ show: "Show video",
4234
+ carousel: "Videos",
4235
+ carouselRole: "carousel",
4236
+ previous: "Previous video",
4237
+ next: "Next video",
4238
+ player: "Video",
4239
+ expand: "Expand video",
4240
+ collapse: "Collapse video",
4241
+ close: "Close video",
4242
+ play: "Play video",
4243
+ pause: "Pause video",
4244
+ soundOn: "Turn sound on",
4245
+ soundOff: "Turn sound off",
4246
+ addToCart: "Add to cart",
4247
+ unavailable: "Product unavailable",
4248
+ soldOut: "Sold out",
4249
+ viewProduct: "View product",
4250
+ product: (name, price, listPrice) => {
4251
+ if (price && listPrice) return `${name}, was ${listPrice}, now ${price}`;
4252
+ return price ? `${name}, ${price}` : name;
4253
+ },
4254
+ position: (label, index, count) => count > 1 ? `${label} ${index + 1} of ${count}` : label
4255
+ };
4256
+
4257
+ // src/locales/es.ts
4258
+ var es = {
4259
+ watch: "Ver video",
4260
+ show: "Mostrar video",
4261
+ carousel: "Videos",
4262
+ carouselRole: "carrusel",
4263
+ previous: "Video anterior",
4264
+ next: "Video siguiente",
4265
+ player: "Video",
4266
+ expand: "Ampliar video",
4267
+ collapse: "Reducir video",
4268
+ close: "Cerrar video",
4269
+ play: "Reproducir video",
4270
+ pause: "Pausar video",
4271
+ soundOn: "Activar sonido",
4272
+ soundOff: "Desactivar sonido",
4273
+ addToCart: "Agregar al carrito",
4274
+ unavailable: "Producto no disponible",
4275
+ soldOut: "Agotado",
4276
+ viewProduct: "Ver producto",
4277
+ product: (name, price, listPrice) => {
4278
+ if (price && listPrice)
4279
+ return `${name}, antes ${listPrice}, ahora ${price}`;
4280
+ return price ? `${name}, ${price}` : name;
4281
+ },
4282
+ position: (label, index, count) => count > 1 ? `${label} ${index + 1} de ${count}` : label
581
4283
  };
582
- var LABELS = {
4284
+
4285
+ // src/locales/pt.ts
4286
+ var pt = {
583
4287
  watch: "Assistir v\xEDdeo",
4288
+ show: "Mostrar v\xEDdeo",
4289
+ carousel: "V\xEDdeos",
4290
+ carouselRole: "carrossel",
4291
+ previous: "V\xEDdeo anterior",
4292
+ next: "Pr\xF3ximo v\xEDdeo",
584
4293
  player: "V\xEDdeo",
585
4294
  expand: "Expandir v\xEDdeo",
586
4295
  collapse: "Reduzir v\xEDdeo",
@@ -588,90 +4297,458 @@ var LABELS = {
588
4297
  play: "Reproduzir v\xEDdeo",
589
4298
  pause: "Pausar v\xEDdeo",
590
4299
  soundOn: "Ativar som",
591
- soundOff: "Desativar som"
4300
+ soundOff: "Desativar som",
4301
+ addToCart: "Adicionar ao carrinho",
4302
+ unavailable: "Produto indispon\xEDvel",
4303
+ soldOut: "Esgotado",
4304
+ viewProduct: "Ver produto",
4305
+ product: (name, price, listPrice) => {
4306
+ if (price && listPrice) return `${name}, de ${listPrice} por ${price}`;
4307
+ return price ? `${name}, ${price}` : name;
4308
+ },
4309
+ position: (label, index, count) => count > 1 ? `${label} ${index + 1} de ${count}` : label
4310
+ };
4311
+
4312
+ // src/locales/index.ts
4313
+ var BY_LANGUAGE = /* @__PURE__ */ new Map([
4314
+ ["pt", pt],
4315
+ ["es", es],
4316
+ ["en", en]
4317
+ ]);
4318
+ function labelsFor(locale, overrides = {}) {
4319
+ var _a13, _b3, _c;
4320
+ const language = locale.split("-")[0].toLowerCase();
4321
+ const labels = (_a13 = BY_LANGUAGE.get(language)) != null ? _a13 : pt;
4322
+ const addToCart = (_b3 = overrides.addToCart) == null ? void 0 : _b3.trim();
4323
+ const viewProduct = (_c = overrides.viewProduct) == null ? void 0 : _c.trim();
4324
+ return {
4325
+ ...labels,
4326
+ ...addToCart && { addToCart },
4327
+ ...viewProduct && { viewProduct }
4328
+ };
4329
+ }
4330
+
4331
+ // src/story/story.ts
4332
+ var REQUEST_PROPERTIES = [
4333
+ "publisherId",
4334
+ "sessionId",
4335
+ "placement",
4336
+ "userId",
4337
+ "accountName",
4338
+ "channel",
4339
+ "quantity",
4340
+ "hydration"
4341
+ ];
4342
+ var CHANNELS = /* @__PURE__ */ new Set(["site", "app"]);
4343
+ var isChannel = (value) => CHANNELS.has(value);
4344
+ var booleanConverter = {
4345
+ fromAttribute: (value) => typeof value === "string" && (value === "" || value.toLowerCase() === "true")
4346
+ };
4347
+ var channelConverter = {
4348
+ fromAttribute: (value) => isChannel(value) ? value : void 0
592
4349
  };
593
- var VtexAdsStoryElement = class extends BaseElement {
4350
+ var hydrationConverter = {
4351
+ fromAttribute: (value) => value === "none" ? "none" : void 0
4352
+ };
4353
+ var VtexAdsStoryCarouselElement = class extends i3 {
594
4354
  constructor() {
595
- super(...arguments);
596
- this.player = null;
597
- this.onKeyDown = (event) => {
598
- if (event.key === "Escape") this.closePlayer();
599
- };
4355
+ super();
4356
+ /**
4357
+ * One per rendered card, by its key (see Slide): a Story can show in more
4358
+ * than one card, each with its own video.
4359
+ */
4360
+ this.cardVideos = /* @__PURE__ */ new Map();
4361
+ /** The sound was on when the highlight moved: the new card turns it on. */
4362
+ this.soundPending = false;
4363
+ this.carousel = new CarouselController(this, {
4364
+ onStep: (from, to) => this.leaveHighlight(from, to),
4365
+ // Every card is new: so are their videos. Behind an open player, the
4366
+ // new highlighted card stays on its cover, as after a step.
4367
+ onLayoutChange: () => {
4368
+ this.cardVideos.clear();
4369
+ if (this.player.isOpen) {
4370
+ this.afterRender = () => {
4371
+ var _a13;
4372
+ return (_a13 = this.activeVideo) == null ? void 0 : _a13.pause();
4373
+ };
4374
+ }
4375
+ },
4376
+ // The player shows the highlighted Story: the highlight stays on it.
4377
+ locked: () => this.player.isOpen
4378
+ });
4379
+ this.player = new PlayerController(this, {
4380
+ onStep: (delta) => this.stepInPlayer(delta),
4381
+ onClose: () => this.closePlayer()
4382
+ });
4383
+ // Added after the carousel and the player: its hostUpdated reads what
4384
+ // they rendered.
4385
+ this.events = new StoryEventsController(this, {
4386
+ identity: () => ({ sessionId: this.sessionId, userId: this.userId }),
4387
+ viewTargets: () => this.viewTargets()
4388
+ });
4389
+ // The highlighted card opens the player; another one takes the highlight.
4390
+ // Hidden cards, out of sight, show only their cover.
4391
+ this.renderSlide = (story, { key, index, offset, active, hidden, cardRef, focusRef }) => renderCard(story, this.videoFor(key), {
4392
+ label: this.labels.position(
4393
+ active ? this.labels.watch : this.labels.show,
4394
+ index,
4395
+ this.stories.length
4396
+ ),
4397
+ labels: this.labels,
4398
+ withVideo: active || this.inactiveAutoplay && !hidden,
4399
+ product: this.productOf(story),
4400
+ onSelect: active ? () => this.openPlayer() : () => this.carousel.step(offset),
4401
+ // On a card without the highlight, the product moves it, as the card.
4402
+ onProductSelect: active ? () => this.openPlayer({ productOpen: true }) : void 0,
4403
+ // On the highlighted card it follows the link; on another, it moves the
4404
+ // highlight.
4405
+ cta: toCardCta(story),
4406
+ onCtaSelect: active ? void 0 : () => this.carousel.step(offset),
4407
+ onPress: () => this.events.click(story),
4408
+ ref: cardRef,
4409
+ openRef: focusRef
4410
+ });
4411
+ this.inactiveAutoplay = false;
4412
+ this.stories = [];
600
4413
  }
601
- render() {
602
- var _a2;
603
- const container = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(".root");
604
- if (!container) return;
605
- container.replaceChildren(
606
- createCard(PLACEHOLDER_STORY, {
607
- label: LABELS.watch,
608
- soundOnLabel: LABELS.soundOn,
609
- soundOffLabel: LABELS.soundOff,
610
- onSelect: () => this.openPlayer()
611
- })
612
- );
4414
+ // Lit keeps the card's DOM when the element is moved (removed and appended
4415
+ // again), but the browser pauses a removed video and doesn't autoplay it
4416
+ // again. resume() only plays a video that autoplays (not with reduced
4417
+ // motion), and does nothing on the first connection, before the render.
4418
+ // Not in VideoController.hostConnected: there, the player's video is still
4419
+ // in the DOM until the next update and would play for a moment.
4420
+ connectedCallback() {
4421
+ var _a13;
4422
+ super.connectedCallback();
4423
+ for (const video of this.cardVideos.values()) video.resume();
4424
+ if ((_a13 = this.request) == null ? void 0 : _a13.signal.aborted) void this.loadStory();
613
4425
  }
614
- cardVideo() {
615
- var _a2;
616
- return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(
617
- ".root .card video"
618
- );
4426
+ // A request still pending when the element leaves the page is cancelled.
4427
+ disconnectedCallback() {
4428
+ var _a13;
4429
+ super.disconnectedCallback();
4430
+ (_a13 = this.request) == null ? void 0 : _a13.abort();
619
4431
  }
620
- openPlayer() {
621
- var _a2, _b;
622
- if (this.player || !this.shadowRoot) return;
623
- this.player = createPlayer(PLACEHOLDER_STORY, {
624
- label: LABELS.player,
625
- expandLabel: LABELS.expand,
626
- collapseLabel: LABELS.collapse,
627
- closeLabel: LABELS.close,
628
- playLabel: LABELS.play,
629
- pauseLabel: LABELS.pause,
630
- soundOnLabel: LABELS.soundOn,
631
- soundOffLabel: LABELS.soundOff,
632
- onClose: () => this.closePlayer()
4432
+ willUpdate(changed) {
4433
+ if (REQUEST_PROPERTIES.some((name) => changed.has(name))) {
4434
+ void this.loadStory();
4435
+ }
4436
+ }
4437
+ updated() {
4438
+ const afterRender = this.afterRender;
4439
+ this.afterRender = void 0;
4440
+ afterRender == null ? void 0 : afterRender();
4441
+ }
4442
+ // The strategy for the products' details, if any (see `hydration`).
4443
+ get activeHydration() {
4444
+ if (this.hydration === "none") return void 0;
4445
+ if (this.hydration) return this.hydration;
4446
+ return this.accountName ? intelligentSearchHydration : void 0;
4447
+ }
4448
+ /**
4449
+ * Requests the Story and shows it, then hydrates its products. Until the
4450
+ * Story arrives, and when there is none (see fetchStories), the element
4451
+ * renders nothing.
4452
+ */
4453
+ async loadStory() {
4454
+ var _a13, _b3, _c, _d, _e;
4455
+ (_a13 = this.request) == null ? void 0 : _a13.abort();
4456
+ const request = new AbortController();
4457
+ this.request = request;
4458
+ this.player.close();
4459
+ this.showStories([]);
4460
+ if (!this.isConnected) {
4461
+ request.abort();
4462
+ return;
4463
+ }
4464
+ const stories = await fetchStories(this, {
4465
+ signal: request.signal,
4466
+ timeout: this.timeout
633
4467
  });
634
- this.shadowRoot.append(this.player);
635
- showPlayer(this.player);
636
- (_a2 = this.cardVideo()) == null ? void 0 : _a2.pause();
637
- playPlayer(this.player);
638
- document.addEventListener("keydown", this.onKeyDown);
639
- (_b = this.player.querySelector(".player-close")) == null ? void 0 : _b.focus();
4468
+ if (request.signal.aborted) return;
4469
+ const hydration = this.activeHydration;
4470
+ if (!hydration || !stories.some((story) => story.product)) {
4471
+ this.request = void 0;
4472
+ this.showStories(stories);
4473
+ return;
4474
+ }
4475
+ this.showStories(stories, "loading");
4476
+ const products = await hydrateStoryProducts(
4477
+ (_b3 = this.placement) != null ? _b3 : "",
4478
+ stories,
4479
+ hydration,
4480
+ {
4481
+ accountName: (_c = this.accountName) != null ? _c : "",
4482
+ publisherId: (_d = this.publisherId) != null ? _d : "",
4483
+ sessionId: (_e = this.sessionId) != null ? _e : "",
4484
+ userId: this.userId,
4485
+ channel: this.channel
4486
+ },
4487
+ { signal: request.signal, timeout: this.hydrationTimeout }
4488
+ );
4489
+ if (request.signal.aborted) return;
4490
+ this.request = void 0;
4491
+ this.products = products;
640
4492
  }
641
- // `removed`: the element is leaving the page, so there is no card to give
642
- // focus back to or to resume playing (it would play out of sight).
643
- closePlayer({ removed = false } = {}) {
644
- var _a2, _b;
645
- if (!this.player) return;
646
- document.removeEventListener("keydown", this.onKeyDown);
647
- this.player.remove();
648
- this.player = null;
649
- if (removed) return;
650
- const video = this.cardVideo();
651
- if (video == null ? void 0 : video.autoplay) playVideo(video);
652
- (_b = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(".root .card-open")) == null ? void 0 : _b.focus();
4493
+ // Each card's video starts fresh: a failed load of an old one doesn't hide
4494
+ // it.
4495
+ showStories(stories, products) {
4496
+ this.products = products;
4497
+ this.cardVideos.clear();
4498
+ this.soundPending = false;
4499
+ this.afterRender = void 0;
4500
+ this.carousel.reset(stories.length);
4501
+ this.stories = stories;
4502
+ this.events.impress(stories);
653
4503
  }
654
- connectedCallback() {
655
- if (!this.shadowRoot) {
656
- const root = this.attachShadow({ mode: "open" });
657
- root.innerHTML = `<style>${styles}</style><div class="root"></div>`;
4504
+ /**
4505
+ * Where each Story is being watched: the cards on screen (not the hidden
4506
+ * ones kept for the slide in) and the open player's video, while their
4507
+ * video plays. A card showing only its cover doesn't count. Behind the
4508
+ * expanded player, a modal over the page, the cards are covered.
4509
+ */
4510
+ *viewTargets() {
4511
+ var _a13;
4512
+ const { stories } = this;
4513
+ if (!this.player.isExpanded) {
4514
+ for (const [card, { key, index }] of this.carousel.visibleCards()) {
4515
+ const story = stories[index];
4516
+ if (story && ((_a13 = this.cardVideos.get(key)) == null ? void 0 : _a13.playing)) yield [card, story];
4517
+ }
4518
+ }
4519
+ const stageCard = this.player.stageCard;
4520
+ const active = stories[this.carousel.active];
4521
+ if (stageCard && active && this.player.video.playing) {
4522
+ yield [stageCard, active];
658
4523
  }
659
- this.render();
660
4524
  }
661
- disconnectedCallback() {
662
- this.closePlayer({ removed: true });
4525
+ videoFor(key) {
4526
+ let video = this.cardVideos.get(key);
4527
+ if (!video) {
4528
+ video = new VideoController(this);
4529
+ this.cardVideos.set(key, video);
4530
+ }
4531
+ return video;
4532
+ }
4533
+ get activeVideo() {
4534
+ return this.cardVideos.get(this.carousel.activeKey);
4535
+ }
4536
+ // The card losing the highlight goes quiet: muted if it keeps playing, or
4537
+ // back to its cover. Its next video then starts fresh. If its sound was
4538
+ // on, the sound moves to the new highlighted card, once its video renders.
4539
+ // With the player open (it stepped), the new card stays on its cover
4540
+ // behind it instead. Cards no longer rendered (the rolling layout drops
4541
+ // them as it moves) leave with their videos.
4542
+ leaveHighlight(from, to) {
4543
+ const video = this.cardVideos.get(from);
4544
+ this.soundPending || (this.soundPending = video !== void 0 && !video.muted);
4545
+ if (this.inactiveAutoplay) video == null ? void 0 : video.mute();
4546
+ else video == null ? void 0 : video.reset();
4547
+ if (this.player.isOpen) {
4548
+ this.soundPending = false;
4549
+ this.afterRender = () => this.videoFor(to).pause();
4550
+ } else if (this.soundPending) {
4551
+ this.afterRender = () => {
4552
+ this.soundPending = false;
4553
+ this.videoFor(to).playWithSound();
4554
+ };
4555
+ }
4556
+ for (const key of this.cardVideos.keys()) {
4557
+ if (Math.abs(key - to) > RENDERED_SIDE) this.cardVideos.delete(key);
4558
+ }
4559
+ }
4560
+ // The player's previous and next buttons: the highlight moves with the
4561
+ // Story the player shows.
4562
+ stepInPlayer(delta) {
4563
+ this.carousel.step(delta, { evenIfLocked: true });
4564
+ void this.player.showNext(delta);
4565
+ }
4566
+ // From the card's product, the player opens with the product panel open.
4567
+ openPlayer({ productOpen = false } = {}) {
4568
+ var _a13;
4569
+ if (this.player.isOpen) return;
4570
+ (_a13 = this.activeVideo) == null ? void 0 : _a13.pause();
4571
+ void this.player.open({ productOpen });
4572
+ }
4573
+ // The player also closes on its own when the element leaves the page,
4574
+ // without this: there is no card to give focus back to or to resume playing
4575
+ // (it would play out of sight).
4576
+ closePlayer() {
4577
+ if (!this.player.isOpen) return;
4578
+ this.player.close();
4579
+ for (const video of this.cardVideos.values()) video.resume();
4580
+ this.carousel.focusActive();
4581
+ }
4582
+ // Prices and texts follow the language of the closest element with a
4583
+ // `lang`, the element itself included, so a store can set one for the
4584
+ // widget alone. An empty `lang` (unknown) is skipped; none, or an unknown
4585
+ // one, falls back to pt-BR.
4586
+ get locale() {
4587
+ var _a13, _b3;
4588
+ return (_b3 = (_a13 = this.closest('[lang]:not([lang=""])')) == null ? void 0 : _a13.lang) != null ? _b3 : DEFAULT_LOCALE;
4589
+ }
4590
+ get labels() {
4591
+ var _a13;
4592
+ const { locale, labelAddToCart = "", labelViewProduct = "" } = this;
4593
+ const key = JSON.stringify([locale, labelAddToCart, labelViewProduct]);
4594
+ if (((_a13 = this.labelSet) == null ? void 0 : _a13.key) !== key) {
4595
+ this.labelSet = {
4596
+ key,
4597
+ labels: labelsFor(locale, {
4598
+ addToCart: labelAddToCart,
4599
+ viewProduct: labelViewProduct
4600
+ })
4601
+ };
4602
+ }
4603
+ return this.labelSet.labels;
4604
+ }
4605
+ get formatPrice() {
4606
+ var _a13, _b3;
4607
+ const { locale } = this;
4608
+ const key = `${locale}|${(_a13 = this.currency) != null ? _a13 : ""}`;
4609
+ if (((_b3 = this.formatter) == null ? void 0 : _b3.key) !== key) {
4610
+ this.formatter = { key, format: priceFormatter(locale, this.currency) };
4611
+ }
4612
+ return this.formatter.format;
4613
+ }
4614
+ productOf(story) {
4615
+ var _a13;
4616
+ const fetched = this.products === "loading" ? "loading" : (_a13 = this.products) == null ? void 0 : _a13.get(story.ad_id);
4617
+ return toCardProduct(story, this.formatPrice, this.labels, fetched);
4618
+ }
4619
+ render() {
4620
+ const { stories } = this;
4621
+ const index = this.carousel.active;
4622
+ const active = stories[index];
4623
+ if (!active) return A;
4624
+ const neighbors = neighborOffsets(stories.length, index).map((offset) => {
4625
+ const neighbor = (index + offset + stories.length) % stories.length;
4626
+ return {
4627
+ offset,
4628
+ story: stories[neighbor],
4629
+ label: this.labels.position(this.labels.show, neighbor, stories.length)
4630
+ };
4631
+ });
4632
+ return T`
4633
+ <div class="root">
4634
+ ${this.carousel.render(stories, this.renderSlide, this.labels)}
4635
+ </div>
4636
+ ${this.player.render(active, {
4637
+ labels: this.labels,
4638
+ navigation: stories.length > 1,
4639
+ neighbors,
4640
+ product: this.productOf(active),
4641
+ cta: toCardCta(active),
4642
+ onPress: () => this.events.click(active)
4643
+ })}
4644
+ `;
663
4645
  }
664
4646
  };
665
- function defineVtexAdsStories() {
4647
+ VtexAdsStoryCarouselElement.properties = {
4648
+ publisherId: { attribute: "publisher-id" },
4649
+ sessionId: { attribute: "session-id" },
4650
+ placement: {},
4651
+ userId: { attribute: "user-id" },
4652
+ accountName: { attribute: "account-name" },
4653
+ channel: { converter: channelConverter },
4654
+ timeout: { type: Number },
4655
+ quantity: { type: Number },
4656
+ currency: {},
4657
+ labelAddToCart: { attribute: "label-add-to-cart" },
4658
+ labelViewProduct: { attribute: "label-view-product" },
4659
+ hydration: { converter: hydrationConverter },
4660
+ hydrationTimeout: { type: Number, attribute: "hydration-timeout" },
4661
+ inactiveAutoplay: {
4662
+ type: Boolean,
4663
+ attribute: "inactive-autoplay",
4664
+ converter: booleanConverter
4665
+ },
4666
+ stories: { state: true },
4667
+ products: { state: true }
4668
+ };
4669
+ VtexAdsStoryCarouselElement.styles = [
4670
+ i`
4671
+ :host {
4672
+ display: block;
4673
+ font-family: var(--vtex-ads-story-font-family, inherit);
4674
+ color: var(--vtex-ads-story-color-text, inherit);
4675
+ }
4676
+ `,
4677
+ cardStyles,
4678
+ productStyles,
4679
+ carouselStyles,
4680
+ playerStyles
4681
+ ];
4682
+ function defineVtexAdsStoryCarousel() {
666
4683
  if (typeof customElements === "undefined") return;
667
4684
  if (customElements.get(TAG_NAME)) return;
668
- customElements.define(TAG_NAME, VtexAdsStoryElement);
4685
+ customElements.define(TAG_NAME, VtexAdsStoryCarouselElement);
669
4686
  }
670
4687
  // Annotate the CommonJS export names for ESM import in node:
671
4688
  0 && (module.exports = {
672
4689
  TAG_NAME,
673
- VtexAdsStoryElement,
674
- defineVtexAdsStories
4690
+ VtexAdsStoryCarouselElement,
4691
+ defineVtexAdsStoryCarousel
675
4692
  });
676
4693
  /*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */
4694
+ /*! Bundled license information:
4695
+
4696
+ @lit-labs/ssr-dom-shim/lib/element-internals.js:
4697
+ @lit-labs/ssr-dom-shim/lib/events.js:
4698
+ (**
4699
+ * @license
4700
+ * Copyright 2023 Google LLC
4701
+ * SPDX-License-Identifier: BSD-3-Clause
4702
+ *)
4703
+
4704
+ @lit-labs/ssr-dom-shim/lib/css.js:
4705
+ @lit-labs/ssr-dom-shim/lib/observers.js:
4706
+ (**
4707
+ * @license
4708
+ * Copyright 2024 Google LLC
4709
+ * SPDX-License-Identifier: BSD-3-Clause
4710
+ *)
4711
+
4712
+ @lit-labs/ssr-dom-shim/index.js:
4713
+ @lit/reactive-element/node/css-tag.js:
4714
+ (**
4715
+ * @license
4716
+ * Copyright 2019 Google LLC
4717
+ * SPDX-License-Identifier: BSD-3-Clause
4718
+ *)
4719
+
4720
+ lit-html/node/lit-html.js:
4721
+ lit-element/lit-element.js:
4722
+ lit-html/node/directive.js:
4723
+ lit-html/node/async-directive.js:
4724
+ lit-html/node/directives/unsafe-html.js:
4725
+ lit-html/node/directives/repeat.js:
4726
+ (**
4727
+ * @license
4728
+ * Copyright 2017 Google LLC
4729
+ * SPDX-License-Identifier: BSD-3-Clause
4730
+ *)
4731
+
4732
+ lit-html/node/is-server.js:
4733
+ (**
4734
+ * @license
4735
+ * Copyright 2022 Google LLC
4736
+ * SPDX-License-Identifier: BSD-3-Clause
4737
+ *)
4738
+
4739
+ lit-html/node/directive-helpers.js:
4740
+ lit-html/node/directives/ref.js:
4741
+ (**
4742
+ * @license
4743
+ * Copyright 2020 Google LLC
4744
+ * SPDX-License-Identifier: BSD-3-Clause
4745
+ *)
4746
+
4747
+ lit-html/node/directives/style-map.js:
4748
+ (**
4749
+ * @license
4750
+ * Copyright 2018 Google LLC
4751
+ * SPDX-License-Identifier: BSD-3-Clause
4752
+ *)
4753
+ */
677
4754
  //# sourceMappingURL=index.cjs.map