@vtex/ads-stories 0.4.1 → 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.
- package/CHANGELOG.md +60 -0
- package/README.md +250 -26
- package/dist/cdn/vtex-ads-stories.js +986 -72
- package/dist/cdn/vtex-ads-stories.js.map +1 -1
- package/dist/cjs/index.cjs +2911 -403
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +193 -8
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/cjs/react.d.cts +45 -5
- package/dist/esm/index.d.ts +193 -8
- package/dist/esm/index.js +2528 -121
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.d.ts +45 -5
- package/package.json +18 -4
- package/src/cdn.ts +7 -3
- package/src/components/card/card.ts +64 -12
- package/src/components/carousel/carousel.ts +670 -0
- package/src/components/carousel/index.ts +15 -0
- package/src/components/events/events-controller.ts +212 -0
- package/src/components/events/index.ts +6 -0
- package/src/components/icons/assets/caret-left-bold.svg +1 -0
- package/src/components/icons/assets/caret-right-bold.svg +1 -0
- package/src/components/icons/assets/caret-up-bold.svg +1 -0
- package/src/components/icons/index.ts +6 -0
- package/src/components/media/index.ts +2 -1
- package/src/components/media/media.ts +21 -17
- package/src/components/media/video-controller.ts +47 -0
- package/src/components/player/index.ts +6 -2
- package/src/components/player/player.ts +797 -48
- package/src/components/product/cta.ts +56 -0
- package/src/components/product/index.ts +20 -0
- package/src/components/product/price.ts +86 -0
- package/src/components/product/product.styles.ts +369 -0
- package/src/components/product/product.ts +235 -0
- package/src/index.ts +9 -1
- package/src/locales/en.ts +29 -0
- package/src/locales/es.ts +30 -0
- package/src/locales/index.ts +36 -0
- package/src/locales/pt.ts +29 -0
- package/src/locales/types.ts +24 -0
- package/src/react.ts +49 -7
- package/src/story/index.ts +5 -1
- package/src/story/story.ts +505 -47
- package/src/tag-name.ts +1 -0
- package/src/types.ts +8 -12
- package/src/utils/fetch-story.ts +113 -0
- package/src/utils/http-url.ts +12 -0
- package/src/utils/hydrate-products.ts +88 -0
- package/src/utils/send-event.ts +71 -0
- package/src/utils/with-timeout.ts +43 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -21,8 +21,8 @@ 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
|
-
|
|
25
|
-
|
|
24
|
+
VtexAdsStoryCarouselElement: () => VtexAdsStoryCarouselElement,
|
|
25
|
+
defineVtexAdsStoryCarousel: () => defineVtexAdsStoryCarousel
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
@@ -604,7 +604,7 @@ var ElementShim = class Element extends NodeShim {
|
|
|
604
604
|
return value != null ? value : null;
|
|
605
605
|
}
|
|
606
606
|
};
|
|
607
|
-
var HTMLElementShim = class
|
|
607
|
+
var HTMLElementShim = class HTMLElement2 extends ElementShim {
|
|
608
608
|
};
|
|
609
609
|
var HTMLElementShimWithRealType = HTMLElementShim;
|
|
610
610
|
var ShadowRootShim = class ShadowRoot extends NodeShim {
|
|
@@ -709,16 +709,16 @@ var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "a
|
|
|
709
709
|
var s = Symbol();
|
|
710
710
|
var o = /* @__PURE__ */ new WeakMap();
|
|
711
711
|
var n = class {
|
|
712
|
-
constructor(t5, e6,
|
|
713
|
-
if (this._$cssResult$ = true,
|
|
712
|
+
constructor(t5, e6, o9) {
|
|
713
|
+
if (this._$cssResult$ = true, o9 !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
714
714
|
this.cssText = t5, this.t = e6;
|
|
715
715
|
}
|
|
716
716
|
get styleSheet() {
|
|
717
717
|
let t5 = this.o;
|
|
718
|
-
const
|
|
718
|
+
const s6 = this.t;
|
|
719
719
|
if (e && void 0 === t5) {
|
|
720
|
-
const e6 = void 0 !==
|
|
721
|
-
e6 && (t5 = o.get(
|
|
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
722
|
}
|
|
723
723
|
return t5;
|
|
724
724
|
}
|
|
@@ -728,23 +728,23 @@ var n = class {
|
|
|
728
728
|
};
|
|
729
729
|
var r = (t5) => new n("string" == typeof t5 ? t5 : t5 + "", void 0, s);
|
|
730
730
|
var i = (t5, ...e6) => {
|
|
731
|
-
const
|
|
731
|
+
const o9 = 1 === t5.length ? t5[0] : e6.reduce((e7, s6, o10) => e7 + ((t6) => {
|
|
732
732
|
if (true === t6._$cssResult$) return t6.cssText;
|
|
733
733
|
if ("number" == typeof t6) return t6;
|
|
734
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
|
-
})(
|
|
736
|
-
return new n(
|
|
735
|
+
})(s6) + t5[o10 + 1], t5[0]);
|
|
736
|
+
return new n(o9, t5, s);
|
|
737
737
|
};
|
|
738
|
-
var S = (
|
|
739
|
-
if (e)
|
|
740
|
-
else for (const e6 of
|
|
741
|
-
const
|
|
742
|
-
void 0 !==
|
|
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
743
|
}
|
|
744
744
|
};
|
|
745
745
|
var c = e || void 0 === t.CSSStyleSheet ? (t5) => t5 : (t5) => t5 instanceof CSSStyleSheet ? ((t6) => {
|
|
746
746
|
let e6 = "";
|
|
747
|
-
for (const
|
|
747
|
+
for (const s6 of t6.cssRules) e6 += s6.cssText;
|
|
748
748
|
return r(e6);
|
|
749
749
|
})(t5) : t5;
|
|
750
750
|
|
|
@@ -756,9 +756,9 @@ var _a6;
|
|
|
756
756
|
var p = l.trustedTypes;
|
|
757
757
|
var d = p ? p.emptyScript : "";
|
|
758
758
|
var u = l.reactiveElementPolyfillSupport;
|
|
759
|
-
var f = (t5,
|
|
760
|
-
var b = { toAttribute(t5,
|
|
761
|
-
switch (
|
|
759
|
+
var f = (t5, s6) => t5;
|
|
760
|
+
var b = { toAttribute(t5, s6) {
|
|
761
|
+
switch (s6) {
|
|
762
762
|
case Boolean:
|
|
763
763
|
t5 = t5 ? d : null;
|
|
764
764
|
break;
|
|
@@ -767,26 +767,26 @@ var b = { toAttribute(t5, s5) {
|
|
|
767
767
|
t5 = null == t5 ? t5 : JSON.stringify(t5);
|
|
768
768
|
}
|
|
769
769
|
return t5;
|
|
770
|
-
}, fromAttribute(t5,
|
|
771
|
-
let
|
|
772
|
-
switch (
|
|
770
|
+
}, fromAttribute(t5, s6) {
|
|
771
|
+
let i7 = t5;
|
|
772
|
+
switch (s6) {
|
|
773
773
|
case Boolean:
|
|
774
|
-
|
|
774
|
+
i7 = null !== t5;
|
|
775
775
|
break;
|
|
776
776
|
case Number:
|
|
777
|
-
|
|
777
|
+
i7 = null === t5 ? null : Number(t5);
|
|
778
778
|
break;
|
|
779
779
|
case Object:
|
|
780
780
|
case Array:
|
|
781
781
|
try {
|
|
782
|
-
|
|
782
|
+
i7 = JSON.parse(t5);
|
|
783
783
|
} catch (t6) {
|
|
784
|
-
|
|
784
|
+
i7 = null;
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
|
-
return
|
|
787
|
+
return i7;
|
|
788
788
|
} };
|
|
789
|
-
var m = (t5,
|
|
789
|
+
var m = (t5, s6) => !h(t5, s6);
|
|
790
790
|
var y = { attribute: true, type: String, converter: b, reflect: false, useDefault: false, hasChanged: m };
|
|
791
791
|
var _a7, _b2;
|
|
792
792
|
(_a7 = Symbol.metadata) != null ? _a7 : Symbol.metadata = Symbol("metadata"), (_b2 = l.litPropertyMetadata) != null ? _b2 : l.litPropertyMetadata = /* @__PURE__ */ new WeakMap();
|
|
@@ -799,22 +799,22 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
799
799
|
static get observedAttributes() {
|
|
800
800
|
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
801
801
|
}
|
|
802
|
-
static createProperty(t5,
|
|
803
|
-
if (
|
|
804
|
-
const
|
|
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
805
|
void 0 !== e6 && r2(this.prototype, t5, e6);
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
|
-
static getPropertyDescriptor(t5,
|
|
808
|
+
static getPropertyDescriptor(t5, s6, i7) {
|
|
809
809
|
var _a13;
|
|
810
|
-
const { get: e6, set:
|
|
811
|
-
return this[
|
|
810
|
+
const { get: e6, set: h6 } = (_a13 = o2(this.prototype, t5)) != null ? _a13 : { get() {
|
|
811
|
+
return this[s6];
|
|
812
812
|
}, set(t6) {
|
|
813
|
-
this[
|
|
813
|
+
this[s6] = t6;
|
|
814
814
|
} };
|
|
815
|
-
return { get: e6, set(
|
|
815
|
+
return { get: e6, set(s7) {
|
|
816
816
|
const r6 = e6 == null ? void 0 : e6.call(this);
|
|
817
|
-
|
|
817
|
+
h6 == null ? void 0 : h6.call(this, s7), this.requestUpdate(t5, r6, i7);
|
|
818
818
|
}, configurable: true, enumerable: true };
|
|
819
819
|
}
|
|
820
820
|
static getPropertyOptions(t5) {
|
|
@@ -829,32 +829,32 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
829
829
|
static finalize() {
|
|
830
830
|
if (this.hasOwnProperty(f("finalized"))) return;
|
|
831
831
|
if (this.finalized = true, this._$Ei(), this.hasOwnProperty(f("properties"))) {
|
|
832
|
-
const t6 = this.properties,
|
|
833
|
-
for (const
|
|
832
|
+
const t6 = this.properties, s6 = [...n2(t6), ...a(t6)];
|
|
833
|
+
for (const i7 of s6) this.createProperty(i7, t6[i7]);
|
|
834
834
|
}
|
|
835
835
|
const t5 = this[Symbol.metadata];
|
|
836
836
|
if (null !== t5) {
|
|
837
|
-
const
|
|
838
|
-
if (void 0 !==
|
|
837
|
+
const s6 = litPropertyMetadata.get(t5);
|
|
838
|
+
if (void 0 !== s6) for (const [t6, i7] of s6) this.elementProperties.set(t6, i7);
|
|
839
839
|
}
|
|
840
840
|
this._$Eh = /* @__PURE__ */ new Map();
|
|
841
|
-
for (const [t6,
|
|
842
|
-
const
|
|
843
|
-
void 0 !==
|
|
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
844
|
}
|
|
845
845
|
this.elementStyles = this.finalizeStyles(this.styles);
|
|
846
846
|
}
|
|
847
847
|
static finalizeStyles(t5) {
|
|
848
|
-
const
|
|
848
|
+
const s6 = [];
|
|
849
849
|
if (Array.isArray(t5)) {
|
|
850
850
|
const e6 = new Set(t5.flat(1 / 0).reverse());
|
|
851
|
-
for (const t6 of e6)
|
|
852
|
-
} else void 0 !== t5 &&
|
|
853
|
-
return
|
|
851
|
+
for (const t6 of e6) s6.unshift(c(t6));
|
|
852
|
+
} else void 0 !== t5 && s6.push(c(t5));
|
|
853
|
+
return s6;
|
|
854
854
|
}
|
|
855
|
-
static _$Eu(t5,
|
|
856
|
-
const
|
|
857
|
-
return false ===
|
|
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
858
|
}
|
|
859
859
|
constructor() {
|
|
860
860
|
super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
|
|
@@ -872,8 +872,8 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
872
872
|
(_a13 = this._$EO) == null ? void 0 : _a13.delete(t5);
|
|
873
873
|
}
|
|
874
874
|
_$E_() {
|
|
875
|
-
const t5 = /* @__PURE__ */ new Map(),
|
|
876
|
-
for (const
|
|
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
877
|
t5.size > 0 && (this._$Ep = t5);
|
|
878
878
|
}
|
|
879
879
|
createRenderRoot() {
|
|
@@ -897,39 +897,39 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
897
897
|
return (_a14 = t5.hostDisconnected) == null ? void 0 : _a14.call(t5);
|
|
898
898
|
});
|
|
899
899
|
}
|
|
900
|
-
attributeChangedCallback(t5,
|
|
901
|
-
this._$AK(t5,
|
|
900
|
+
attributeChangedCallback(t5, s6, i7) {
|
|
901
|
+
this._$AK(t5, i7);
|
|
902
902
|
}
|
|
903
|
-
_$ET(t5,
|
|
903
|
+
_$ET(t5, s6) {
|
|
904
904
|
var _a13;
|
|
905
|
-
const
|
|
906
|
-
if (void 0 !== e6 && true ===
|
|
907
|
-
const
|
|
908
|
-
this._$Em = t5, null ==
|
|
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
909
|
}
|
|
910
910
|
}
|
|
911
|
-
_$AK(t5,
|
|
911
|
+
_$AK(t5, s6) {
|
|
912
912
|
var _a13, _b3, _c;
|
|
913
|
-
const
|
|
913
|
+
const i7 = this.constructor, e6 = i7._$Eh.get(t5);
|
|
914
914
|
if (void 0 !== e6 && this._$Em !== e6) {
|
|
915
|
-
const t6 =
|
|
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
916
|
this._$Em = e6;
|
|
917
|
-
const r6 =
|
|
917
|
+
const r6 = h6.fromAttribute(s6, t6.type);
|
|
918
918
|
this[e6] = (_c = r6 != null ? r6 : (_b3 = this._$Ej) == null ? void 0 : _b3.get(e6)) != null ? _c : r6, this._$Em = null;
|
|
919
919
|
}
|
|
920
920
|
}
|
|
921
|
-
requestUpdate(t5,
|
|
921
|
+
requestUpdate(t5, s6, i7, e6 = false, h6) {
|
|
922
922
|
var _a13, _b3;
|
|
923
923
|
if (void 0 !== t5) {
|
|
924
924
|
const r6 = this.constructor;
|
|
925
|
-
if (false === e6 && (
|
|
926
|
-
this.C(t5,
|
|
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
927
|
}
|
|
928
928
|
false === this.isUpdatePending && (this._$ES = this._$EP());
|
|
929
929
|
}
|
|
930
|
-
C(t5,
|
|
930
|
+
C(t5, s6, { useDefault: i7, reflect: e6, wrapped: h6 }, r6) {
|
|
931
931
|
var _a13, _b3, _c;
|
|
932
|
-
|
|
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
933
|
}
|
|
934
934
|
async _$EP() {
|
|
935
935
|
this.isUpdatePending = true;
|
|
@@ -949,26 +949,26 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
949
949
|
if (!this.isUpdatePending) return;
|
|
950
950
|
if (!this.hasUpdated) {
|
|
951
951
|
if ((_a13 = this.renderRoot) != null ? _a13 : this.renderRoot = this.createRenderRoot(), this._$Ep) {
|
|
952
|
-
for (const [t7,
|
|
952
|
+
for (const [t7, s7] of this._$Ep) this[t7] = s7;
|
|
953
953
|
this._$Ep = void 0;
|
|
954
954
|
}
|
|
955
955
|
const t6 = this.constructor.elementProperties;
|
|
956
|
-
if (t6.size > 0) for (const [
|
|
957
|
-
const { wrapped: t7 } =
|
|
958
|
-
true !== t7 || this._$AL.has(
|
|
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
959
|
}
|
|
960
960
|
}
|
|
961
961
|
let t5 = false;
|
|
962
|
-
const
|
|
962
|
+
const s6 = this._$AL;
|
|
963
963
|
try {
|
|
964
|
-
t5 = this.shouldUpdate(
|
|
964
|
+
t5 = this.shouldUpdate(s6), t5 ? (this.willUpdate(s6), (_b3 = this._$EO) == null ? void 0 : _b3.forEach((t6) => {
|
|
965
965
|
var _a14;
|
|
966
966
|
return (_a14 = t6.hostUpdate) == null ? void 0 : _a14.call(t6);
|
|
967
|
-
}), this.update(
|
|
968
|
-
} catch (
|
|
969
|
-
throw t5 = false, this._$EM(),
|
|
967
|
+
}), this.update(s6)) : this._$EM();
|
|
968
|
+
} catch (s7) {
|
|
969
|
+
throw t5 = false, this._$EM(), s7;
|
|
970
970
|
}
|
|
971
|
-
t5 && this._$AE(
|
|
971
|
+
t5 && this._$AE(s6);
|
|
972
972
|
}
|
|
973
973
|
willUpdate(t5) {
|
|
974
974
|
}
|
|
@@ -1025,7 +1025,7 @@ var p2 = RegExp(`>|${f2}(?:([^\\s"'>=/]+)(${f2}*=${f2}*(?:[^
|
|
|
1025
1025
|
var g2 = /'/g;
|
|
1026
1026
|
var $ = /"/g;
|
|
1027
1027
|
var y2 = /^(?:script|style|textarea|title)$/i;
|
|
1028
|
-
var x = (t5) => (
|
|
1028
|
+
var x = (t5) => (i7, ...s6) => ({ _$litType$: t5, strings: i7, values: s6 });
|
|
1029
1029
|
var T = x(1);
|
|
1030
1030
|
var b2 = x(2);
|
|
1031
1031
|
var w = x(3);
|
|
@@ -1033,44 +1033,44 @@ var E = Symbol.for("lit-noChange");
|
|
|
1033
1033
|
var A = Symbol.for("lit-nothing");
|
|
1034
1034
|
var C = /* @__PURE__ */ new WeakMap();
|
|
1035
1035
|
var P = l2.createTreeWalker(l2, 129);
|
|
1036
|
-
function V(t5,
|
|
1036
|
+
function V(t5, i7) {
|
|
1037
1037
|
if (!u2(t5) || !t5.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
1038
|
-
return void 0 !== e2 ? e2.createHTML(
|
|
1038
|
+
return void 0 !== e2 ? e2.createHTML(i7) : i7;
|
|
1039
1039
|
}
|
|
1040
|
-
var N = (t5,
|
|
1041
|
-
const
|
|
1042
|
-
let
|
|
1043
|
-
for (let
|
|
1044
|
-
const
|
|
1045
|
-
let a3,
|
|
1046
|
-
for (; f4 <
|
|
1047
|
-
const x2 =
|
|
1048
|
-
l3 +=
|
|
1049
|
-
}
|
|
1050
|
-
return [V(t5, l3 + (t5[
|
|
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
1051
|
};
|
|
1052
1052
|
var S2 = class _S {
|
|
1053
|
-
constructor({ strings: t5, _$litType$:
|
|
1053
|
+
constructor({ strings: t5, _$litType$: i7 }, e6) {
|
|
1054
1054
|
let r6;
|
|
1055
1055
|
this.parts = [];
|
|
1056
1056
|
let l3 = 0, a3 = 0;
|
|
1057
|
-
const
|
|
1058
|
-
if (this.el = _S.createElement(f4, e6), P.currentNode = this.el.content, 2 ===
|
|
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
1059
|
const t6 = this.el.content.firstChild;
|
|
1060
1060
|
t6.replaceWith(...t6.childNodes);
|
|
1061
1061
|
}
|
|
1062
|
-
for (; null !== (r6 = P.nextNode()) && d3.length <
|
|
1062
|
+
for (; null !== (r6 = P.nextNode()) && d3.length < u5; ) {
|
|
1063
1063
|
if (1 === r6.nodeType) {
|
|
1064
1064
|
if (r6.hasAttributes()) for (const t6 of r6.getAttributeNames()) if (t6.endsWith(h2)) {
|
|
1065
|
-
const
|
|
1066
|
-
d3.push({ type: 1, index: l3, name: e7[2], strings:
|
|
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
1067
|
} else t6.startsWith(o3) && (d3.push({ type: 6, index: l3 }), r6.removeAttribute(t6));
|
|
1068
1068
|
if (y2.test(r6.tagName)) {
|
|
1069
|
-
const t6 = r6.textContent.split(o3),
|
|
1070
|
-
if (
|
|
1069
|
+
const t6 = r6.textContent.split(o3), i8 = t6.length - 1;
|
|
1070
|
+
if (i8 > 0) {
|
|
1071
1071
|
r6.textContent = s2 ? s2.emptyScript : "";
|
|
1072
|
-
for (let
|
|
1073
|
-
r6.append(t6[
|
|
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
1074
|
}
|
|
1075
1075
|
}
|
|
1076
1076
|
} else if (8 === r6.nodeType) if (r6.data === n3) d3.push({ type: 2, index: l3 });
|
|
@@ -1081,21 +1081,21 @@ var S2 = class _S {
|
|
|
1081
1081
|
l3++;
|
|
1082
1082
|
}
|
|
1083
1083
|
}
|
|
1084
|
-
static createElement(t5,
|
|
1085
|
-
const
|
|
1086
|
-
return
|
|
1084
|
+
static createElement(t5, i7) {
|
|
1085
|
+
const s6 = l2.createElement("template");
|
|
1086
|
+
return s6.innerHTML = t5, s6;
|
|
1087
1087
|
}
|
|
1088
1088
|
};
|
|
1089
|
-
function M(t5,
|
|
1089
|
+
function M(t5, i7, s6 = t5, e6) {
|
|
1090
1090
|
var _a13, _b3, _c;
|
|
1091
|
-
if (
|
|
1092
|
-
let
|
|
1093
|
-
const
|
|
1094
|
-
return (
|
|
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
1095
|
}
|
|
1096
1096
|
var k = class {
|
|
1097
|
-
constructor(t5,
|
|
1098
|
-
this._$AV = [], this._$AN = void 0, this._$AD = t5, this._$AM =
|
|
1097
|
+
constructor(t5, i7) {
|
|
1098
|
+
this._$AV = [], this._$AN = void 0, this._$AD = t5, this._$AM = i7;
|
|
1099
1099
|
}
|
|
1100
1100
|
get parentNode() {
|
|
1101
1101
|
return this._$AM.parentNode;
|
|
@@ -1105,21 +1105,21 @@ var k = class {
|
|
|
1105
1105
|
}
|
|
1106
1106
|
u(t5) {
|
|
1107
1107
|
var _a13;
|
|
1108
|
-
const { el: { content:
|
|
1108
|
+
const { el: { content: i7 }, parts: s6 } = this._$AD, e6 = ((_a13 = t5 == null ? void 0 : t5.creationScope) != null ? _a13 : l2).importNode(i7, true);
|
|
1109
1109
|
P.currentNode = e6;
|
|
1110
|
-
let
|
|
1110
|
+
let h6 = P.nextNode(), o9 = 0, n7 = 0, r6 = s6[0];
|
|
1111
1111
|
for (; void 0 !== r6; ) {
|
|
1112
|
-
if (
|
|
1113
|
-
let
|
|
1114
|
-
2 === r6.type ?
|
|
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
1115
|
}
|
|
1116
|
-
|
|
1116
|
+
o9 !== (r6 == null ? void 0 : r6.index) && (h6 = P.nextNode(), o9++);
|
|
1117
1117
|
}
|
|
1118
1118
|
return P.currentNode = l2, e6;
|
|
1119
1119
|
}
|
|
1120
1120
|
p(t5) {
|
|
1121
|
-
let
|
|
1122
|
-
for (const
|
|
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
1123
|
}
|
|
1124
1124
|
};
|
|
1125
1125
|
var R = class _R {
|
|
@@ -1127,14 +1127,14 @@ var R = class _R {
|
|
|
1127
1127
|
var _a13, _b3;
|
|
1128
1128
|
return (_b3 = (_a13 = this._$AM) == null ? void 0 : _a13._$AU) != null ? _b3 : this._$Cv;
|
|
1129
1129
|
}
|
|
1130
|
-
constructor(t5,
|
|
1130
|
+
constructor(t5, i7, s6, e6) {
|
|
1131
1131
|
var _a13;
|
|
1132
|
-
this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t5, this._$AB =
|
|
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
1133
|
}
|
|
1134
1134
|
get parentNode() {
|
|
1135
1135
|
let t5 = this._$AA.parentNode;
|
|
1136
|
-
const
|
|
1137
|
-
return void 0 !==
|
|
1136
|
+
const i7 = this._$AM;
|
|
1137
|
+
return void 0 !== i7 && 11 === (t5 == null ? void 0 : t5.nodeType) && (t5 = i7.parentNode), t5;
|
|
1138
1138
|
}
|
|
1139
1139
|
get startNode() {
|
|
1140
1140
|
return this._$AA;
|
|
@@ -1142,8 +1142,8 @@ var R = class _R {
|
|
|
1142
1142
|
get endNode() {
|
|
1143
1143
|
return this._$AB;
|
|
1144
1144
|
}
|
|
1145
|
-
_$AI(t5,
|
|
1146
|
-
t5 = M(this, t5,
|
|
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
1147
|
}
|
|
1148
1148
|
O(t5) {
|
|
1149
1149
|
return this._$AA.parentNode.insertBefore(t5, this._$AB);
|
|
@@ -1156,29 +1156,29 @@ var R = class _R {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
$(t5) {
|
|
1158
1158
|
var _a13;
|
|
1159
|
-
const { values:
|
|
1160
|
-
if (((_a13 = this._$AH) == null ? void 0 : _a13._$AD) === e6) this._$AH.p(
|
|
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
1161
|
else {
|
|
1162
|
-
const t6 = new k(e6, this),
|
|
1163
|
-
t6.p(
|
|
1162
|
+
const t6 = new k(e6, this), s7 = t6.u(this.options);
|
|
1163
|
+
t6.p(i7), this.T(s7), this._$AH = t6;
|
|
1164
1164
|
}
|
|
1165
1165
|
}
|
|
1166
1166
|
_$AC(t5) {
|
|
1167
|
-
let
|
|
1168
|
-
return void 0 ===
|
|
1167
|
+
let i7 = C.get(t5.strings);
|
|
1168
|
+
return void 0 === i7 && C.set(t5.strings, i7 = new S2(t5)), i7;
|
|
1169
1169
|
}
|
|
1170
1170
|
k(t5) {
|
|
1171
1171
|
u2(this._$AH) || (this._$AH = [], this._$AR());
|
|
1172
|
-
const
|
|
1173
|
-
let
|
|
1174
|
-
for (const
|
|
1175
|
-
e6 <
|
|
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
1176
|
}
|
|
1177
|
-
_$AR(t5 = this._$AA.nextSibling,
|
|
1177
|
+
_$AR(t5 = this._$AA.nextSibling, s6) {
|
|
1178
1178
|
var _a13;
|
|
1179
|
-
for ((_a13 = this._$AP) == null ? void 0 : _a13.call(this, false, true,
|
|
1180
|
-
const
|
|
1181
|
-
i2(t5).remove(), t5 =
|
|
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
1182
|
}
|
|
1183
1183
|
}
|
|
1184
1184
|
setConnected(t5) {
|
|
@@ -1193,19 +1193,19 @@ var H = class {
|
|
|
1193
1193
|
get _$AU() {
|
|
1194
1194
|
return this._$AM._$AU;
|
|
1195
1195
|
}
|
|
1196
|
-
constructor(t5,
|
|
1197
|
-
this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t5, this.name =
|
|
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
1198
|
}
|
|
1199
|
-
_$AI(t5,
|
|
1200
|
-
const
|
|
1201
|
-
let
|
|
1202
|
-
if (void 0 ===
|
|
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
1203
|
else {
|
|
1204
1204
|
const e7 = t5;
|
|
1205
|
-
let
|
|
1206
|
-
for (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
1207
|
}
|
|
1208
|
-
|
|
1208
|
+
o9 && !e6 && this.j(t5);
|
|
1209
1209
|
}
|
|
1210
1210
|
j(t5) {
|
|
1211
1211
|
t5 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t5 != null ? t5 : "");
|
|
@@ -1228,14 +1228,14 @@ var L = class extends H {
|
|
|
1228
1228
|
}
|
|
1229
1229
|
};
|
|
1230
1230
|
var z = class extends H {
|
|
1231
|
-
constructor(t5,
|
|
1232
|
-
super(t5,
|
|
1231
|
+
constructor(t5, i7, s6, e6, h6) {
|
|
1232
|
+
super(t5, i7, s6, e6, h6), this.type = 5;
|
|
1233
1233
|
}
|
|
1234
|
-
_$AI(t5,
|
|
1234
|
+
_$AI(t5, i7 = this) {
|
|
1235
1235
|
var _a13;
|
|
1236
|
-
if ((t5 = (_a13 = M(this, t5,
|
|
1237
|
-
const
|
|
1238
|
-
e6 && this.element.removeEventListener(this.name, this,
|
|
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
1239
|
}
|
|
1240
1240
|
handleEvent(t5) {
|
|
1241
1241
|
var _a13, _b3;
|
|
@@ -1243,8 +1243,8 @@ var z = class extends H {
|
|
|
1243
1243
|
}
|
|
1244
1244
|
};
|
|
1245
1245
|
var W = class {
|
|
1246
|
-
constructor(t5,
|
|
1247
|
-
this.element = t5, this.type = 6, this._$AN = void 0, this._$AM =
|
|
1246
|
+
constructor(t5, i7, s6) {
|
|
1247
|
+
this.element = t5, this.type = 6, this._$AN = void 0, this._$AM = i7, this.options = s6;
|
|
1248
1248
|
}
|
|
1249
1249
|
get _$AU() {
|
|
1250
1250
|
return this._$AM._$AU;
|
|
@@ -1257,15 +1257,15 @@ var Z = { M: h2, P: o3, A: n3, C: 1, L: N, R: k, D: d2, V: M, I: R, H, N: L, U:
|
|
|
1257
1257
|
var j = t2.litHtmlPolyfillSupport;
|
|
1258
1258
|
var _a10;
|
|
1259
1259
|
j == null ? void 0 : j(S2, R), ((_a10 = t2.litHtmlVersions) != null ? _a10 : t2.litHtmlVersions = []).push("3.3.3");
|
|
1260
|
-
var B = (t5,
|
|
1260
|
+
var B = (t5, i7, s6) => {
|
|
1261
1261
|
var _a13, _b3;
|
|
1262
|
-
const e6 = (_a13 =
|
|
1263
|
-
let
|
|
1264
|
-
if (void 0 ===
|
|
1265
|
-
const t6 = (_b3 =
|
|
1266
|
-
e6._$litPart$ =
|
|
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
1267
|
}
|
|
1268
|
-
return
|
|
1268
|
+
return h6._$AI(t5), h6;
|
|
1269
1269
|
};
|
|
1270
1270
|
|
|
1271
1271
|
// ../../node_modules/.pnpm/lit-element@4.2.2/node_modules/lit-element/lit-element.js
|
|
@@ -1302,17 +1302,52 @@ o4 == null ? void 0 : o4({ LitElement: i3 });
|
|
|
1302
1302
|
var _a12;
|
|
1303
1303
|
((_a12 = s3.litElementVersions) != null ? _a12 : s3.litElementVersions = []).push("4.2.2");
|
|
1304
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
|
+
|
|
1305
1340
|
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directive.js
|
|
1306
|
-
var
|
|
1341
|
+
var t4 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 };
|
|
1307
1342
|
var e3 = (t5) => (...e6) => ({ _$litDirective$: t5, values: e6 });
|
|
1308
|
-
var
|
|
1343
|
+
var i5 = class {
|
|
1309
1344
|
constructor(t5) {
|
|
1310
1345
|
}
|
|
1311
1346
|
get _$AU() {
|
|
1312
1347
|
return this._$AM._$AU;
|
|
1313
1348
|
}
|
|
1314
|
-
_$AT(t5, e6,
|
|
1315
|
-
this._$Ct = t5, this._$AM = e6, this._$Ci =
|
|
1349
|
+
_$AT(t5, e6, i7) {
|
|
1350
|
+
this._$Ct = t5, this._$AM = e6, this._$Ci = i7;
|
|
1316
1351
|
}
|
|
1317
1352
|
_$AS(t5, e6) {
|
|
1318
1353
|
return this.update(t5, e6);
|
|
@@ -1322,124 +1357,58 @@ var i4 = class {
|
|
|
1322
1357
|
}
|
|
1323
1358
|
};
|
|
1324
1359
|
|
|
1325
|
-
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/unsafe-html.js
|
|
1326
|
-
var e4 = class extends i4 {
|
|
1327
|
-
constructor(i5) {
|
|
1328
|
-
if (super(i5), this.it = A, i5.type !== t3.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
|
|
1329
|
-
}
|
|
1330
|
-
render(r6) {
|
|
1331
|
-
if (r6 === A || null == r6) return this._t = void 0, this.it = r6;
|
|
1332
|
-
if (r6 === E) return r6;
|
|
1333
|
-
if ("string" != typeof r6) throw Error(this.constructor.directiveName + "() called with a non-string value");
|
|
1334
|
-
if (r6 === this.it) return this._t;
|
|
1335
|
-
this.it = r6;
|
|
1336
|
-
const s5 = [r6];
|
|
1337
|
-
return s5.raw = s5, this._t = { _$litType$: this.constructor.resultType, strings: s5, values: [] };
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
e4.directiveName = "unsafeHTML", e4.resultType = 1;
|
|
1341
|
-
var o5 = e3(e4);
|
|
1342
|
-
|
|
1343
|
-
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg
|
|
1344
|
-
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';
|
|
1345
|
-
|
|
1346
|
-
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg
|
|
1347
|
-
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';
|
|
1348
|
-
|
|
1349
|
-
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg
|
|
1350
|
-
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';
|
|
1351
|
-
|
|
1352
|
-
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg
|
|
1353
|
-
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';
|
|
1354
|
-
|
|
1355
|
-
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg
|
|
1356
|
-
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';
|
|
1357
|
-
|
|
1358
|
-
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg
|
|
1359
|
-
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';
|
|
1360
|
-
|
|
1361
|
-
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg
|
|
1362
|
-
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';
|
|
1363
|
-
|
|
1364
|
-
// src/components/icons/index.ts
|
|
1365
|
-
var icons = {
|
|
1366
|
-
close: close_default,
|
|
1367
|
-
collapse: collapse_default,
|
|
1368
|
-
expand: expand_default,
|
|
1369
|
-
pause: pause_fill_default,
|
|
1370
|
-
play: play_fill_default,
|
|
1371
|
-
soundOff: speaker_x_fill_default,
|
|
1372
|
-
soundOn: speaker_high_fill_default
|
|
1373
|
-
};
|
|
1374
|
-
var markup = Object.fromEntries(
|
|
1375
|
-
Object.entries(icons).map(([name, svg]) => [
|
|
1376
|
-
name,
|
|
1377
|
-
svg.replace(
|
|
1378
|
-
"<svg",
|
|
1379
|
-
'<svg class="icon" aria-hidden="true" focusable="false"'
|
|
1380
|
-
)
|
|
1381
|
-
])
|
|
1382
|
-
);
|
|
1383
|
-
function icon(name) {
|
|
1384
|
-
return o5(markup[name]);
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directive-helpers.js
|
|
1388
|
-
var { I: t4 } = Z;
|
|
1389
|
-
var r4 = (o8) => void 0 === o8.strings;
|
|
1390
|
-
|
|
1391
1360
|
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/async-directive.js
|
|
1392
|
-
var
|
|
1361
|
+
var s5 = (i7, t5) => {
|
|
1393
1362
|
var _a13;
|
|
1394
|
-
const e6 =
|
|
1363
|
+
const e6 = i7._$AN;
|
|
1395
1364
|
if (void 0 === e6) return false;
|
|
1396
|
-
for (const
|
|
1365
|
+
for (const i8 of e6) (_a13 = i8._$AO) == null ? void 0 : _a13.call(i8, t5, false), s5(i8, t5);
|
|
1397
1366
|
return true;
|
|
1398
1367
|
};
|
|
1399
|
-
var
|
|
1368
|
+
var o5 = (i7) => {
|
|
1400
1369
|
let t5, e6;
|
|
1401
1370
|
do {
|
|
1402
|
-
if (void 0 === (t5 =
|
|
1403
|
-
e6 = t5._$AN, e6.delete(
|
|
1371
|
+
if (void 0 === (t5 = i7._$AM)) break;
|
|
1372
|
+
e6 = t5._$AN, e6.delete(i7), i7 = t5;
|
|
1404
1373
|
} while (0 === (e6 == null ? void 0 : e6.size));
|
|
1405
1374
|
};
|
|
1406
|
-
var r5 = (
|
|
1407
|
-
for (let t5; t5 =
|
|
1375
|
+
var r5 = (i7) => {
|
|
1376
|
+
for (let t5; t5 = i7._$AM; i7 = t5) {
|
|
1408
1377
|
let e6 = t5._$AN;
|
|
1409
1378
|
if (void 0 === e6) t5._$AN = e6 = /* @__PURE__ */ new Set();
|
|
1410
|
-
else if (e6.has(
|
|
1411
|
-
e6.add(
|
|
1379
|
+
else if (e6.has(i7)) break;
|
|
1380
|
+
e6.add(i7), c4(t5);
|
|
1412
1381
|
}
|
|
1413
1382
|
};
|
|
1414
|
-
function
|
|
1415
|
-
void 0 !== this._$AN ? (
|
|
1383
|
+
function h4(i7) {
|
|
1384
|
+
void 0 !== this._$AN ? (o5(this), this._$AM = i7, r5(this)) : this._$AM = i7;
|
|
1416
1385
|
}
|
|
1417
|
-
function n4(
|
|
1418
|
-
const r6 = this._$AH,
|
|
1419
|
-
if (void 0 !==
|
|
1420
|
-
else null != r6 && (
|
|
1421
|
-
else
|
|
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);
|
|
1422
1391
|
}
|
|
1423
|
-
var c4 = (
|
|
1392
|
+
var c4 = (i7) => {
|
|
1424
1393
|
var _a13, _b3;
|
|
1425
|
-
|
|
1394
|
+
i7.type == t4.CHILD && ((_a13 = i7._$AP) != null ? _a13 : i7._$AP = n4, (_b3 = i7._$AQ) != null ? _b3 : i7._$AQ = h4);
|
|
1426
1395
|
};
|
|
1427
|
-
var f3 = class extends
|
|
1396
|
+
var f3 = class extends i5 {
|
|
1428
1397
|
constructor() {
|
|
1429
1398
|
super(...arguments), this._$AN = void 0;
|
|
1430
1399
|
}
|
|
1431
|
-
_$AT(
|
|
1432
|
-
super._$AT(
|
|
1400
|
+
_$AT(i7, t5, e6) {
|
|
1401
|
+
super._$AT(i7, t5, e6), r5(this), this.isConnected = i7._$AU;
|
|
1433
1402
|
}
|
|
1434
|
-
_$AO(
|
|
1403
|
+
_$AO(i7, t5 = true) {
|
|
1435
1404
|
var _a13, _b3;
|
|
1436
|
-
|
|
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));
|
|
1437
1406
|
}
|
|
1438
1407
|
setValue(t5) {
|
|
1439
1408
|
if (r4(this._$Ct)) this._$Ct._$AI(t5, this);
|
|
1440
1409
|
else {
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1410
|
+
const i7 = [...this._$Ct._$AH];
|
|
1411
|
+
i7[this._$Ci] = t5, this._$Ct._$AI(i7, this, 0);
|
|
1443
1412
|
}
|
|
1444
1413
|
}
|
|
1445
1414
|
disconnected() {
|
|
@@ -1449,30 +1418,30 @@ var f3 = class extends i4 {
|
|
|
1449
1418
|
};
|
|
1450
1419
|
|
|
1451
1420
|
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/ref.js
|
|
1452
|
-
var
|
|
1453
|
-
var
|
|
1421
|
+
var e4 = () => new h5();
|
|
1422
|
+
var h5 = class {
|
|
1454
1423
|
};
|
|
1455
|
-
var
|
|
1424
|
+
var o6 = /* @__PURE__ */ new WeakMap();
|
|
1456
1425
|
var n5 = e3(class extends f3 {
|
|
1457
|
-
render(
|
|
1426
|
+
render(i7) {
|
|
1458
1427
|
return A;
|
|
1459
1428
|
}
|
|
1460
|
-
update(
|
|
1429
|
+
update(i7, [s6]) {
|
|
1461
1430
|
var _a13;
|
|
1462
|
-
const e6 =
|
|
1463
|
-
return e6 && this.rt(void 0), (e6 || this.lt !== this.ct) && (this.G =
|
|
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;
|
|
1464
1433
|
}
|
|
1465
1434
|
rt(t5) {
|
|
1466
1435
|
var _a13;
|
|
1467
1436
|
if (void 0 !== this.G) if (this.isConnected || (t5 = void 0), "function" == typeof this.G) {
|
|
1468
|
-
const
|
|
1469
|
-
let
|
|
1470
|
-
void 0 ===
|
|
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);
|
|
1471
1440
|
} else this.G.value = t5;
|
|
1472
1441
|
}
|
|
1473
1442
|
get lt() {
|
|
1474
1443
|
var _a13, _b3, _c;
|
|
1475
|
-
return "function" == typeof this.G ? (_b3 =
|
|
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;
|
|
1476
1445
|
}
|
|
1477
1446
|
disconnected() {
|
|
1478
1447
|
this.lt === this.ct && this.rt(void 0);
|
|
@@ -1482,7 +1451,81 @@ var n5 = e3(class extends f3 {
|
|
|
1482
1451
|
}
|
|
1483
1452
|
});
|
|
1484
1453
|
|
|
1485
|
-
//
|
|
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
|
+
|
|
1478
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg
|
|
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';
|
|
1480
|
+
|
|
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
|
|
1486
1529
|
function httpUrl(value) {
|
|
1487
1530
|
if (!value) return null;
|
|
1488
1531
|
try {
|
|
@@ -1492,6 +1535,8 @@ function httpUrl(value) {
|
|
|
1492
1535
|
return null;
|
|
1493
1536
|
}
|
|
1494
1537
|
}
|
|
1538
|
+
|
|
1539
|
+
// src/components/media/media.ts
|
|
1495
1540
|
function prefersReducedMotion() {
|
|
1496
1541
|
var _a13, _b3;
|
|
1497
1542
|
return (_b3 = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis, "(prefers-reduced-motion: reduce)").matches) != null ? _b3 : false;
|
|
@@ -1499,9 +1544,9 @@ function prefersReducedMotion() {
|
|
|
1499
1544
|
function hasVideo(story, video) {
|
|
1500
1545
|
return !video.failed && httpUrl(story.media_url) !== null;
|
|
1501
1546
|
}
|
|
1502
|
-
function renderMedia(story, video) {
|
|
1547
|
+
function renderMedia(story, video, { withVideo = true, loop = true, onEnded } = {}) {
|
|
1503
1548
|
const posterUrl = httpUrl(story.poster_url);
|
|
1504
|
-
const mediaUrl = httpUrl(story.media_url);
|
|
1549
|
+
const mediaUrl = withVideo ? httpUrl(story.media_url) : null;
|
|
1505
1550
|
return T`
|
|
1506
1551
|
${posterUrl ? T`<img class="poster" alt="" src=${posterUrl} />` : A}
|
|
1507
1552
|
${mediaUrl && !video.failed ? T`
|
|
@@ -1509,7 +1554,7 @@ function renderMedia(story, video) {
|
|
|
1509
1554
|
class="video"
|
|
1510
1555
|
muted
|
|
1511
1556
|
playsinline
|
|
1512
|
-
loop
|
|
1557
|
+
?loop=${loop}
|
|
1513
1558
|
preload="metadata"
|
|
1514
1559
|
.muted=${true}
|
|
1515
1560
|
?autoplay=${!prefersReducedMotion()}
|
|
@@ -1520,6 +1565,7 @@ function renderMedia(story, video) {
|
|
|
1520
1565
|
@pause=${video.sync}
|
|
1521
1566
|
@volumechange=${video.sync}
|
|
1522
1567
|
@error=${video.fail}
|
|
1568
|
+
@ended=${onEnded}
|
|
1523
1569
|
></video>
|
|
1524
1570
|
` : A}
|
|
1525
1571
|
`;
|
|
@@ -1534,7 +1580,7 @@ var VideoController = class {
|
|
|
1534
1580
|
constructor(host) {
|
|
1535
1581
|
this.host = host;
|
|
1536
1582
|
/** Bound to the <video> by renderMedia. */
|
|
1537
|
-
this.ref =
|
|
1583
|
+
this.ref = e4();
|
|
1538
1584
|
this.paused = true;
|
|
1539
1585
|
// The video always starts muted: that is what browsers allow to autoplay.
|
|
1540
1586
|
this.muted = true;
|
|
@@ -1554,6 +1600,11 @@ var VideoController = class {
|
|
|
1554
1600
|
this.host.requestUpdate();
|
|
1555
1601
|
};
|
|
1556
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
|
+
}
|
|
1557
1608
|
/** For a new <video>, such as each time the player opens. */
|
|
1558
1609
|
reset() {
|
|
1559
1610
|
this.paused = true;
|
|
@@ -1579,68 +1630,671 @@ var VideoController = class {
|
|
|
1579
1630
|
if (video.paused) playVideo(video);
|
|
1580
1631
|
else video.pause();
|
|
1581
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
|
+
}
|
|
1582
1668
|
toggleMuted() {
|
|
1583
1669
|
const video = this.ref.value;
|
|
1584
1670
|
if (video) video.muted = !video.muted;
|
|
1585
1671
|
}
|
|
1586
1672
|
};
|
|
1587
1673
|
|
|
1588
|
-
// src/components/
|
|
1589
|
-
var
|
|
1590
|
-
|
|
1591
|
-
|
|
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;
|
|
1592
1885
|
box-sizing: border-box;
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
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;
|
|
1598
1896
|
}
|
|
1599
1897
|
|
|
1600
|
-
/* The
|
|
1601
|
-
|
|
1602
|
-
.card-
|
|
1898
|
+
/* The glass's tint and inner light, darker on hover. */
|
|
1899
|
+
.card-product::before,
|
|
1900
|
+
.card-cta::before {
|
|
1603
1901
|
position: absolute;
|
|
1604
1902
|
inset: 0;
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
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 {
|
|
1610
1913
|
cursor: pointer;
|
|
1611
1914
|
}
|
|
1612
1915
|
|
|
1613
|
-
.card-
|
|
1614
|
-
|
|
1916
|
+
.card-product:focus-visible,
|
|
1917
|
+
.card-cta:focus-visible {
|
|
1918
|
+
outline: 2px solid #fff;
|
|
1919
|
+
outline-offset: 2px;
|
|
1615
1920
|
}
|
|
1616
1921
|
|
|
1617
|
-
|
|
1618
|
-
|
|
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
|
+
}
|
|
1619
1932
|
}
|
|
1620
1933
|
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
height:
|
|
1627
|
-
|
|
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;
|
|
1628
1945
|
}
|
|
1629
1946
|
|
|
1630
|
-
.
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
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
|
+
}
|
|
2094
|
+
|
|
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
|
+
}
|
|
2101
|
+
|
|
2102
|
+
.product-expandable[data-open]::before {
|
|
2103
|
+
opacity: 0;
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
.product-expandable[data-open] .product-price {
|
|
2107
|
+
color: inherit;
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
.product-expandable[data-open] .product-list-price {
|
|
2111
|
+
color: var(--vtex-ads-story-color-muted, #6b6b6b);
|
|
2112
|
+
opacity: 1;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
.product-expandable[data-open] .product-summary {
|
|
2116
|
+
padding: 12px;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
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
|
+
`;
|
|
2239
|
+
|
|
2240
|
+
// src/components/card/card.ts
|
|
2241
|
+
var cardStyles = i`
|
|
2242
|
+
/* 9:16 at the height its container gives it (--card-height, default
|
|
2243
|
+
500px). */
|
|
2244
|
+
.card {
|
|
2245
|
+
position: relative;
|
|
2246
|
+
box-sizing: border-box;
|
|
2247
|
+
width: calc(var(--card-height, 500px) * 9 / 16);
|
|
2248
|
+
height: var(--card-height, 500px);
|
|
2249
|
+
overflow: hidden;
|
|
2250
|
+
border-radius: var(--vtex-ads-story-radius, 20px);
|
|
2251
|
+
background: #000;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
/* The card's button covers it. The focus ring goes on the card, since the
|
|
2255
|
+
card's overflow would clip the button's own. */
|
|
2256
|
+
.card-open {
|
|
2257
|
+
position: absolute;
|
|
2258
|
+
inset: 0;
|
|
2259
|
+
width: 100%;
|
|
2260
|
+
height: 100%;
|
|
2261
|
+
padding: 0;
|
|
2262
|
+
border: 0;
|
|
2263
|
+
background: transparent;
|
|
2264
|
+
cursor: pointer;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
.card-open:focus-visible {
|
|
2268
|
+
outline: none;
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
.card:has(> .card-open:focus-visible) {
|
|
2272
|
+
outline: auto;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
.poster,
|
|
2276
|
+
.video {
|
|
2277
|
+
position: absolute;
|
|
2278
|
+
inset: 0;
|
|
2279
|
+
width: 100%;
|
|
2280
|
+
height: 100%;
|
|
2281
|
+
object-fit: cover;
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
.play {
|
|
2285
|
+
position: absolute;
|
|
2286
|
+
top: 50%;
|
|
2287
|
+
left: 50%;
|
|
2288
|
+
display: grid;
|
|
2289
|
+
width: 66px;
|
|
2290
|
+
height: 66px;
|
|
2291
|
+
place-items: center;
|
|
2292
|
+
border-radius: 50%;
|
|
2293
|
+
background:
|
|
2294
|
+
linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06)),
|
|
2295
|
+
rgba(255, 255, 255, 0.15);
|
|
2296
|
+
backdrop-filter: blur(2px);
|
|
2297
|
+
box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);
|
|
1644
2298
|
transform: translate(-50%, -50%);
|
|
1645
2299
|
transition:
|
|
1646
2300
|
opacity 0.3s ease,
|
|
@@ -1698,7 +2352,7 @@ function renderSoundButton(video, options) {
|
|
|
1698
2352
|
<button
|
|
1699
2353
|
type="button"
|
|
1700
2354
|
class="card-sound"
|
|
1701
|
-
aria-label=${video.muted ? options.
|
|
2355
|
+
aria-label=${video.muted ? options.labels.soundOn : options.labels.soundOff}
|
|
1702
2356
|
@click=${() => video.toggleMuted()}
|
|
1703
2357
|
>
|
|
1704
2358
|
${icon(video.muted ? "soundOff" : "soundOn")}
|
|
@@ -1706,23 +2360,805 @@ function renderSoundButton(video, options) {
|
|
|
1706
2360
|
`;
|
|
1707
2361
|
}
|
|
1708
2362
|
function renderCard(story, video, options) {
|
|
2363
|
+
var _a13, _b3;
|
|
2364
|
+
const withVideo = (_a13 = options.withVideo) != null ? _a13 : true;
|
|
1709
2365
|
return T`
|
|
1710
|
-
<div
|
|
1711
|
-
|
|
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 })}
|
|
1712
2375
|
<button
|
|
1713
2376
|
type="button"
|
|
1714
2377
|
class="card-open"
|
|
2378
|
+
${n5(options.openRef)}
|
|
1715
2379
|
aria-label=${options.label}
|
|
1716
2380
|
@click=${options.onSelect}
|
|
1717
2381
|
>
|
|
1718
2382
|
<span class="play" aria-hidden="true">${icon("play")}</span>
|
|
1719
2383
|
</button>
|
|
1720
|
-
${hasVideo(story, video) && !video.paused ? renderSoundButton(video, options) : A}
|
|
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}
|
|
1721
2390
|
</div>
|
|
1722
2391
|
`;
|
|
1723
2392
|
}
|
|
1724
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);
|
|
3121
|
+
}
|
|
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);
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
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);
|
|
3141
|
+
}
|
|
3142
|
+
stopTimer(watched) {
|
|
3143
|
+
clearTimeout(watched.timer);
|
|
3144
|
+
watched.timer = void 0;
|
|
3145
|
+
}
|
|
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
|
+
};
|
|
3158
|
+
|
|
1725
3159
|
// src/components/player/player.ts
|
|
3160
|
+
var NEAR_GAP = 72;
|
|
3161
|
+
var FAR_GAP = 48;
|
|
1726
3162
|
var playerStyles = i`
|
|
1727
3163
|
.player {
|
|
1728
3164
|
position: fixed;
|
|
@@ -1756,12 +3192,28 @@ var playerStyles = i`
|
|
|
1756
3192
|
background: transparent;
|
|
1757
3193
|
}
|
|
1758
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
|
+
|
|
1759
3201
|
.player-frame {
|
|
1760
3202
|
position: relative;
|
|
1761
3203
|
width: 100%;
|
|
1762
3204
|
height: 100%;
|
|
1763
3205
|
}
|
|
1764
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
|
+
|
|
1765
3217
|
.player .card {
|
|
1766
3218
|
width: 100%;
|
|
1767
3219
|
height: 100%;
|
|
@@ -1808,6 +3260,26 @@ var playerStyles = i`
|
|
|
1808
3260
|
height: 20px;
|
|
1809
3261
|
}
|
|
1810
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
|
+
|
|
1811
3283
|
/* Above the card: on narrow screens the expanded card can cover them. */
|
|
1812
3284
|
.player-controls {
|
|
1813
3285
|
position: absolute;
|
|
@@ -1818,6 +3290,12 @@ var playerStyles = i`
|
|
|
1818
3290
|
gap: 8px;
|
|
1819
3291
|
}
|
|
1820
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
|
+
|
|
1821
3299
|
.player-button {
|
|
1822
3300
|
display: grid;
|
|
1823
3301
|
width: 36px;
|
|
@@ -1871,6 +3349,116 @@ var playerStyles = i`
|
|
|
1871
3349
|
height: 40px;
|
|
1872
3350
|
}
|
|
1873
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
|
+
|
|
1874
3462
|
@media (max-width: 576px) {
|
|
1875
3463
|
.player {
|
|
1876
3464
|
right: 12px;
|
|
@@ -1878,6 +3466,18 @@ var playerStyles = i`
|
|
|
1878
3466
|
height: 391px;
|
|
1879
3467
|
}
|
|
1880
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
|
+
|
|
1881
3481
|
.player[data-expanded] {
|
|
1882
3482
|
background: #000;
|
|
1883
3483
|
}
|
|
@@ -1900,6 +3500,28 @@ var playerStyles = i`
|
|
|
1900
3500
|
top: 60px;
|
|
1901
3501
|
right: 12px;
|
|
1902
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
|
+
}
|
|
1903
3525
|
}
|
|
1904
3526
|
|
|
1905
3527
|
@keyframes player-in {
|
|
@@ -1915,6 +3537,88 @@ var playerStyles = i`
|
|
|
1915
3537
|
}
|
|
1916
3538
|
}
|
|
1917
3539
|
`;
|
|
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
|
+
)
|
|
3590
|
+
);
|
|
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;
|
|
1918
3622
|
function supportsPopover(dialog) {
|
|
1919
3623
|
return typeof dialog.showPopover === "function";
|
|
1920
3624
|
}
|
|
@@ -1925,17 +3629,33 @@ var PlayerController = class {
|
|
|
1925
3629
|
/** Rendered and, once the host has updated, shown. */
|
|
1926
3630
|
this.isOpen = false;
|
|
1927
3631
|
this.expanded = false;
|
|
3632
|
+
/** The product panel is open. Closed again on a step and on opening. */
|
|
3633
|
+
this.productOpen = false;
|
|
1928
3634
|
/** Switched modes at least once: only the first opening fades in. */
|
|
1929
3635
|
this.switched = false;
|
|
1930
3636
|
/** The dialog is showing, in the mode `expanded` says. */
|
|
1931
3637
|
this.shown = false;
|
|
1932
|
-
this.dialog =
|
|
1933
|
-
this.expandButton =
|
|
1934
|
-
this.closeButton =
|
|
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 = [];
|
|
1935
3654
|
this.toggleExpanded = async () => {
|
|
1936
3655
|
var _a13;
|
|
1937
3656
|
const dialog = this.dialog.value;
|
|
1938
3657
|
if (!dialog) return;
|
|
3658
|
+
this.cancelAnimations();
|
|
1939
3659
|
this.hide(dialog);
|
|
1940
3660
|
this.expanded = !this.expanded;
|
|
1941
3661
|
this.switched = true;
|
|
@@ -1949,6 +3669,17 @@ var PlayerController = class {
|
|
|
1949
3669
|
this.onKeyDown = (event) => {
|
|
1950
3670
|
if (event.key === "Escape") this.options.onClose();
|
|
1951
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
|
+
};
|
|
1952
3683
|
// Clicks on the backdrop of the expanded view reach the dialog itself.
|
|
1953
3684
|
this.onDialogClick = (event) => {
|
|
1954
3685
|
if (this.expanded && event.target === event.currentTarget) {
|
|
@@ -1960,20 +3691,52 @@ var PlayerController = class {
|
|
|
1960
3691
|
event.preventDefault();
|
|
1961
3692
|
this.options.onClose();
|
|
1962
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
|
+
};
|
|
1963
3711
|
host.addController(this);
|
|
1964
3712
|
this.video = new VideoController(host);
|
|
1965
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
|
+
}
|
|
1966
3722
|
hostDisconnected() {
|
|
1967
3723
|
this.close();
|
|
1968
3724
|
}
|
|
1969
|
-
/**
|
|
1970
|
-
|
|
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 } = {}) {
|
|
1971
3731
|
var _a13;
|
|
1972
3732
|
if (this.isOpen) return;
|
|
1973
3733
|
document.addEventListener("keydown", this.onKeyDown);
|
|
1974
3734
|
this.isOpen = true;
|
|
1975
3735
|
this.expanded = false;
|
|
3736
|
+
this.productOpen = productOpen;
|
|
1976
3737
|
this.switched = false;
|
|
3738
|
+
this.rendered = void 0;
|
|
3739
|
+
this.beforeStep = void 0;
|
|
1977
3740
|
this.video.reset();
|
|
1978
3741
|
this.host.requestUpdate();
|
|
1979
3742
|
await this.host.updateComplete;
|
|
@@ -1987,11 +3750,99 @@ var PlayerController = class {
|
|
|
1987
3750
|
close() {
|
|
1988
3751
|
if (!this.isOpen) return;
|
|
1989
3752
|
document.removeEventListener("keydown", this.onKeyDown);
|
|
3753
|
+
this.cancelAnimations();
|
|
1990
3754
|
const dialog = this.dialog.value;
|
|
1991
3755
|
if (dialog) this.hide(dialog);
|
|
1992
3756
|
this.isOpen = false;
|
|
1993
3757
|
this.host.requestUpdate();
|
|
1994
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
|
+
}
|
|
1995
3846
|
// Mini: a manual popover, or a non-modal dialog without popover support.
|
|
1996
3847
|
// Expanded: a modal dialog.
|
|
1997
3848
|
// Already showing: a second expand click in the same task resumes after the
|
|
@@ -2012,12 +3863,35 @@ var PlayerController = class {
|
|
|
2012
3863
|
this.shown = false;
|
|
2013
3864
|
}
|
|
2014
3865
|
/**
|
|
2015
|
-
*
|
|
2016
|
-
*
|
|
2017
|
-
*
|
|
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.
|
|
2018
3869
|
*/
|
|
2019
|
-
|
|
2020
|
-
|
|
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;
|
|
2021
3895
|
const onToggle = (event) => {
|
|
2022
3896
|
event.stopPropagation();
|
|
2023
3897
|
video.togglePlayback();
|
|
@@ -2030,7 +3904,7 @@ var PlayerController = class {
|
|
|
2030
3904
|
<button
|
|
2031
3905
|
type="button"
|
|
2032
3906
|
class="play player-toggle"
|
|
2033
|
-
aria-label=${video.paused ?
|
|
3907
|
+
aria-label=${video.paused ? labels.play : labels.pause}
|
|
2034
3908
|
@click=${onToggle}
|
|
2035
3909
|
>
|
|
2036
3910
|
${icon(video.paused ? "play" : "pause")}
|
|
@@ -2038,57 +3912,196 @@ var PlayerController = class {
|
|
|
2038
3912
|
<button
|
|
2039
3913
|
type="button"
|
|
2040
3914
|
class="player-button player-sound"
|
|
2041
|
-
aria-label=${video.muted ?
|
|
3915
|
+
aria-label=${video.muted ? labels.soundOn : labels.soundOff}
|
|
2042
3916
|
@click=${onSound}
|
|
2043
3917
|
>
|
|
2044
3918
|
${icon(video.muted ? "soundOff" : "soundOn")}
|
|
2045
3919
|
</button>
|
|
2046
3920
|
`;
|
|
2047
3921
|
}
|
|
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
|
+
}
|
|
3981
|
+
);
|
|
3982
|
+
}
|
|
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
|
+
`;
|
|
4008
|
+
}
|
|
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
|
+
}
|
|
2048
4045
|
/**
|
|
2049
4046
|
* The player <dialog> while it is open. Clicking the video also plays or
|
|
2050
|
-
* pauses it
|
|
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.
|
|
2051
4052
|
*/
|
|
2052
|
-
render(story
|
|
4053
|
+
render(story, {
|
|
4054
|
+
labels,
|
|
4055
|
+
navigation = false,
|
|
4056
|
+
neighbors = [],
|
|
4057
|
+
product,
|
|
4058
|
+
cta,
|
|
4059
|
+
onPress
|
|
4060
|
+
}) {
|
|
2053
4061
|
if (!this.isOpen) return A;
|
|
2054
|
-
const { video,
|
|
2055
|
-
const
|
|
4062
|
+
const { video, expanded } = this;
|
|
4063
|
+
const shownNeighbors = this.track(story, neighbors);
|
|
4064
|
+
const pair = this.pairDirection !== 0;
|
|
4065
|
+
this.navigation = navigation;
|
|
2056
4066
|
return T`
|
|
2057
4067
|
<dialog
|
|
2058
4068
|
class="player"
|
|
2059
4069
|
popover="manual"
|
|
2060
|
-
aria-label=${
|
|
4070
|
+
aria-label=${labels.player}
|
|
2061
4071
|
?data-expanded=${expanded}
|
|
4072
|
+
?data-pair=${pair}
|
|
4073
|
+
style=${o8({
|
|
4074
|
+
"--pair-dir": pair ? String(this.pairDirection) : void 0
|
|
4075
|
+
})}
|
|
2062
4076
|
?data-switched=${this.switched}
|
|
2063
|
-
?data-paused=${
|
|
4077
|
+
?data-paused=${hasVideo(story, video) && video.paused}
|
|
4078
|
+
tabindex="-1"
|
|
2064
4079
|
${n5(this.dialog)}
|
|
2065
4080
|
@click=${this.onDialogClick}
|
|
2066
4081
|
@cancel=${this.onCancel}
|
|
4082
|
+
@keydown=${this.onPlayerKeyDown}
|
|
2067
4083
|
>
|
|
4084
|
+
${this.renderNeighbors(shownNeighbors, labels)}
|
|
2068
4085
|
<div class="player-frame">
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
</div>
|
|
2089
|
-
<div class="card" @click=${() => video.togglePlayback()}>
|
|
2090
|
-
${renderMedia(story, video)}
|
|
2091
|
-
${withVideo ? this.renderVideoControls() : A}
|
|
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>
|
|
2092
4105
|
</div>
|
|
2093
4106
|
</div>
|
|
2094
4107
|
</dialog>
|
|
@@ -2096,14 +4109,187 @@ var PlayerController = class {
|
|
|
2096
4109
|
}
|
|
2097
4110
|
};
|
|
2098
4111
|
|
|
2099
|
-
// src/
|
|
2100
|
-
var
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
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 }
|
|
4159
|
+
);
|
|
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;
|
|
4177
|
+
}
|
|
4178
|
+
|
|
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();
|
|
4227
|
+
}
|
|
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
|
|
2104
4283
|
};
|
|
2105
|
-
|
|
4284
|
+
|
|
4285
|
+
// src/locales/pt.ts
|
|
4286
|
+
var pt = {
|
|
2106
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",
|
|
2107
4293
|
player: "V\xEDdeo",
|
|
2108
4294
|
expand: "Expandir v\xEDdeo",
|
|
2109
4295
|
collapse: "Reduzir v\xEDdeo",
|
|
@@ -2111,23 +4297,119 @@ var LABELS = {
|
|
|
2111
4297
|
play: "Reproduzir v\xEDdeo",
|
|
2112
4298
|
pause: "Pausar v\xEDdeo",
|
|
2113
4299
|
soundOn: "Ativar som",
|
|
2114
|
-
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
|
|
2115
4349
|
};
|
|
2116
|
-
var
|
|
4350
|
+
var hydrationConverter = {
|
|
4351
|
+
fromAttribute: (value) => value === "none" ? "none" : void 0
|
|
4352
|
+
};
|
|
4353
|
+
var VtexAdsStoryCarouselElement = class extends i3 {
|
|
2117
4354
|
constructor() {
|
|
2118
|
-
super(
|
|
2119
|
-
|
|
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
|
+
});
|
|
2120
4379
|
this.player = new PlayerController(this, {
|
|
2121
|
-
|
|
2122
|
-
expandLabel: LABELS.expand,
|
|
2123
|
-
collapseLabel: LABELS.collapse,
|
|
2124
|
-
closeLabel: LABELS.close,
|
|
2125
|
-
playLabel: LABELS.play,
|
|
2126
|
-
pauseLabel: LABELS.pause,
|
|
2127
|
-
soundOnLabel: LABELS.soundOn,
|
|
2128
|
-
soundOffLabel: LABELS.soundOff,
|
|
4380
|
+
onStep: (delta) => this.stepInPlayer(delta),
|
|
2129
4381
|
onClose: () => this.closePlayer()
|
|
2130
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 = [];
|
|
2131
4413
|
}
|
|
2132
4414
|
// Lit keeps the card's DOM when the element is moved (removed and appended
|
|
2133
4415
|
// again), but the browser pauses a removed video and doesn't autoplay it
|
|
@@ -2136,39 +4418,255 @@ var VtexAdsStoryElement = class extends i3 {
|
|
|
2136
4418
|
// Not in VideoController.hostConnected: there, the player's video is still
|
|
2137
4419
|
// in the DOM until the next update and would play for a moment.
|
|
2138
4420
|
connectedCallback() {
|
|
4421
|
+
var _a13;
|
|
2139
4422
|
super.connectedCallback();
|
|
2140
|
-
this.
|
|
4423
|
+
for (const video of this.cardVideos.values()) video.resume();
|
|
4424
|
+
if ((_a13 = this.request) == null ? void 0 : _a13.signal.aborted) void this.loadStory();
|
|
4425
|
+
}
|
|
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();
|
|
4431
|
+
}
|
|
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
|
|
4467
|
+
});
|
|
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;
|
|
4492
|
+
}
|
|
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);
|
|
4503
|
+
}
|
|
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];
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
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);
|
|
2141
4565
|
}
|
|
2142
|
-
|
|
4566
|
+
// From the card's product, the player opens with the product panel open.
|
|
4567
|
+
openPlayer({ productOpen = false } = {}) {
|
|
4568
|
+
var _a13;
|
|
2143
4569
|
if (this.player.isOpen) return;
|
|
2144
|
-
this.
|
|
2145
|
-
void this.player.open();
|
|
4570
|
+
(_a13 = this.activeVideo) == null ? void 0 : _a13.pause();
|
|
4571
|
+
void this.player.open({ productOpen });
|
|
2146
4572
|
}
|
|
2147
4573
|
// The player also closes on its own when the element leaves the page,
|
|
2148
4574
|
// without this: there is no card to give focus back to or to resume playing
|
|
2149
4575
|
// (it would play out of sight).
|
|
2150
4576
|
closePlayer() {
|
|
2151
|
-
var _a13;
|
|
2152
4577
|
if (!this.player.isOpen) return;
|
|
2153
4578
|
this.player.close();
|
|
2154
|
-
this.
|
|
2155
|
-
|
|
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);
|
|
2156
4618
|
}
|
|
2157
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
|
+
});
|
|
2158
4632
|
return T`
|
|
2159
4633
|
<div class="root">
|
|
2160
|
-
${
|
|
2161
|
-
label: LABELS.watch,
|
|
2162
|
-
soundOnLabel: LABELS.soundOn,
|
|
2163
|
-
soundOffLabel: LABELS.soundOff,
|
|
2164
|
-
onSelect: () => this.openPlayer()
|
|
2165
|
-
})}
|
|
4634
|
+
${this.carousel.render(stories, this.renderSlide, this.labels)}
|
|
2166
4635
|
</div>
|
|
2167
|
-
${this.player.render(
|
|
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
|
+
})}
|
|
2168
4644
|
`;
|
|
2169
4645
|
}
|
|
2170
4646
|
};
|
|
2171
|
-
|
|
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 = [
|
|
2172
4670
|
i`
|
|
2173
4671
|
:host {
|
|
2174
4672
|
display: block;
|
|
@@ -2177,18 +4675,20 @@ VtexAdsStoryElement.styles = [
|
|
|
2177
4675
|
}
|
|
2178
4676
|
`,
|
|
2179
4677
|
cardStyles,
|
|
4678
|
+
productStyles,
|
|
4679
|
+
carouselStyles,
|
|
2180
4680
|
playerStyles
|
|
2181
4681
|
];
|
|
2182
|
-
function
|
|
4682
|
+
function defineVtexAdsStoryCarousel() {
|
|
2183
4683
|
if (typeof customElements === "undefined") return;
|
|
2184
4684
|
if (customElements.get(TAG_NAME)) return;
|
|
2185
|
-
customElements.define(TAG_NAME,
|
|
4685
|
+
customElements.define(TAG_NAME, VtexAdsStoryCarouselElement);
|
|
2186
4686
|
}
|
|
2187
4687
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2188
4688
|
0 && (module.exports = {
|
|
2189
4689
|
TAG_NAME,
|
|
2190
|
-
|
|
2191
|
-
|
|
4690
|
+
VtexAdsStoryCarouselElement,
|
|
4691
|
+
defineVtexAdsStoryCarousel
|
|
2192
4692
|
});
|
|
2193
4693
|
/*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */
|
|
2194
4694
|
/*! Bundled license information:
|
|
@@ -2220,8 +4720,9 @@ function defineVtexAdsStories() {
|
|
|
2220
4720
|
lit-html/node/lit-html.js:
|
|
2221
4721
|
lit-element/lit-element.js:
|
|
2222
4722
|
lit-html/node/directive.js:
|
|
2223
|
-
lit-html/node/directives/unsafe-html.js:
|
|
2224
4723
|
lit-html/node/async-directive.js:
|
|
4724
|
+
lit-html/node/directives/unsafe-html.js:
|
|
4725
|
+
lit-html/node/directives/repeat.js:
|
|
2225
4726
|
(**
|
|
2226
4727
|
* @license
|
|
2227
4728
|
* Copyright 2017 Google LLC
|
|
@@ -2242,5 +4743,12 @@ lit-html/node/directives/ref.js:
|
|
|
2242
4743
|
* Copyright 2020 Google LLC
|
|
2243
4744
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
2244
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
|
+
*)
|
|
2245
4753
|
*/
|
|
2246
4754
|
//# sourceMappingURL=index.cjs.map
|