@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/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/story/story.ts","../../src/components/card/card.ts","../../src/components/icons/index.ts","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg","../../src/components/media/media.ts","../../src/components/media/video-controller.ts","../../src/components/player/player.ts"],"sourcesContent":["import { css, html, LitElement } from \"lit\";\nimport { cardStyles, renderCard } from \"../components/card\";\nimport { VideoController } from \"../components/media\";\nimport { PlayerController, playerStyles } from \"../components/player\";\nimport type { StoryMedia } from \"../types\";\n\nexport const TAG_NAME = \"vtex-ads-story\";\n\n// Temporary: rendered until the element reads Stories from the ad API.\nconst PLACEHOLDER_STORY: StoryMedia = {\n poster_url: \"https://dummyimage.com/1080x1920/e31c57/fff\",\n media_url: \"https://samplelib.com/mp4/sample-10s-vp9.mp4\",\n};\n\n// Temporary: fixed texts until the store can set them by attribute.\nconst LABELS = {\n watch: \"Assistir vídeo\",\n player: \"Vídeo\",\n expand: \"Expandir vídeo\",\n collapse: \"Reduzir vídeo\",\n close: \"Fechar vídeo\",\n play: \"Reproduzir vídeo\",\n pause: \"Pausar vídeo\",\n soundOn: \"Ativar som\",\n soundOff: \"Desativar som\",\n};\n\n// LitElement is importable where HTMLElement doesn't exist (SSR, Node): Lit\n// falls back to a minimal shim there.\nexport class VtexAdsStoryElement extends LitElement {\n static readonly styles = [\n css`\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n `,\n cardStyles,\n playerStyles,\n ];\n\n private readonly cardVideo = new VideoController(this);\n\n private readonly player = new PlayerController(this, {\n label: LABELS.player,\n expandLabel: LABELS.expand,\n collapseLabel: LABELS.collapse,\n closeLabel: LABELS.close,\n playLabel: LABELS.play,\n pauseLabel: LABELS.pause,\n soundOnLabel: LABELS.soundOn,\n soundOffLabel: LABELS.soundOff,\n onClose: () => this.closePlayer(),\n });\n\n // Lit keeps the card's DOM when the element is moved (removed and appended\n // again), but the browser pauses a removed video and doesn't autoplay it\n // again. resume() only plays a video that autoplays (not with reduced\n // motion), and does nothing on the first connection, before the render.\n // Not in VideoController.hostConnected: there, the player's video is still\n // in the DOM until the next update and would play for a moment.\n connectedCallback() {\n super.connectedCallback();\n this.cardVideo.resume();\n }\n\n private openPlayer() {\n if (this.player.isOpen) return;\n\n // While the player is open, the card behind it stops on its cover.\n this.cardVideo.pause();\n void this.player.open();\n }\n\n // The player also closes on its own when the element leaves the page,\n // without this: there is no card to give focus back to or to resume playing\n // (it would play out of sight).\n private closePlayer() {\n if (!this.player.isOpen) return;\n\n this.player.close();\n this.cardVideo.resume();\n this.renderRoot.querySelector<HTMLElement>(\".root .card-open\")?.focus();\n }\n\n protected render() {\n return html`\n <div class=\"root\">\n ${renderCard(PLACEHOLDER_STORY, this.cardVideo, {\n label: LABELS.watch,\n soundOnLabel: LABELS.soundOn,\n soundOffLabel: LABELS.soundOff,\n onSelect: () => this.openPlayer(),\n })}\n </div>\n ${this.player.render(PLACEHOLDER_STORY)}\n `;\n }\n}\n\n// Types `document.createElement(\"vtex-ads-story\")` and `querySelector` results\n// as VtexAdsStoryElement in any TypeScript project, no framework needed.\ndeclare global {\n interface HTMLElementTagNameMap {\n \"vtex-ads-story\": VtexAdsStoryElement;\n }\n}\n\nexport function defineVtexAdsStories() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryElement);\n}\n","import { css, html, nothing } from \"lit\";\nimport { icon } from \"../icons\";\nimport { hasVideo, renderMedia, type VideoController } from \"../media\";\nimport type { StoryMedia } from \"../../types\";\n\nexport const cardStyles = css`\n .card {\n position: relative;\n box-sizing: border-box;\n width: calc(500px * 9 / 16);\n height: 500px;\n overflow: hidden;\n border-radius: var(--vtex-ads-story-radius, 20px);\n background: #000;\n }\n\n /* The card's button covers it. The focus ring goes on the card, since the\n card's overflow would clip the button's own. */\n .card-open {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n }\n\n .card-open:focus-visible {\n outline: none;\n }\n\n .card:has(> .card-open:focus-visible) {\n outline: auto;\n }\n\n .poster,\n .video {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .play {\n position: absolute;\n top: 50%;\n left: 50%;\n display: grid;\n width: 66px;\n height: 66px;\n place-items: center;\n border-radius: 50%;\n background:\n linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06)),\n rgba(255, 255, 255, 0.15);\n backdrop-filter: blur(2px);\n box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);\n transform: translate(-50%, -50%);\n transition:\n opacity 0.3s ease,\n transform 0.3s ease;\n }\n\n /* The icon's triangle is 18px tall and already sits slightly right of its\n box, so it looks centered in the circle. */\n .play .icon {\n width: 22px;\n height: 22px;\n color: #fff;\n }\n\n /* Sound on/off, at the top right of the card (as in the prototype). */\n .card-sound {\n position: absolute;\n top: 22px;\n right: 12px;\n z-index: 1;\n display: grid;\n width: 28px;\n height: 28px;\n place-items: center;\n padding: 0;\n border: 0;\n background: transparent;\n color: #fff;\n cursor: pointer;\n filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));\n }\n\n .card-sound .icon {\n width: 20px;\n height: 20px;\n }\n\n /* With a mouse, the play button shows only on hover or keyboard focus.\n Touch screens have no hover, so it stays visible there. */\n @media (hover: hover) and (pointer: fine) {\n .play {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.9);\n }\n\n .card:hover .play,\n .card-open:focus-visible .play {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n }\n`;\n\nexport interface CardOptions {\n /** Accessible name of the card. */\n label: string;\n /** Called on click, Enter or Space. */\n onSelect: () => void;\n /** Accessible names of the sound button, shown when the card has a video. */\n soundOnLabel: string;\n soundOffLabel: string;\n}\n\n/**\n * Sound on/off for the card's video, which starts muted. Only shown while the\n * video plays: a video that never plays (reduced motion, or autoplay blocked\n * as in iOS Low Power Mode) has no sound to turn on, and the card paused\n * behind the open player needs none.\n */\nfunction renderSoundButton(video: VideoController, options: CardOptions) {\n return html`\n <button\n type=\"button\"\n class=\"card-sound\"\n aria-label=${video.muted ? options.soundOnLabel : options.soundOffLabel}\n @click=${() => video.toggleMuted()}\n >\n ${icon(video.muted ? \"soundOff\" : \"soundOn\")}\n </button>\n `;\n}\n\n/**\n * A 9:16 card with the Story cover and, with a media_url, the video looping\n * muted over it (see renderMedia). A button with a play icon in the middle\n * covers the card, and a sound button shows while the video plays. The sound\n * button is beside the card's button, not inside it: a button can't contain\n * another.\n */\nexport function renderCard(\n story: StoryMedia,\n video: VideoController,\n options: CardOptions,\n) {\n return html`\n <div class=\"card\">\n ${renderMedia(story, video)}\n <button\n type=\"button\"\n class=\"card-open\"\n aria-label=${options.label}\n @click=${options.onSelect}\n >\n <span class=\"play\" aria-hidden=\"true\">${icon(\"play\")}</span>\n </button>\n ${hasVideo(story, video) && !video.paused\n ? renderSoundButton(video, options)\n : nothing}\n </div>\n `;\n}\n","/*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */\n\nimport type { DirectiveResult } from \"lit/directive.js\";\nimport {\n unsafeHTML,\n type UnsafeHTMLDirective,\n} from \"lit/directives/unsafe-html.js\";\n\n// SVG files as downloaded from Phosphor: regular weight, or the weight in the\n// file name. They are bundled as text: `?raw` is handled by Vite in dev and\n// tests, and by the raw plugin in tsup.config.ts.\nimport close from \"./assets/close.svg?raw\";\nimport collapse from \"./assets/collapse.svg?raw\";\nimport expand from \"./assets/expand.svg?raw\";\nimport pause from \"./assets/pause-fill.svg?raw\";\nimport play from \"./assets/play-fill.svg?raw\";\nimport soundOff from \"./assets/speaker-x-fill.svg?raw\";\nimport soundOn from \"./assets/speaker-high-fill.svg?raw\";\n\nexport const icons = {\n close,\n collapse,\n expand,\n pause,\n play,\n soundOff,\n soundOn,\n};\n\nexport type IconName = keyof typeof icons;\n\n// Each file as markup, marked decorative once so every render reuses it.\nconst markup = Object.fromEntries(\n Object.entries(icons).map(([name, svg]) => [\n name,\n svg.replace(\n \"<svg\",\n '<svg class=\"icon\" aria-hidden=\"true\" focusable=\"false\"',\n ),\n ]),\n) as Record<IconName, string>;\n\n/**\n * Renders a bundled icon in a Lit template. It is decorative: name the\n * control around it. The markup only ever comes from the bundled files.\n */\nexport function icon(\n name: IconName,\n): DirectiveResult<typeof UnsafeHTMLDirective> {\n return unsafeHTML(markup[name]);\n}\n","<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","<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","<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","<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","<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","<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","<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","import { html, nothing } from \"lit\";\nimport { ref } from \"lit/directives/ref.js\";\nimport type { StoryMedia } from \"../../types\";\nimport type { VideoController } from \"./video-controller\";\n\n// Only absolute http(s) URLs reach the DOM. Relative and protocol-relative\n// ones (\"/a.jpg\", \"//host/a.jpg\") don't parse without a base, so they're out.\nexport function httpUrl(value: string | undefined) {\n if (!value) return null;\n try {\n const { protocol } = new URL(value);\n return protocol === \"https:\" || protocol === \"http:\" ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction prefersReducedMotion() {\n return (\n globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ?? false\n );\n}\n\n/** Whether renderMedia shows a video for this Story right now. */\nexport function hasVideo(story: StoryMedia, video: VideoController) {\n return !video.failed && httpUrl(story.media_url) !== null;\n}\n\n/**\n * The Story cover and, with a media_url, the video looping muted over it. If\n * the video can't load, it is removed and the cover underneath stays.\n */\nexport function renderMedia(story: StoryMedia, video: VideoController) {\n const posterUrl = httpUrl(story.poster_url);\n const mediaUrl = httpUrl(story.media_url);\n\n // Muted and inline is what browsers, iOS included, allow to autoplay. The\n // muted attribute and property are both set, since browsers differ on\n // which one they read for autoplay. No autoplay for people who asked for\n // reduced motion.\n return html`\n ${posterUrl\n ? html`<img class=\"poster\" alt=\"\" src=${posterUrl} />`\n : nothing}\n ${mediaUrl && !video.failed\n ? html`\n <video\n class=\"video\"\n muted\n playsinline\n loop\n preload=\"metadata\"\n .muted=${true}\n ?autoplay=${!prefersReducedMotion()}\n poster=${posterUrl ?? nothing}\n src=${mediaUrl}\n ${ref(video.ref)}\n @play=${video.sync}\n @pause=${video.sync}\n @volumechange=${video.sync}\n @error=${video.fail}\n ></video>\n `\n : nothing}\n `;\n}\n","import type { ReactiveControllerHost } from \"lit\";\nimport { createRef } from \"lit/directives/ref.js\";\n\n/**\n * Plays a video. A blocked play is ignored: the cover or the paused state\n * stays.\n */\nexport function playVideo(video: HTMLVideoElement) {\n video.play()?.catch(() => undefined);\n}\n\n/**\n * Follows one rendered <video> (see renderMedia) and re-renders its host when\n * it plays, pauses, is muted or unmuted, or fails to load. The state comes\n * from the video's own events, so a blocked autoplay shows as paused. It needs\n * no lifecycle hooks: the browser pauses a video removed from the page.\n */\nexport class VideoController {\n /** Bound to the <video> by renderMedia. */\n readonly ref = createRef<HTMLVideoElement>();\n\n paused = true;\n // The video always starts muted: that is what browsers allow to autoplay.\n muted = true;\n /** The video could not load: only the cover is shown. */\n failed = false;\n\n constructor(private readonly host: ReactiveControllerHost) {}\n\n /** For a new <video>, such as each time the player opens. */\n reset() {\n this.paused = true;\n this.muted = true;\n this.failed = false;\n }\n\n play() {\n const video = this.ref.value;\n if (video) playVideo(video);\n }\n\n pause() {\n this.ref.value?.pause();\n }\n\n /** Plays again if the video plays on its own (see renderMedia). */\n resume() {\n const video = this.ref.value;\n if (video?.autoplay) playVideo(video);\n }\n\n togglePlayback() {\n const video = this.ref.value;\n if (!video) return;\n if (video.paused) playVideo(video);\n else video.pause();\n }\n\n toggleMuted() {\n const video = this.ref.value;\n if (video) video.muted = !video.muted;\n }\n\n /** Listener for the video's play, pause and volumechange events. */\n readonly sync = () => {\n const video = this.ref.value;\n if (!video) return;\n this.paused = video.paused;\n this.muted = video.muted;\n this.host.requestUpdate();\n };\n\n /** Listener for the video's error event. */\n readonly fail = () => {\n this.failed = true;\n this.host.requestUpdate();\n };\n}\n","import { css, html, nothing } from \"lit\";\nimport type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport { createRef, ref } from \"lit/directives/ref.js\";\nimport { icon } from \"../icons\";\nimport { hasVideo, renderMedia, VideoController } from \"../media\";\nimport type { StoryMedia } from \"../../types\";\n\n// The player is a <dialog> shown in the top layer, so no store z-index,\n// overflow or transform can hide or move it.\n//\n// Mini: a manual popover (non-modal, the page stays usable), with the card at\n// the bottom right and the controls above it. Without popover support it is a\n// non-modal dialog, fixed with a high z-index.\n// Expanded: a modal dialog (showModal), so the browser makes the page behind\n// it inert. The card is centered over a dark backdrop, with the controls at\n// the top right of the screen. On narrow screens it fills the screen.\nexport const playerStyles = css`\n .player {\n position: fixed;\n inset: auto 16px 16px auto;\n z-index: 2147483000;\n box-sizing: border-box;\n width: calc(min(587px, 100vh - 80px) * 9 / 16);\n height: min(587px, 100vh - 80px);\n margin: 0;\n padding: 0;\n overflow: visible;\n border: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n animation: player-in 0.25s ease;\n }\n\n /* A <dialog> shown as a popover has no open attribute, which the browser\n hides by default. */\n .player:popover-open {\n display: block;\n }\n\n /* Switching modes shows the dialog again; only the first opening fades in. */\n .player[data-switched] {\n animation: none;\n }\n\n .player::backdrop {\n background: transparent;\n }\n\n .player-frame {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .player .card {\n width: 100%;\n height: 100%;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);\n }\n\n .player .card:has(.video) {\n cursor: pointer;\n }\n\n /* Play/pause reuses the card's glass .play button, as a real button. */\n .player-toggle {\n padding: 0;\n border: 0;\n color: #fff;\n font: inherit;\n cursor: pointer;\n }\n\n .player[data-paused] .player-toggle,\n .player-toggle:focus-visible {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n\n /* On touch, tapping the video pauses it; the button shows while paused. */\n @media (hover: none) {\n .player:not([data-paused]) .player-toggle {\n opacity: 0;\n }\n }\n\n .player-sound {\n position: absolute;\n top: 12px;\n right: 12px;\n z-index: 1;\n border-color: transparent;\n background: rgba(0, 0, 0, 0.3);\n }\n\n .player-sound .icon {\n width: 20px;\n height: 20px;\n }\n\n /* Above the card: on narrow screens the expanded card can cover them. */\n .player-controls {\n position: absolute;\n right: 0;\n bottom: calc(100% + 8px);\n z-index: 1;\n display: flex;\n gap: 8px;\n }\n\n .player-button {\n display: grid;\n width: 36px;\n height: 36px;\n place-items: center;\n padding: 0;\n border: 1px solid rgba(133, 133, 133, 0.3);\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.32);\n backdrop-filter: blur(5px);\n color: #fff;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n .player-button:hover {\n background: rgba(0, 0, 0, 0.55);\n }\n\n .player-button .icon {\n width: 18px;\n height: 18px;\n }\n\n .player[data-expanded] {\n inset: 0;\n display: grid;\n width: 100%;\n max-width: none;\n height: 100%;\n max-height: none;\n place-items: center;\n background: rgba(0, 0, 0, 0.85);\n animation: none;\n }\n\n .player[data-expanded] .player-frame {\n width: calc(min(78vh, 720px) * 9 / 16);\n height: min(78vh, 720px);\n }\n\n .player[data-expanded] .player-controls {\n position: fixed;\n top: 24px;\n right: 24px;\n bottom: auto;\n }\n\n .player[data-expanded] .player-button {\n width: 40px;\n height: 40px;\n }\n\n @media (max-width: 576px) {\n .player {\n right: 12px;\n width: 220px;\n height: 391px;\n }\n\n .player[data-expanded] {\n background: #000;\n }\n\n /* The video stays 9:16 and centered; the rest of the screen is black. */\n .player[data-expanded] .player-frame {\n width: min(100vw, 100vh * 9 / 16);\n height: min(100vh, 100vw * 16 / 9);\n }\n\n .player[data-expanded] .card {\n border-radius: 0;\n }\n\n /* Below the sound button, at the top right of the video. Placed in the\n video frame, not the screen: the frame is centered, so on screens\n taller than 9:16 its top is below the screen's. */\n .player[data-expanded] .player-controls {\n position: absolute;\n top: 60px;\n right: 12px;\n }\n }\n\n @keyframes player-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .player {\n animation: none;\n }\n }\n`;\n\nexport interface PlayerOptions {\n /** Accessible name of the player. */\n label: string;\n /** Accessible names of the buttons. */\n expandLabel: string;\n collapseLabel: string;\n closeLabel: string;\n playLabel: string;\n pauseLabel: string;\n soundOnLabel: string;\n soundOffLabel: string;\n /**\n * Called by the close button, Escape and a click on the expanded view's\n * backdrop. Call close() from it.\n */\n onClose: () => void;\n}\n\nfunction supportsPopover(dialog: HTMLDialogElement) {\n return typeof dialog.showPopover === \"function\";\n}\n\n/**\n * The Story player, rendered by its host with render(). open() shows it as\n * the mini player; expand switches to the expanded view, a modal dialog, and\n * back. The video starts muted and plays when the player opens. It closes on\n * its own when the host leaves the page.\n */\nexport class PlayerController implements ReactiveController {\n readonly video: VideoController;\n\n /** Rendered and, once the host has updated, shown. */\n isOpen = false;\n private expanded = false;\n /** Switched modes at least once: only the first opening fades in. */\n private switched = false;\n /** The dialog is showing, in the mode `expanded` says. */\n private shown = false;\n\n private readonly dialog = createRef<HTMLDialogElement>();\n private readonly expandButton = createRef<HTMLButtonElement>();\n private readonly closeButton = createRef<HTMLButtonElement>();\n\n constructor(\n private readonly host: ReactiveControllerHost,\n private readonly options: PlayerOptions,\n ) {\n host.addController(this);\n this.video = new VideoController(host);\n }\n\n hostDisconnected() {\n this.close();\n }\n\n /** Opens the mini player, plays the video and focuses the close button. */\n async open() {\n if (this.isOpen) return;\n\n document.addEventListener(\"keydown\", this.onKeyDown);\n this.isOpen = true;\n this.expanded = false;\n this.switched = false;\n this.video.reset();\n this.host.requestUpdate();\n await this.host.updateComplete;\n\n const dialog = this.dialog.value;\n // Closed again before the host rendered it.\n if (!this.isOpen || !dialog) return;\n\n this.show(dialog);\n this.video.play();\n this.closeButton.value?.focus();\n }\n\n /** Hides the player now; the host removes it on its next update. */\n close() {\n if (!this.isOpen) return;\n\n document.removeEventListener(\"keydown\", this.onKeyDown);\n const dialog = this.dialog.value;\n if (dialog) this.hide(dialog);\n this.isOpen = false;\n this.host.requestUpdate();\n }\n\n // Mini: a manual popover, or a non-modal dialog without popover support.\n // Expanded: a modal dialog.\n // Already showing: a second expand click in the same task resumes after the\n // first one has shown the dialog, and showing it again would throw.\n private show(dialog: HTMLDialogElement) {\n if (this.shown) return;\n if (this.expanded) dialog.showModal();\n else if (supportsPopover(dialog)) dialog.showPopover();\n else dialog.show();\n this.shown = true;\n }\n\n // A dialog can't be shown as a popover and as a modal at the same time, so\n // switching modes hides it first, the same way it was shown.\n private hide(dialog: HTMLDialogElement) {\n if (!this.shown) return;\n if (!this.expanded && supportsPopover(dialog)) dialog.hidePopover();\n else dialog.close();\n this.shown = false;\n }\n\n private readonly toggleExpanded = async () => {\n const dialog = this.dialog.value;\n if (!dialog) return;\n\n this.hide(dialog);\n this.expanded = !this.expanded;\n this.switched = true;\n this.host.requestUpdate();\n await this.host.updateComplete;\n\n if (!this.isOpen) return;\n this.show(dialog);\n this.expandButton.value?.focus();\n };\n\n // Escape anywhere on the page, also in the mini player, which is not modal.\n private readonly onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") this.options.onClose();\n };\n\n // Clicks on the backdrop of the expanded view reach the dialog itself.\n private readonly onDialogClick = (event: Event) => {\n if (this.expanded && event.target === event.currentTarget) {\n this.options.onClose();\n }\n };\n\n // Escape on a modal dialog would only hide it: close the player instead.\n private readonly onCancel = (event: Event) => {\n event.preventDefault();\n this.options.onClose();\n };\n\n /**\n * Play/pause in the middle of the video and sound on/off at its top right.\n * They follow the video's own events, so a blocked autoplay shows as\n * paused.\n */\n private renderVideoControls() {\n const { video, options } = this;\n\n // Not a .player-button: it keeps the card's larger glass look.\n const onToggle = (event: Event) => {\n event.stopPropagation();\n video.togglePlayback();\n };\n const onSound = (event: Event) => {\n event.stopPropagation();\n video.toggleMuted();\n };\n\n return html`\n <button\n type=\"button\"\n class=\"play player-toggle\"\n aria-label=${video.paused ? options.playLabel : options.pauseLabel}\n @click=${onToggle}\n >\n ${icon(video.paused ? \"play\" : \"pause\")}\n </button>\n <button\n type=\"button\"\n class=\"player-button player-sound\"\n aria-label=${video.muted ? options.soundOnLabel : options.soundOffLabel}\n @click=${onSound}\n >\n ${icon(video.muted ? \"soundOff\" : \"soundOn\")}\n </button>\n `;\n }\n\n /**\n * The player <dialog> while it is open. Clicking the video also plays or\n * pauses it.\n */\n render(story: StoryMedia) {\n if (!this.isOpen) return nothing;\n\n const { video, options, expanded } = this;\n const withVideo = hasVideo(story, video);\n\n return html`\n <dialog\n class=\"player\"\n popover=\"manual\"\n aria-label=${options.label}\n ?data-expanded=${expanded}\n ?data-switched=${this.switched}\n ?data-paused=${withVideo && video.paused}\n ${ref(this.dialog)}\n @click=${this.onDialogClick}\n @cancel=${this.onCancel}\n >\n <div class=\"player-frame\">\n <div class=\"player-controls\">\n <button\n type=\"button\"\n class=\"player-button player-expand\"\n aria-label=${expanded\n ? options.collapseLabel\n : options.expandLabel}\n ${ref(this.expandButton)}\n @click=${this.toggleExpanded}\n >\n ${icon(expanded ? \"collapse\" : \"expand\")}\n </button>\n <button\n type=\"button\"\n class=\"player-button player-close\"\n aria-label=${options.closeLabel}\n ${ref(this.closeButton)}\n @click=${options.onClose}\n >\n ${icon(\"close\")}\n </button>\n </div>\n <div class=\"card\" @click=${() => video.togglePlayback()}>\n ${renderMedia(story, video)}\n ${withVide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,EAEU,SAAS;AACjB,WAAOE;AAAA;AAAA,UAED,WAAW,mBAAmB,KAAK,WAAW;AAAA,MAC9C,OAAO,OAAO;AAAA,MACd,cAAc,OAAO;AAAA,MACrB,eAAe,OAAO;AAAA,MACtB,UAAU,MAAM,KAAK,WAAW;AAAA,IAClC,CAAC,CAAC;AAAA;AAAA,QAEF,KAAK,OAAO,OAAO,iBAAiB,CAAC;AAAA;AAAA,EAE3C;AACF;AAtEa,oBACK,SAAS;AAAA,EACvBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA;AAAA,EACA;AACF;AAqEK,SAAS,uBAAuB;AACrC,MAAI,OAAO,mBAAmB,YAAa;AAC3C,MAAI,eAAe,IAAI,QAAQ,EAAG;AAElC,iBAAe,OAAO,UAAU,mBAAmB;AACrD;","names":["css","html","html","nothing","html","nothing","css","html","nothing","createRef","ref","css","createRef","html","nothing","ref","html","css"]}
|
|
1
|
+
{"version":3,"sources":["../../src/story/story.ts","../../src/components/card/card.ts","../../src/components/icons/index.ts","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-left-bold.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-right-bold.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-up-bold.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg","../../src/components/media/media.ts","../../src/utils/http-url.ts","../../src/components/media/video-controller.ts","../../src/components/product/product.ts","../../src/components/product/price.ts","../../src/components/product/cta.ts","../../src/components/product/product.styles.ts","../../src/components/carousel/carousel.ts","../../src/tag-name.ts","../../src/utils/send-event.ts","../../src/components/events/events-controller.ts","../../src/components/player/player.ts","../../src/utils/hydrate-products.ts","../../src/utils/with-timeout.ts","../../src/utils/fetch-story.ts","../../src/locales/en.ts","../../src/locales/es.ts","../../src/locales/pt.ts","../../src/locales/index.ts"],"sourcesContent":["import { css, html, LitElement, nothing, type PropertyValues } from \"lit\";\nimport type { Channel } from \"@vtex/ads-core\";\nimport { cardStyles, renderCard } from \"../components/card\";\nimport {\n CarouselController,\n carouselStyles,\n RENDERED_SIDE,\n type Slide,\n} from \"../components/carousel\";\nimport { StoryEventsController, type ViewTarget } from \"../components/events\";\nimport { VideoController } from \"../components/media\";\nimport {\n DEFAULT_LOCALE,\n priceFormatter,\n productStyles,\n toCardCta,\n toCardProduct,\n type FetchedProduct,\n} from \"../components/product\";\nimport {\n neighborOffsets,\n PlayerController,\n playerStyles,\n} from \"../components/player\";\nimport type { StoryAd } from \"../types\";\nimport {\n hydrateStoryProducts,\n intelligentSearchHydration,\n type StoryHydration,\n type StoryProductDetails,\n} from \"../utils/hydrate-products\";\nimport { fetchStories } from \"../utils/fetch-story\";\nimport { labelsFor, type StoryLabels } from \"../locales\";\nimport { TAG_NAME } from \"../tag-name\";\n\nexport { TAG_NAME } from \"../tag-name\";\n\n// The properties that make up the ad and product requests: a change to any of\n// them fetches the Story again.\nconst REQUEST_PROPERTIES = [\n \"publisherId\",\n \"sessionId\",\n \"placement\",\n \"userId\",\n \"accountName\",\n \"channel\",\n \"quantity\",\n \"hydration\",\n] as const;\n\nconst CHANNELS: ReadonlySet<Channel> = new Set([\"site\", \"app\"]);\n\nconst isChannel = (value: string | null): value is Channel =>\n CHANNELS.has(value as Channel);\n\n// Reads a boolean attribute: on only when present bare (`\"\"`, as in HTML and\n// React 19) or \"true\"; absent, \"false\" or any other value is off. React 18\n// writes boolean props on custom elements as strings, so\n// `inactive-autoplay={false}` arrives as inactive-autoplay=\"false\".\nconst booleanConverter = {\n fromAttribute: (value: string | null) =>\n typeof value === \"string\" &&\n (value === \"\" || value.toLowerCase() === \"true\"),\n};\n\n// Reads the `channel` attribute. An unknown value leaves the property\n// undefined, so it is not sent.\nconst channelConverter = {\n fromAttribute: (value: string | null) =>\n isChannel(value) ? value : undefined,\n};\n\n// Reads the `hydration` attribute: only \"none\" means something there (no\n// product request). A strategy is set as a property.\nconst hydrationConverter = {\n fromAttribute: (value: string | null) =>\n value === \"none\" ? (\"none\" as const) : undefined,\n};\n\n// LitElement is importable where HTMLElement doesn't exist (SSR, Node): Lit\n// falls back to a minimal shim there.\nexport class VtexAdsStoryCarouselElement extends LitElement {\n static readonly properties = {\n publisherId: { attribute: \"publisher-id\" },\n sessionId: { attribute: \"session-id\" },\n placement: {},\n userId: { attribute: \"user-id\" },\n accountName: { attribute: \"account-name\" },\n channel: { converter: channelConverter },\n timeout: { type: Number },\n quantity: { type: Number },\n currency: {},\n labelAddToCart: { attribute: \"label-add-to-cart\" },\n labelViewProduct: { attribute: \"label-view-product\" },\n hydration: { converter: hydrationConverter },\n hydrationTimeout: { type: Number, attribute: \"hydration-timeout\" },\n inactiveAutoplay: {\n type: Boolean,\n attribute: \"inactive-autoplay\",\n converter: booleanConverter,\n },\n stories: { state: true },\n products: { state: true },\n };\n\n /** Required. The publisher the ads are requested for. */\n declare publisherId?: string;\n /** Required. The store's session, also used to deduplicate events. */\n declare sessionId?: string;\n /** Required. The Story placement configured for the publisher. */\n declare placement?: string;\n declare userId?: string;\n declare accountName?: string;\n /** `site` or `app`. Any other attribute value is ignored. */\n declare channel?: Channel;\n /**\n * Time limit for the ad request, in milliseconds (default 2000). Without a\n * Story by then, the element renders nothing. A change applies to the next\n * request; it doesn't request again.\n */\n declare timeout?: number;\n /**\n * How many Stories to ask for: the carousel positions (default 8). Missing,\n * below 1 or not a number: the default.\n */\n declare quantity?: number;\n /**\n * Currency of the prices, as an ISO 4217 code (\"BRL\", \"ARS\"). Missing or\n * invalid: BRL.\n */\n declare currency?: string;\n /**\n * The add to cart button's text. Missing or blank: the default in the\n * element's language (\"Adicionar ao carrinho\").\n */\n declare labelAddToCart?: string;\n /**\n * The view product button's text. Missing or blank: the default in the\n * element's language (\"Ver produto\").\n */\n declare labelViewProduct?: string;\n /**\n * Where the products' details (for now, their prices) come from. A\n * strategy (fetcher, matcher and price reader) is set as a property; the\n * attribute takes only \"none\", for no product request. Missing:\n * Intelligent Search when `account-name` is set, no product request\n * otherwise.\n */\n declare hydration?: StoryHydration | \"none\";\n /**\n * Time limit for the product request, in milliseconds (default 5000).\n * Without the prices by then, the cards show the ad server's.\n */\n declare hydrationTimeout?: number;\n /**\n * With more than one Story, whether the cards without the highlight also\n * play their video, muted. Off by default: they show only their cover, and\n * only the highlighted card plays.\n */\n declare inactiveAutoplay: boolean;\n\n /** The Stories shown: none while loading, on error or with none. */\n declare private stories: StoryAd[];\n\n /**\n * The fetched products, by Story `ad_id`, or `\"loading\"` while the product\n * request runs. Undefined without a product request.\n */\n declare private products?: Map<string, StoryProductDetails> | \"loading\";\n\n /**\n * Cancels the request in progress. Kept, already aborted, when leaving the\n * page cancelled it, so connecting again requests once more.\n */\n private request?: AbortController;\n\n static readonly styles = [\n css`\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n `,\n cardStyles,\n productStyles,\n carouselStyles,\n playerStyles,\n ];\n\n /**\n * One per rendered card, by its key (see Slide): a Story can show in more\n * than one card, each with its own video.\n */\n private readonly cardVideos = new Map<number, VideoController>();\n\n /** The sound was on when the highlight moved: the new card turns it on. */\n private soundPending = false;\n\n /**\n * What to do once the next render is on screen, when the new highlighted\n * card's video exists (see leaveHighlight and onLayoutChange). A step\n * taken before then replaces it.\n */\n private afterRender?: () => void;\n\n private readonly carousel = new CarouselController(this, {\n onStep: (from, to) => this.leaveHighlight(from, to),\n // Every card is new: so are their videos. Behind an open player, the\n // new highlighted card stays on its cover, as after a step.\n onLayoutChange: () => {\n this.cardVideos.clear();\n if (this.player.isOpen) {\n this.afterRender = () => this.activeVideo?.pause();\n }\n },\n // The player shows the highlighted Story: the highlight stays on it.\n locked: () => this.player.isOpen,\n });\n\n private readonly player = new PlayerController(this, {\n onStep: (delta) => this.stepInPlayer(delta),\n onClose: () => this.closePlayer(),\n });\n\n // Added after the carousel and the player: its hostUpdated reads what\n // they rendered.\n private readonly events = new StoryEventsController(this, {\n identity: () => ({ sessionId: this.sessionId, userId: this.userId }),\n viewTargets: () => this.viewTargets(),\n });\n\n constructor() {\n super();\n this.inactiveAutoplay = false;\n this.stories = [];\n }\n\n // Lit keeps the card's DOM when the element is moved (removed and appended\n // again), but the browser pauses a removed video and doesn't autoplay it\n // again. resume() only plays a video that autoplays (not with reduced\n // motion), and does nothing on the first connection, before the render.\n // Not in VideoController.hostConnected: there, the player's video is still\n // in the DOM until the next update and would play for a moment.\n connectedCallback() {\n super.connectedCallback();\n for (const video of this.cardVideos.values()) video.resume();\n\n // Moved while its request was pending: that request was cancelled.\n if (this.request?.signal.aborted) void this.loadStory();\n }\n\n // A request still pending when the element leaves the page is cancelled.\n disconnectedCallback() {\n super.disconnectedCallback();\n this.request?.abort();\n }\n\n protected willUpdate(changed: PropertyValues<this>) {\n if (REQUEST_PROPERTIES.some((name) => changed.has(name))) {\n void this.loadStory();\n }\n }\n\n protected updated() {\n const afterRender = this.afterRender;\n this.afterRender = undefined;\n afterRender?.();\n }\n\n // The strategy for the products' details, if any (see `hydration`).\n private get activeHydration(): StoryHydration | undefined {\n if (this.hydration === \"none\") return undefined;\n if (this.hydration) return this.hydration;\n return this.accountName ? intelligentSearchHydration : undefined;\n }\n\n /**\n * Requests the Story and shows it, then hydrates its products. Until the\n * Story arrives, and when there is none (see fetchStories), the element\n * renders nothing.\n */\n private async loadStory() {\n // A request still pending no longer matches the attributes.\n this.request?.abort();\n const request = new AbortController();\n this.request = request;\n\n // The Stories shown no longer match the request either.\n this.player.close();\n this.showStories([]);\n\n // Off the page (an attribute changed just before the element was\n // removed): keep the cancelled request, so connecting again requests.\n if (!this.isConnected) {\n request.abort();\n return;\n }\n\n const stories = await fetchStories(this, {\n signal: request.signal,\n timeout: this.timeout,\n });\n\n // Cancelled meanwhile, by a newer request or by leaving the page: this\n // response is not shown.\n if (request.signal.aborted) return;\n\n const hydration = this.activeHydration;\n if (!hydration || !stories.some((story) => story.product)) {\n this.request = undefined;\n this.showStories(stories);\n return;\n }\n\n // The carousel shows now; the products' details replace their\n // placeholders later.\n this.showStories(stories, \"loading\");\n const products = await hydrateStoryProducts(\n this.placement ?? \"\",\n stories,\n hydration,\n {\n accountName: this.accountName ?? \"\",\n publisherId: this.publisherId ?? \"\",\n sessionId: this.sessionId ?? \"\",\n userId: this.userId,\n channel: this.channel,\n },\n { signal: request.signal, timeout: this.hydrationTimeout },\n );\n\n if (request.signal.aborted) return;\n this.request = undefined;\n this.products = products;\n }\n\n // Each card's video starts fresh: a failed load of an old one doesn't hide\n // it.\n private showStories(stories: StoryAd[], products?: \"loading\") {\n this.products = products;\n this.cardVideos.clear();\n this.soundPending = false;\n this.afterRender = undefined;\n this.carousel.reset(stories.length);\n this.stories = stories;\n this.events.impress(stories);\n }\n\n /**\n * Where each Story is being watched: the cards on screen (not the hidden\n * ones kept for the slide in) and the open player's video, while their\n * video plays. A card showing only its cover doesn't count. Behind the\n * expanded player, a modal over the page, the cards are covered.\n */\n private *viewTargets(): Generator<ViewTarget> {\n const { stories } = this;\n\n if (!this.player.isExpanded) {\n for (const [card, { key, index }] of this.carousel.visibleCards()) {\n const story = stories[index];\n if (story && this.cardVideos.get(key)?.playing) yield [card, story];\n }\n }\n\n const stageCard = this.player.stageCard;\n const active = stories[this.carousel.active];\n if (stageCard && active && this.player.video.playing) {\n yield [stageCard, active];\n }\n }\n\n private videoFor(key: number) {\n let video = this.cardVideos.get(key);\n if (!video) {\n video = new VideoController(this);\n this.cardVideos.set(key, video);\n }\n return video;\n }\n\n private get activeVideo(): VideoController | undefined {\n return this.cardVideos.get(this.carousel.activeKey);\n }\n\n // The card losing the highlight goes quiet: muted if it keeps playing, or\n // back to its cover. Its next video then starts fresh. If its sound was\n // on, the sound moves to the new highlighted card, once its video renders.\n // With the player open (it stepped), the new card stays on its cover\n // behind it instead. Cards no longer rendered (the rolling layout drops\n // them as it moves) leave with their videos.\n private leaveHighlight(from: number, to: number) {\n const video = this.cardVideos.get(from);\n // Still pending: moved again before the last step rendered.\n this.soundPending ||= video !== undefined && !video.muted;\n if (this.inactiveAutoplay) video?.mute();\n else video?.reset();\n\n // The step requested its render before calling this: updated() runs the\n // action once the new card is on screen.\n if (this.player.isOpen) {\n this.soundPending = false;\n // Paused before it starts, its autoplay doesn't start either.\n this.afterRender = () => this.videoFor(to).pause();\n } else if (this.soundPending) {\n this.afterRender = () => {\n this.soundPending = false;\n this.videoFor(to).playWithSound();\n };\n }\n\n for (const key of this.cardVideos.keys()) {\n if (Math.abs(key - to) > RENDERED_SIDE) this.cardVideos.delete(key);\n }\n }\n\n // The player's previous and next buttons: the highlight moves with the\n // Story the player shows.\n private stepInPlayer(delta: number) {\n this.carousel.step(delta, { evenIfLocked: true });\n void this.player.showNext(delta);\n }\n\n // From the card's product, the player opens with the product panel open.\n private openPlayer({ productOpen = false } = {}) {\n if (this.player.isOpen) return;\n\n // While the player is open, the card behind it stops on its cover.\n this.activeVideo?.pause();\n void this.player.open({ productOpen });\n }\n\n // The player also closes on its own when the element leaves the page,\n // without this: there is no card to give focus back to or to resume playing\n // (it would play out of sight).\n private closePlayer() {\n if (!this.player.isOpen) return;\n\n this.player.close();\n // The highlighted card, and with inactive-autoplay the others, which may\n // have been highlighted and paused while the player stepped.\n for (const video of this.cardVideos.values()) video.resume();\n this.carousel.focusActive();\n }\n\n // The formatter for the current language and currency, made again only\n // when either changes.\n private formatter?: {\n key: string;\n format: (amount: number) => string;\n };\n\n // Prices and texts follow the language of the closest element with a\n // `lang`, the element itself included, so a store can set one for the\n // widget alone. An empty `lang` (unknown) is skipped; none, or an unknown\n // one, falls back to pt-BR.\n private get locale() {\n return (\n this.closest<HTMLElement>('[lang]:not([lang=\"\"])')?.lang ?? DEFAULT_LOCALE\n );\n }\n\n // The texts for the current language and label attributes, made again\n // only when any of them changes.\n private labelSet?: { key: string; labels: StoryLabels };\n\n private get labels() {\n const { locale, labelAddToCart = \"\", labelViewProduct = \"\" } = this;\n const key = JSON.stringify([locale, labelAddToCart, labelViewProduct]);\n if (this.labelSet?.key !== key) {\n this.labelSet = {\n key,\n labels: labelsFor(locale, {\n addToCart: labelAddToCart,\n viewProduct: labelViewProduct,\n }),\n };\n }\n return this.labelSet.labels;\n }\n\n private get formatPrice() {\n const { locale } = this;\n const key = `${locale}|${this.currency ?? \"\"}`;\n if (this.formatter?.key !== key) {\n this.formatter = { key, format: priceFormatter(locale, this.currency) };\n }\n return this.formatter.format;\n }\n\n private productOf(story: StoryAd) {\n const fetched: FetchedProduct =\n this.products === \"loading\" ? \"loading\" : this.products?.get(story.ad_id);\n return toCardProduct(story, this.formatPrice, this.labels, fetched);\n }\n\n // The highlighted card opens the player; another one takes the highlight.\n // Hidden cards, out of sight, show only their cover.\n private readonly renderSlide = (\n story: StoryAd,\n { key, index, offset, active, hidden, cardRef, focusRef }: Slide,\n ) =>\n renderCard(story, this.videoFor(key), {\n label: this.labels.position(\n active ? this.labels.watch : this.labels.show,\n index,\n this.stories.length,\n ),\n labels: this.labels,\n withVideo: active || (this.inactiveAutoplay && !hidden),\n product: this.productOf(story),\n onSelect: active\n ? () => this.openPlayer()\n : () => this.carousel.step(offset),\n // On a card without the highlight, the product moves it, as the card.\n onProductSelect: active\n ? () => this.openPlayer({ productOpen: true })\n : undefined,\n // On the highlighted card it follows the link; on another, it moves the\n // highlight.\n cta: toCardCta(story),\n onCtaSelect: active ? undefined : () => this.carousel.step(offset),\n onPress: () => this.events.click(story),\n ref: cardRef,\n openRef: focusRef,\n });\n\n protected render() {\n const { stories } = this;\n const index = this.carousel.active;\n const active = stories[index];\n if (!active) return nothing;\n\n const neighbors = neighborOffsets(stories.length, index).map((offset) => {\n const neighbor = (index + offset + stories.length) % stories.length;\n return {\n offset,\n story: stories[neighbor],\n label: this.labels.position(this.labels.show, neighbor, stories.length),\n };\n });\n\n return html`\n <div class=\"root\">\n ${this.carousel.render(stories, this.renderSlide, this.labels)}\n </div>\n ${this.player.render(active, {\n labels: this.labels,\n navigation: stories.length > 1,\n neighbors,\n product: this.productOf(active),\n cta: toCardCta(active),\n onPress: () => this.events.click(active),\n })}\n `;\n }\n}\n\n// Types `document.createElement(\"vtex-ads-story-carousel\")` and\n// `querySelector` results as VtexAdsStoryCarouselElement in any TypeScript\n// project, no framework needed.\ndeclare global {\n interface HTMLElementTagNameMap {\n [TAG_NAME]: VtexAdsStoryCarouselElement;\n }\n}\n\nexport function defineVtexAdsStoryCarousel() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryCarouselElement);\n}\n","import { css, html, nothing } from \"lit\";\nimport { ref, type RefOrCallback } from \"lit/directives/ref.js\";\nimport type { StoryLabels } from \"../../locales\";\nimport { icon } from \"../icons\";\nimport { hasVideo, renderMedia, type VideoController } from \"../media\";\nimport {\n renderCta,\n renderProduct,\n type CardCta,\n type CardProduct,\n} from \"../product\";\nimport type { StoryMedia } from \"../../types\";\n\nexport const cardStyles = css`\n /* 9:16 at the height its container gives it (--card-height, default\n 500px). */\n .card {\n position: relative;\n box-sizing: border-box;\n width: calc(var(--card-height, 500px) * 9 / 16);\n height: var(--card-height, 500px);\n overflow: hidden;\n border-radius: var(--vtex-ads-story-radius, 20px);\n background: #000;\n }\n\n /* The card's button covers it. The focus ring goes on the card, since the\n card's overflow would clip the button's own. */\n .card-open {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n }\n\n .card-open:focus-visible {\n outline: none;\n }\n\n .card:has(> .card-open:focus-visible) {\n outline: auto;\n }\n\n .poster,\n .video {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .play {\n position: absolute;\n top: 50%;\n left: 50%;\n display: grid;\n width: 66px;\n height: 66px;\n place-items: center;\n border-radius: 50%;\n background:\n linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06)),\n rgba(255, 255, 255, 0.15);\n backdrop-filter: blur(2px);\n box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);\n transform: translate(-50%, -50%);\n transition:\n opacity 0.3s ease,\n transform 0.3s ease;\n }\n\n /* The icon's triangle is 18px tall and already sits slightly right of its\n box, so it looks centered in the circle. */\n .play .icon {\n width: 22px;\n height: 22px;\n color: #fff;\n }\n\n /* Sound on/off, at the top right of the card (as in the prototype). */\n .card-sound {\n position: absolute;\n top: 22px;\n right: 12px;\n z-index: 1;\n display: grid;\n width: 28px;\n height: 28px;\n place-items: center;\n padding: 0;\n border: 0;\n background: transparent;\n color: #fff;\n cursor: pointer;\n filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));\n }\n\n .card-sound .icon {\n width: 20px;\n height: 20px;\n }\n\n /* With a mouse, the play button shows only on hover or keyboard focus.\n Touch screens have no hover, so it stays visible there. */\n @media (hover: hover) and (pointer: fine) {\n .play {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.9);\n }\n\n .card:hover .play,\n .card-open:focus-visible .play {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n }\n`;\n\nexport interface CardOptions {\n /** Accessible name of the card. */\n label: string;\n /** Called on click, Enter or Space. */\n onSelect: () => void;\n /**\n * Whether the video plays over the cover (default true). Without it, the\n * card shows only the cover, with no sound button.\n */\n withVideo?: boolean;\n /** The texts (the sound button's, shown when the card has a video). */\n labels: StoryLabels;\n /** The Story's product, shown at the bottom of the card. */\n product?: CardProduct;\n /** Called by a click on the product (default onSelect). */\n onProductSelect?: () => void;\n /** The Story's call to action, for a link destination (no product). */\n cta?: CardCta;\n /**\n * Called by a click on the call to action instead of following the link\n * (a card without the highlight). Without it, the link opens.\n */\n onCtaSelect?: () => void;\n /**\n * Called by any click on the card, its product, call to action and sound\n * button included, before what that click does.\n */\n onPress?: () => void;\n /** Receives the card's element (see Slide's cardRef). */\n ref?: RefOrCallback;\n /** Receives the button that takes the focus (see Slide's focusRef). */\n openRef?: RefOrCallback;\n}\n\n/**\n * Sound on/off for the card's video, which starts muted. Only shown while the\n * video plays: a video that never plays (reduced motion, or autoplay blocked\n * as in iOS Low Power Mode) has no sound to turn on, and the card paused\n * behind the open player needs none.\n */\nfunction renderSoundButton(video: VideoController, options: CardOptions) {\n return html`\n <button\n type=\"button\"\n class=\"card-sound\"\n aria-label=${video.muted\n ? options.labels.soundOn\n : options.labels.soundOff}\n @click=${() => video.toggleMuted()}\n >\n ${icon(video.muted ? \"soundOff\" : \"soundOn\")}\n </button>\n `;\n}\n\n/**\n * A 9:16 card with the Story cover and, with a media_url, the video looping\n * muted over it (see renderMedia). A button with a play icon in the middle\n * covers the card, and a sound button shows while the video plays. With a\n * product, its pill sits at the bottom (see renderProduct); with a link\n * destination, the call to action does (see renderCta). The sound, product\n * and call to action are beside the card's button, not inside it: a button\n * can't contain another.\n */\nexport function renderCard(\n story: StoryMedia,\n video: VideoController,\n options: CardOptions,\n) {\n const withVideo = options.withVideo ?? true;\n\n return html`\n <div\n class=\"card\"\n ${ref(options.ref)}\n @click=${{ handleEvent: () => options.onPress?.(), capture: true }}\n >\n ${renderMedia(story, video, { withVideo })}\n <button\n type=\"button\"\n class=\"card-open\"\n ${ref(options.openRef)}\n aria-label=${options.label}\n @click=${options.onSelect}\n >\n <span class=\"play\" aria-hidden=\"true\">${icon(\"play\")}</span>\n </button>\n ${withVideo && hasVideo(story, video) && !video.paused\n ? renderSoundButton(video, options)\n : nothing}\n ${options.product\n ? renderProduct(\n options.product,\n options.onProductSelect ?? options.onSelect,\n )\n : nothing}\n ${options.cta ? renderCta(options.cta, options.onCtaSelect) : nothing}\n </div>\n `;\n}\n","/*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */\n\nimport type { DirectiveResult } from \"lit/directive.js\";\nimport {\n unsafeHTML,\n type UnsafeHTMLDirective,\n} from \"lit/directives/unsafe-html.js\";\n\n// SVG files as downloaded from Phosphor: regular weight, or the weight in the\n// file name. They are bundled as text: `?raw` is handled by Vite in dev and\n// tests, and by the raw plugin in tsup.config.ts.\nimport previous from \"./assets/caret-left-bold.svg?raw\";\nimport next from \"./assets/caret-right-bold.svg?raw\";\nimport close from \"./assets/close.svg?raw\";\nimport caretUp from \"./assets/caret-up-bold.svg?raw\";\nimport collapse from \"./assets/collapse.svg?raw\";\nimport expand from \"./assets/expand.svg?raw\";\nimport pause from \"./assets/pause-fill.svg?raw\";\nimport play from \"./assets/play-fill.svg?raw\";\nimport soundOff from \"./assets/speaker-x-fill.svg?raw\";\nimport soundOn from \"./assets/speaker-high-fill.svg?raw\";\n\nexport const icons = {\n caretUp,\n close,\n collapse,\n expand,\n next,\n pause,\n play,\n previous,\n soundOff,\n soundOn,\n};\n\nexport type IconName = keyof typeof icons;\n\n// Each file as markup, marked decorative once so every render reuses it.\nconst markup = Object.fromEntries(\n Object.entries(icons).map(([name, svg]) => [\n name,\n svg.replace(\n \"<svg\",\n '<svg class=\"icon\" aria-hidden=\"true\" focusable=\"false\"',\n ),\n ]),\n) as Record<IconName, string>;\n\n/**\n * Renders a bundled icon in a Lit template. It is decorative: name the\n * control around it. The markup only ever comes from the bundled files.\n */\nexport function icon(\n name: IconName,\n): DirectiveResult<typeof UnsafeHTMLDirective> {\n return unsafeHTML(markup[name]);\n}\n","<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","<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","<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","<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>","<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","<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","<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","<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","<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","<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","import { html, nothing } from \"lit\";\nimport { ref } from \"lit/directives/ref.js\";\nimport type { StoryMedia } from \"../../types\";\nimport { httpUrl } from \"../../utils/http-url\";\nimport type { VideoController } from \"./video-controller\";\n\nexport function prefersReducedMotion() {\n return (\n globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ?? false\n );\n}\n\n/** Whether renderMedia shows a video for this Story right now. */\nexport function hasVideo(story: StoryMedia, video: VideoController) {\n return !video.failed && httpUrl(story.media_url) !== null;\n}\n\nexport interface MediaOptions {\n /** Whether the video shows over the cover (default true). */\n withVideo?: boolean;\n /** Whether the video loops (default true). */\n loop?: boolean;\n /** Called when a video that doesn't loop reaches its end. */\n onEnded?: () => void;\n}\n\n/**\n * The Story cover and, with a media_url, the video looping muted over it. If\n * the video can't load, it is removed and the cover underneath stays. With\n * withVideo false, only the cover.\n */\nexport function renderMedia(\n story: StoryMedia,\n video: VideoController,\n { withVideo = true, loop = true, onEnded }: MediaOptions = {},\n) {\n const posterUrl = httpUrl(story.poster_url);\n const mediaUrl = withVideo ? httpUrl(story.media_url) : null;\n\n // Muted and inline is what browsers, iOS included, allow to autoplay. The\n // muted attribute and property are both set, since browsers differ on\n // which one they read for autoplay. No autoplay for people who asked for\n // reduced motion.\n return html`\n ${posterUrl\n ? html`<img class=\"poster\" alt=\"\" src=${posterUrl} />`\n : nothing}\n ${mediaUrl && !video.failed\n ? html`\n <video\n class=\"video\"\n muted\n playsinline\n ?loop=${loop}\n preload=\"metadata\"\n .muted=${true}\n ?autoplay=${!prefersReducedMotion()}\n poster=${posterUrl ?? nothing}\n src=${mediaUrl}\n ${ref(video.ref)}\n @play=${video.sync}\n @pause=${video.sync}\n @volumechange=${video.sync}\n @error=${video.fail}\n @ended=${onEnded}\n ></video>\n `\n : nothing}\n `;\n}\n","// Only absolute http(s) URLs reach the DOM or the network. Relative and\n// protocol-relative ones (\"/a.jpg\", \"//host/a.jpg\") don't parse without a\n// base, so they're out.\nexport function httpUrl(value: string | undefined) {\n if (!value) return null;\n try {\n const { protocol } = new URL(value);\n return protocol === \"https:\" || protocol === \"http:\" ? value : null;\n } catch {\n return null;\n }\n}\n","import type { ReactiveControllerHost } from \"lit\";\nimport { createRef } from \"lit/directives/ref.js\";\n\n/**\n * Plays a video. A blocked play is ignored: the cover or the paused state\n * stays.\n */\nexport function playVideo(video: HTMLVideoElement) {\n video.play()?.catch(() => undefined);\n}\n\n/**\n * Follows one rendered <video> (see renderMedia) and re-renders its host when\n * it plays, pauses, is muted or unmuted, or fails to load. The state comes\n * from the video's own events, so a blocked autoplay shows as paused. It needs\n * no lifecycle hooks: the browser pauses a video removed from the page.\n */\nexport class VideoController {\n /** Bound to the <video> by renderMedia. */\n readonly ref = createRef<HTMLVideoElement>();\n\n paused = true;\n // The video always starts muted: that is what browsers allow to autoplay.\n muted = true;\n /** The video could not load: only the cover is shown. */\n failed = false;\n\n constructor(private readonly host: ReactiveControllerHost) {}\n\n /** The rendered <video> is on the page and playing. */\n get playing() {\n const video = this.ref.value;\n return !!video && video.isConnected && !video.paused;\n }\n\n /** For a new <video>, such as each time the player opens. */\n reset() {\n this.paused = true;\n this.muted = true;\n this.failed = false;\n }\n\n play() {\n const video = this.ref.value;\n if (video) playVideo(video);\n }\n\n pause() {\n this.ref.value?.pause();\n }\n\n /** Plays again if the video plays on its own (see renderMedia). */\n resume() {\n const video = this.ref.value;\n if (video?.autoplay) playVideo(video);\n }\n\n togglePlayback() {\n const video = this.ref.value;\n if (!video) return;\n if (video.paused) playVideo(video);\n else video.pause();\n }\n\n mute() {\n const video = this.ref.value;\n if (video) video.muted = true;\n }\n\n /**\n * Plays from the start, with the sound on if `withSound`. A new src starts\n * there anyway; the same src (two Stories with one video) would otherwise\n * go on where it was.\n */\n restart({ withSound = false } = {}) {\n const video = this.ref.value;\n if (!video) return;\n\n video.currentTime = 0;\n if (withSound) this.playWithSound();\n else playVideo(video);\n }\n\n /**\n * Plays with the sound on. A browser that blocks playing with sound (for\n * example, without a recent tap) gets it muted instead: the video keeps\n * playing, and the sound button offers to turn it on. Not if the video was\n * replaced or removed meanwhile (the request then fails for that reason):\n * it would play out of sight.\n */\n playWithSound() {\n const video = this.ref.value;\n if (!video) return;\n\n video.muted = false;\n video.play()?.catch((error: unknown) => {\n const blocked =\n error instanceof DOMException && error.name === \"NotAllowedError\";\n if (!blocked || this.ref.value !== video || !video.isConnected) return;\n\n video.muted = true;\n playVideo(video);\n });\n }\n\n toggleMuted() {\n const video = this.ref.value;\n if (video) video.muted = !video.muted;\n }\n\n /** Listener for the video's play, pause and volumechange events. */\n readonly sync = () => {\n const video = this.ref.value;\n if (!video) return;\n this.paused = video.paused;\n this.muted = video.muted;\n this.host.requestUpdate();\n };\n\n /** Listener for the video's error event. */\n readonly fail = () => {\n this.failed = true;\n this.host.requestUpdate();\n };\n}\n","import { html, nothing } from \"lit\";\nimport type { StoryLabels } from \"../../locales\";\nimport { icon } from \"../icons\";\nimport { httpUrl } from \"../../utils/http-url\";\nimport type { StoryAd } from \"../../types\";\nimport type { StoryProductDetails } from \"../../utils/hydrate-products\";\nimport { readProductPrice } from \"./price\";\n\n/** What the card shows of the Story's product, with the prices formatted. */\nexport interface CardProduct {\n name: string;\n imageUrl?: string;\n price?: string;\n /** The \"from\" price, struck through. Only with a price. */\n listPrice?: string;\n /** The product page, opened by view product link button. */\n url?: string;\n /** Accessible name of the product button: name and prices. */\n label: string;\n /**\n * The product's details are being fetched: placeholders show in their\n * place (for now, the price's).\n */\n isLoading?: boolean;\n /**\n * The text shown in place of the price (\"Esgotado\") when the fetched\n * product can't be bought. Add to cart then becomes a disabled button.\n */\n soldOut?: string;\n}\n\n/**\n * The Story's product as fetched: `\"loading\"` while the request runs, its\n * details once found, or undefined without them (no request, not found,\n * failed). Without a fetched price, the ad server's shows.\n */\nexport type FetchedProduct = StoryProductDetails | \"loading\" | undefined;\n\n/**\n * The card's view of a Story's product, or undefined when the Story has none\n * (its destination is a link) or the product has no name.\n *\n * The price is the fetched one when there is one; while the product loads,\n * none; and otherwise the ad server's, from `product_metadata`. A fetched\n * product that can't be bought shows `labels.soldOut` instead.\n */\nexport function toCardProduct(\n story: Pick<StoryAd, \"product\" | \"destination_url\">,\n format: (amount: number) => string,\n labels: StoryLabels,\n fetched?: FetchedProduct,\n): CardProduct | undefined {\n const product = story.product;\n const name = product?.product_name?.trim();\n if (!product || !name) return undefined;\n\n const base = {\n name,\n imageUrl: httpUrl(product.image_url) ?? undefined,\n url: httpUrl(story.destination_url) ?? undefined,\n };\n\n if (fetched === \"loading\") {\n return { ...base, label: labels.product(name), isLoading: true };\n }\n if (fetched?.available === false) {\n return {\n ...base,\n label: labels.product(name, labels.soldOut),\n soldOut: labels.soldOut,\n };\n }\n\n const amounts = fetched?.price ?? readProductPrice(product.product_metadata);\n const price = amounts && format(amounts.price);\n const listPrice =\n amounts?.listPrice === undefined ? undefined : format(amounts.listPrice);\n\n return {\n ...base,\n price,\n listPrice,\n label: labels.product(name, price, listPrice),\n };\n}\n\nconst priceSkeleton = html`\n <span\n class=\"product-price product-loading product-price-loading\"\n aria-hidden=\"true\"\n ></span>\n`;\n\n// The add to cart button's place, while the product loads. Hidden from\n// assistive technology, as the price's.\nconst addToCartSkeleton = html`\n <span\n class=\"product-loading product-add-to-cart-loading\"\n aria-hidden=\"true\"\n ></span>\n`;\n\n// The price and, on sale, the \"from\" price struck through beside it. While\n// the product loads, its placeholder; sold out, the sold out text; without a\n// price, nothing.\nfunction renderPrice({ isLoading, soldOut, price, listPrice }: CardProduct) {\n if (isLoading) return priceSkeleton;\n if (soldOut) {\n return html`<span class=\"product-price product-sold-out\">${soldOut}</span>`;\n }\n if (!price) return nothing;\n\n return html`\n <span class=\"product-price\">\n <span>${price}</span>\n ${listPrice\n ? html`<s class=\"product-list-price\">${listPrice}</s>`\n : nothing}\n </span>\n `;\n}\n\n// Image, name and prices: what the pill shows.\nfunction renderSummary(product: CardProduct) {\n return html`\n ${product.imageUrl\n ? html`<img class=\"product-image\" alt=\"\" src=${product.imageUrl} />`\n : nothing}\n <span class=\"product-info\">\n <span class=\"product-name\">${product.name}</span>\n ${renderPrice(product)}\n </span>\n `;\n}\n\n/**\n * The product pill on the carousel card: image, name (up to two lines),\n * price and, on sale, the \"from\" price struck through. Without a price, only\n * the name. A button of its own, beside the card's (a button can't contain\n * another).\n */\nexport function renderProduct(product: CardProduct, onSelect: () => void) {\n return html`\n <button\n type=\"button\"\n class=\"card-product\"\n aria-label=${product.label}\n @click=${onSelect}\n >\n ${renderSummary(product)}\n </button>\n `;\n}\n\nexport interface ExpandableProductOptions {\n /** Whether the panel with the actions shows. */\n open: boolean;\n /** Called by the pill's button, to open or close the panel. */\n onToggle: () => void;\n /** Id of the panel, for the button's aria-controls. */\n panelId: string;\n /** The texts: add to cart, its disabled \"unavailable\" and view product. */\n labels: StoryLabels;\n}\n\n// Add to cart: its placeholder while the product loads, and a disabled\n// button when sold out.\nfunction renderAddToCart(\n { isLoading, soldOut }: CardProduct,\n { labels }: ExpandableProductOptions,\n) {\n if (isLoading) return addToCartSkeleton;\n if (soldOut) {\n return html`\n <button type=\"button\" class=\"product-action product-unavailable\" disabled>\n ${labels.unavailable}\n </button>\n `;\n }\n return html`\n <button type=\"button\" class=\"product-action product-add-to-cart\">\n ${labels.addToCart}\n </button>\n `;\n}\n\n/**\n * The product pill in the player. The pill is a button that opens a panel\n * below it, as in the prototype, with \"Adicionar ao carrinho\" (a placeholder\n * while the product loads, a disabled \"Produto indisponível\" when sold out)\n * and \"Ver produto\" (the product page, in a new tab; only with a URL). Open,\n * the pill turns white.\n *\n * Adding to the cart does nothing yet: it will emit an event for the store\n * to handle.\n */\nexport function renderExpandableProduct(\n product: CardProduct,\n options: ExpandableProductOptions,\n) {\n const { open } = options;\n\n return html`\n <div class=\"card-product product-expandable\" ?data-open=${open}>\n <button\n type=\"button\"\n class=\"product-summary\"\n aria-label=${product.label}\n aria-expanded=${open ? \"true\" : \"false\"}\n aria-controls=${options.panelId}\n @click=${options.onToggle}\n >\n ${renderSummary(product)}\n <span class=\"product-toggle\">${icon(\"caretUp\")}</span>\n </button>\n <div id=${options.panelId} class=\"product-panel\" ?inert=${!open}>\n <div class=\"product-actions\">\n ${renderAddToCart(product, options)}\n ${product.url\n ? html`\n <a\n class=\"product-action product-view\"\n href=${product.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n ${options.labels.viewProduct}\n </a>\n `\n : nothing}\n </div>\n </div>\n </div>\n `;\n}\n","/** Locale used when the element has none and the page has no `lang`. */\nexport const DEFAULT_LOCALE = \"pt-BR\";\n\n/** Currency used when the element has none or an invalid one. */\nexport const DEFAULT_CURRENCY = \"BRL\";\n\n/**\n * A product's price, as plain numbers. `listPrice` is the \"from\" price, only\n * present when it is above `price` (the product is on sale).\n */\nexport interface ProductPrice {\n price: number;\n listPrice?: number;\n}\n\n// A positive amount, from a number or a numeric string (\"129.9\").\nfunction toAmount(value: unknown) {\n let amount = Number.NaN;\n if (typeof value === \"number\") amount = value;\n else if (typeof value === \"string\" && value.trim() !== \"\") {\n amount = Number(value);\n }\n return Number.isFinite(amount) && amount > 0 ? amount : undefined;\n}\n\n/**\n * Reads the price from a Story product's `product_metadata`, with the names\n * the ad platform uses for prices: `price` (regular) and `promotional_price`\n * (sale, 0 or missing when there is none). The ad API doesn't send a price\n * yet, so this is undefined for now unless the catalog indexed one.\n */\nexport function readProductPrice(\n metadata: Record<string, unknown> | undefined,\n): ProductPrice | undefined {\n const regular = toAmount(metadata?.price);\n const promotional = toAmount(metadata?.promotional_price);\n\n if (\n promotional !== undefined &&\n (regular === undefined || promotional < regular)\n ) {\n return regular === undefined\n ? { price: promotional }\n : { price: promotional, listPrice: regular };\n }\n return regular === undefined ? undefined : { price: regular };\n}\n\n// A language the browser can format numbers in.\nfunction isLocale(locale: string) {\n try {\n return Intl.NumberFormat.supportedLocalesOf(locale).length > 0;\n } catch {\n return false;\n }\n}\n\n// Intl.supportedValuesOf is newer than the TypeScript lib this package\n// targets, and missing in older browsers.\nconst intl = Intl as typeof Intl & {\n supportedValuesOf?: (key: \"currency\") => string[];\n};\n\n// A currency the browser knows. Without the list (older browsers), any\n// three-letter code.\nfunction isCurrency(currency: string) {\n if (!/^[a-z]{3}$/i.test(currency)) return false;\n const known = intl.supportedValuesOf?.(\"currency\");\n return known ? known.includes(currency.toUpperCase()) : true;\n}\n\n/**\n * Formats amounts as the given currency in the given locale (\"R$ 129,90\").\n * An empty or unknown locale falls back to DEFAULT_LOCALE, and an empty or\n * unknown currency (not an ISO 4217 code) to DEFAULT_CURRENCY.\n */\nexport function priceFormatter(locale?: string, currency?: string) {\n const format = new Intl.NumberFormat(\n locale && isLocale(locale) ? locale : DEFAULT_LOCALE,\n {\n style: \"currency\",\n currency: currency && isCurrency(currency) ? currency : DEFAULT_CURRENCY,\n },\n );\n return (amount: number) => format.format(amount);\n}\n","import { html } from \"lit\";\nimport { icon } from \"../icons\";\nimport { httpUrl } from \"../../utils/http-url\";\nimport type { StoryAd } from \"../../types\";\n\n/** The call to action of a Story whose destination is a link. */\nexport interface CardCta {\n /** The button's text, from the campaign (\"Saiba mais\"). */\n label: string;\n /** The advertiser's link. */\n url: string;\n}\n\n/**\n * The call to action of a Story without a product (its destination is a\n * link), with the text set in the campaign. Undefined when the Story has a\n * product, no text or no http(s) destination.\n */\nexport function toCardCta(\n story: Pick<StoryAd, \"product\" | \"destination_url\" | \"call_to_action\">,\n): CardCta | undefined {\n if (story.product) return undefined;\n\n const label = story.call_to_action?.trim();\n const url = httpUrl(story.destination_url);\n\n return label && url ? { label, url } : undefined;\n}\n\n/**\n * The call to action at the bottom of the card or the video: a glass pill\n * with the text and a caret, a link to the destination in a new tab. With\n * `onSelect`, a click calls it instead of following the link (a card\n * without the highlight takes it first).\n */\nexport function renderCta(cta: CardCta, onSelect?: () => void) {\n const onClick = onSelect\n ? (event: Event) => {\n event.preventDefault();\n onSelect();\n }\n : undefined;\n\n return html`\n <a\n class=\"card-cta\"\n href=${cta.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n @click=${onClick}\n >\n <span class=\"cta-label\">${cta.label}</span>\n ${icon(\"next\")}\n </a>\n `;\n}\n","import { css } from \"lit\";\n\nexport const productStyles = css`\n /* A glass pill at the bottom of the card, above its button: the product or\n the call to action. */\n .card-product,\n .card-cta {\n position: absolute;\n right: 12px;\n bottom: 12px;\n left: 12px;\n z-index: 1;\n display: flex;\n gap: 8px;\n align-items: center;\n box-sizing: border-box;\n padding: 8px;\n border: 0;\n border-radius: 16px;\n background: rgba(255, 255, 255, 0.15);\n backdrop-filter: blur(5px);\n color: #fff;\n font: inherit;\n text-align: left;\n isolation: isolate;\n transition: transform 0.2s ease;\n }\n\n /* The glass's tint and inner light, darker on hover. */\n .card-product::before,\n .card-cta::before {\n position: absolute;\n inset: 0;\n z-index: -1;\n border-radius: inherit;\n background: rgba(0, 0, 0, 0.15);\n box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);\n content: \"\";\n transition: background-color 0.2s ease;\n }\n\n button.card-product,\n .card-cta {\n cursor: pointer;\n }\n\n .card-product:focus-visible,\n .card-cta:focus-visible {\n outline: 2px solid #fff;\n outline-offset: 2px;\n }\n\n @media (hover: hover) and (pointer: fine) {\n .card-product:hover,\n .card-cta:hover {\n transform: translateY(-2px);\n }\n\n .card-product:hover::before,\n .card-cta:hover::before {\n background: rgba(0, 0, 0, 0.32);\n }\n }\n\n /* A Story with a link: the pill is the call to action, its text centered\n with a caret after it. */\n .card-cta {\n justify-content: center;\n gap: 6px;\n height: 48px;\n padding: 0 16px;\n font-size: 14px;\n font-weight: 700;\n line-height: 1;\n text-decoration: none;\n }\n\n .cta-label {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .card-cta .icon {\n flex: none;\n width: 14px;\n height: 14px;\n }\n\n /* In the player: the pill is a toggle, with the actions panel below. */\n .product-expandable {\n display: block;\n padding: 0;\n transition:\n background-color 0.3s ease,\n color 0.3s ease,\n box-shadow 0.3s ease,\n transform 0.2s ease;\n }\n\n .product-expandable::before {\n transition:\n opacity 0.3s ease,\n background-color 0.2s ease;\n }\n\n .product-summary {\n display: flex;\n gap: 8px;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n padding: 8px;\n border: 0;\n border-radius: inherit;\n background: transparent;\n color: inherit;\n font: inherit;\n text-align: left;\n cursor: pointer;\n transition: padding 0.3s ease;\n }\n\n .product-summary:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 2px;\n }\n\n /* The caret points up while closed and down while open. */\n .product-toggle {\n display: grid;\n flex: none;\n margin-right: 4px;\n opacity: 0.7;\n transition:\n transform 0.3s ease,\n opacity 0.2s ease;\n }\n\n .product-toggle .icon {\n width: 14px;\n height: 14px;\n }\n\n .product-summary:hover .product-toggle {\n opacity: 1;\n }\n\n /* Closed: 0 rows tall, so it grows smoothly when it opens. */\n .product-panel {\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.3s ease;\n }\n\n .product-actions {\n display: grid;\n gap: 8px;\n min-height: 0;\n overflow: hidden;\n padding: 0 12px;\n opacity: 0;\n transition:\n padding 0.3s ease,\n opacity 0.2s ease;\n }\n\n .product-action {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n height: 48px;\n padding: 0 16px;\n border: 1px solid var(--vtex-ads-story-color-accent, #1b75a8);\n border-radius: 50px;\n font: inherit;\n font-size: 14px;\n font-weight: 700;\n text-decoration: none;\n cursor: pointer;\n transition: background-color 0.2s ease;\n }\n\n .product-action:focus-visible {\n outline: 2px solid var(--vtex-ads-story-color-accent, #1b75a8);\n outline-offset: 2px;\n }\n\n .product-add-to-cart {\n background: var(--vtex-ads-story-color-accent, #1b75a8);\n color: var(--vtex-ads-story-color-accent-contrast, #fff);\n }\n\n .product-add-to-cart:hover {\n background: color-mix(\n in srgb,\n var(--vtex-ads-story-color-accent, #1b75a8) 85%,\n #000\n );\n }\n\n /* Sold out: add to cart, disabled and grayed. */\n .product-unavailable {\n border-color: transparent;\n background: rgba(0, 0, 0, 0.06);\n color: var(--vtex-ads-story-color-muted, #6b6b6b);\n cursor: not-allowed;\n }\n\n .product-view {\n background: var(--vtex-ads-story-color-surface, #fff);\n color: var(--vtex-ads-story-color-accent, #1b75a8);\n }\n\n /* A light tint of the accent. */\n .product-view:hover {\n background: color-mix(\n in srgb,\n var(--vtex-ads-story-color-accent, #1b75a8) 8%,\n var(--vtex-ads-story-color-surface, #fff)\n );\n }\n\n /* Open: a solid card (white by default), without the glass. */\n .product-expandable[data-open] {\n background: var(--vtex-ads-story-color-surface, #fff);\n color: var(--vtex-ads-story-color-text, #242424);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);\n }\n\n .product-expandable[data-open]::before {\n opacity: 0;\n }\n\n .product-expandable[data-open] .product-price {\n color: inherit;\n }\n\n .product-expandable[data-open] .product-list-price {\n color: var(--vtex-ads-story-color-muted, #6b6b6b);\n opacity: 1;\n }\n\n .product-expandable[data-open] .product-summary {\n padding: 12px;\n }\n\n .product-expandable[data-open] .product-toggle {\n transform: rotate(180deg);\n }\n\n .product-expandable[data-open] .product-panel {\n grid-template-rows: 1fr;\n }\n\n .product-expandable[data-open] .product-actions {\n padding: 0 12px 12px;\n opacity: 1;\n transition:\n padding 0.3s ease,\n opacity 0.25s ease 0.1s;\n }\n\n /* Open, it stays in place on hover. */\n @media (hover: hover) and (pointer: fine) {\n .product-expandable[data-open]:hover {\n transform: none;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .card-product,\n .card-product:hover,\n .card-cta,\n .card-cta:hover {\n transform: none;\n transition: none;\n }\n\n .card-product::before,\n .card-cta::before,\n .product-summary,\n .product-toggle,\n .product-panel,\n .product-actions,\n .product-expandable[data-open] .product-actions {\n transition: none;\n }\n }\n\n .product-image {\n flex: none;\n width: 60px;\n height: 60px;\n border-radius: 8px;\n background: #fff;\n object-fit: contain;\n }\n\n .product-info {\n display: grid;\n flex: 1;\n gap: 4px;\n min-width: 0;\n font-size: 12px;\n font-weight: 700;\n line-height: 16px;\n }\n\n .product-name {\n display: -webkit-box;\n overflow: hidden;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n overflow-wrap: anywhere;\n }\n\n .product-price {\n display: flex;\n flex-wrap: wrap;\n gap: 0 6px;\n }\n\n .product-list-price {\n font-weight: 400;\n opacity: 0.5;\n }\n\n /* In place of the price, for a product that can't be bought. */\n .product-sold-out {\n font-weight: 700;\n opacity: 0.75;\n }\n\n /* Placeholders while the product loads, pulsing gently. */\n .product-loading {\n background: currentColor;\n opacity: 0.25;\n animation: product-loading-pulse 1.2s ease-in-out infinite alternate;\n }\n\n @keyframes product-loading-pulse {\n to {\n opacity: 0.1;\n }\n }\n\n /* The price's: a line its height (the info's line height). */\n .product-price-loading {\n width: 64px;\n height: 16px;\n border-radius: 4px;\n }\n\n /* The add to cart button's: its size and shape. */\n .product-add-to-cart-loading {\n display: block;\n height: 48px;\n border-radius: 50px;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .product-loading {\n animation: none;\n }\n }\n`;\n","import {\n css,\n html,\n type ReactiveController,\n type ReactiveControllerHost,\n type TemplateResult,\n} from \"lit\";\nimport type { StoryLabels } from \"../../locales\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { styleMap } from \"lit/directives/style-map.js\";\nimport { icon } from \"../icons\";\n\nconst STAGE_HEIGHT = css`500px`;\nconst SOLO_PADDING = css`24px`;\n\n/** Time each Story stays highlighted before the next one, in milliseconds. */\nexport const AUTO_ADVANCE_MS = 5000;\n\n/** How far a pointer must move, in pixels, to count as a swipe. */\nexport const SWIPE_DISTANCE = 40;\n\n/** Screens this narrow have no room for two cards side by side. */\nexport const NARROW_SCREEN = css`(max-width: 576px)`;\n\n/**\n * Rolling layout: cards on each side of the highlighted one. Up to\n * VISIBLE_SIDE show on each side; RENDERED_SIDE are kept in the DOM, the\n * farther ones hidden, so a card slides in from its place instead of\n * appearing.\n */\nexport const VISIBLE_SIDE = 2;\nexport const RENDERED_SIDE = VISIBLE_SIDE + 3;\n\n/**\n * How the cards are laid out:\n * - solo: one Story, the card centered over the background.\n * - pair: two Stories side by side; moving only changes the highlight.\n * - rolling: the highlighted card in the middle, the others on each side,\n * all moving one place per step. Three or more Stories, or two on narrow\n * screens.\n */\nexport type CarouselLayout = \"solo\" | \"pair\" | \"rolling\";\n\n/**\n * The carousel stage: a band as tall as the card, as wide as the element's\n * parent. The store sets the width on its own container.\n *\n * Solo: the card sits centered over a solid background with room around it:\n * the card shrinks to fit the padding and gets a soft shadow. On narrow\n * screens (576px or less) there is no room for it: the card shows alone at\n * full height.\n *\n * Pair and rolling: the highlighted card is full size, the others smaller\n * (0.9) and dimmed.\n */\nexport const carouselStyles = css`\n .carousel {\n position: relative;\n box-sizing: border-box;\n display: grid;\n height: ${STAGE_HEIGHT};\n place-items: center;\n --card-height: ${STAGE_HEIGHT};\n user-select: none;\n }\n\n .carousel[data-layout=\"solo\"] {\n padding: ${SOLO_PADDING};\n border-radius: var(--vtex-ads-story-radius, 20px);\n background: var(--vtex-ads-story-color-surface, #fafafa);\n --card-height: calc(${STAGE_HEIGHT} - 2 * ${SOLO_PADDING});\n }\n\n .carousel[data-layout=\"solo\"] .card {\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);\n }\n\n .track {\n position: absolute;\n inset: 0;\n overflow: hidden;\n touch-action: pan-y;\n }\n\n /* Each slide starts centered, then moves by its own transform. */\n .slide {\n --ease: cubic-bezier(0.25, 1, 0.5, 1);\n --duration: var(--slide-duration, 0.4s);\n position: absolute;\n top: 0;\n left: 50%;\n width: calc(${STAGE_HEIGHT} * 9 / 16);\n height: 100%;\n margin-left: calc(${STAGE_HEIGHT} * 9 / -32);\n opacity: 0.5;\n transition:\n transform var(--duration) var(--ease),\n opacity var(--duration) var(--ease),\n visibility 0s;\n }\n\n .slide[data-active] {\n opacity: 1;\n }\n\n /* Pair: --side is -1 for the first card, 1 for the second. The highlighted\n card sits 47.5% of its width off center, the other (scaled to 0.9)\n 52.5%, so the gap between them stays 8px. */\n .carousel[data-layout=\"pair\"] .slide {\n --side: 1;\n --offset: 52.5%;\n --scale: 0.9;\n transform: translateX(calc(var(--side) * (var(--offset) + 4px)))\n scale(var(--scale));\n }\n\n .carousel[data-layout=\"pair\"] .slide[data-index=\"0\"] {\n --side: -1;\n }\n\n .carousel[data-layout=\"pair\"] .slide[data-active] {\n --offset: 47.5%;\n --scale: 1;\n }\n\n /* Rolling: --place is the slide's distance from the highlighted one, in\n cards, 8px apart. A hidden slide fades out, then stops being visible. */\n .carousel[data-layout=\"rolling\"] .slide {\n transform: translateX(calc(var(--place) * (100% + 8px))) scale(0.9);\n }\n\n .carousel[data-layout=\"rolling\"] .slide[data-active] {\n transform: translateX(0) scale(1);\n }\n\n .slide[data-hidden] {\n opacity: 0;\n visibility: hidden;\n transition:\n transform var(--duration) var(--ease),\n opacity var(--duration) var(--ease),\n visibility 0s var(--duration);\n }\n\n /* Only the highlighted card opens the player, so only it shows play. Its\n sound is the only one to turn on: the others play muted, if at all. */\n .slide:not([data-active]) .play,\n .slide:not([data-active]) .card-sound {\n display: none;\n }\n\n .arrow {\n position: absolute;\n top: 50%;\n z-index: 2;\n display: grid;\n width: 32px;\n height: 32px;\n place-items: center;\n padding: 0;\n border: 1px solid rgba(133, 133, 133, 0.3);\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.3);\n backdrop-filter: blur(5px);\n color: #fff;\n cursor: pointer;\n transform: translateY(-50%);\n transition: background-color 0.2s;\n }\n\n .arrow:hover {\n background: #262626;\n }\n\n .arrow:disabled {\n cursor: default;\n opacity: 0.5;\n }\n\n .arrow .icon {\n width: 16px;\n height: 16px;\n }\n\n .arrow-previous {\n left: 3px;\n }\n\n .arrow-next {\n right: 3px;\n }\n\n @media ${NARROW_SCREEN} {\n .carousel[data-layout=\"solo\"] {\n padding: 0;\n background: none;\n --card-height: ${STAGE_HEIGHT};\n }\n\n .carousel[data-layout=\"solo\"] .card {\n box-shadow: none;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .slide,\n .slide[data-hidden] {\n transition: none;\n }\n }\n`;\n\nexport interface CarouselOptions {\n /**\n * Called when the highlight moves, before the host renders it, with the\n * keys (see Slide) of the slide that loses it and the one that gets it.\n * The host's updateComplete then resolves once the step is rendered.\n */\n onStep?: (from: number, to: number) => void;\n /**\n * Called when the layout changes (the screen got narrow or wide): every\n * slide is new, with new keys.\n */\n onLayoutChange?: () => void;\n /**\n * While true, the highlight doesn't move, by hand or on its own (for\n * example, while the player shows the highlighted Story).\n */\n locked?: () => boolean;\n}\n\n/** One rendered card. */\nexport interface Slide {\n /**\n * Stays with the card while it moves, so state kept per card (such as its\n * video) follows it. Unique among the rendered slides of a layout; the\n * same Story can show in more than one slide.\n */\n key: number;\n /** The Story's index in the list. */\n index: number;\n /** Places from the highlighted card: negative before it, positive after. */\n offset: number;\n /** Has the highlight. */\n active: boolean;\n /** Kept in the DOM out of sight, so it can slide in. */\n hidden: boolean;\n /**\n * Pass to the card's element (renderCard's ref): the carousel then knows\n * where each Story's card is (see visibleCards).\n */\n cardRef: (element?: Element) => void;\n /**\n * Pass to the card's element that takes the keyboard focus (renderCard's\n * openRef; see focusActive).\n */\n focusRef: (element?: Element) => void;\n}\n\n/** Renders the card of one Story. */\nexport type RenderSlide<T> = (item: T, slide: Slide) => TemplateResult;\n\nconst wrap = (value: number, count: number) =>\n ((value % count) + count) % count;\n\n// A ref callback that keeps `elements` up to date. Each render passes new\n// callbacks: lit calls the last render's with undefined, then the new one\n// with the element, so an element dropped by the rolling layout or the host\n// leaving the page leaves `elements`.\nfunction tracker(elements: Map<Element, Slide>, slide: Slide) {\n let last: Element | undefined;\n return (element?: Element) => {\n if (last) elements.delete(last);\n last = element;\n if (element) elements.set(element, slide);\n };\n}\n\n/**\n * The carousel around the Story cards: which Story has the highlight, the\n * layout, the arrows, swipes and the automatic advance. Call reset() when\n * the Stories change, and render() from the host's render.\n *\n * The highlight moves on its own every AUTO_ADVANCE_MS, except while the\n * pointer is over the carousel, the keyboard focus is in it, it is locked,\n * or the host is off the page.\n */\nexport class CarouselController implements ReactiveController {\n /**\n * Steps taken since the Stories loaded, back and forth, not wrapped: the\n * rolling layout keys its slides by it.\n */\n private position = 0;\n /** Stories moved by the last step: longer jumps animate a bit slower. */\n private distance = 1;\n private count = 0;\n private narrow = false;\n private media?: MediaQueryList;\n private connected = false;\n private hovered = false;\n private focused = false;\n private timer?: ReturnType<typeof setInterval>;\n private swipe?: { x: number; moved: boolean };\n /** The rendered cards, as their cardRef reported them. */\n private readonly cards = new Map<Element, Slide>();\n /** The rendered cards' focus targets, as their focusRef reported them. */\n private readonly focusTargets = new Map<Element, Slide>();\n\n constructor(\n private readonly host: ReactiveControllerHost,\n private readonly options: CarouselOptions,\n ) {\n host.addController(this);\n }\n\n /** Index of the highlighted Story. */\n get active() {\n return this.count ? wrap(this.position, this.count) : 0;\n }\n\n get layout(): CarouselLayout {\n if (this.count < 2) return \"solo\";\n return this.count === 2 && !this.narrow ? \"pair\" : \"rolling\";\n }\n\n /** Key (see Slide) of the highlighted slide. */\n get activeKey() {\n if (this.layout === \"rolling\") return this.position;\n return this.active;\n }\n\n /**\n * The cards on screen, with their slide: not the hidden ones kept for the\n * slide in.\n */\n *visibleCards(): Generator<readonly [card: Element, slide: Slide]> {\n for (const [card, slide] of this.cards) {\n if (!slide.hidden) yield [card, slide];\n }\n }\n\n /** Moves the keyboard focus to the highlighted card, once rendered. */\n focusActive() {\n for (const [target, slide] of this.focusTargets) {\n if (slide.active && target instanceof HTMLElement) {\n target.focus();\n return;\n }\n }\n }\n\n hostConnected() {\n this.connected = true;\n this.media = globalThis.matchMedia?.(NARROW_SCREEN.toString());\n this.media?.addEventListener(\"change\", this.onMediaChange);\n this.narrow = this.media?.matches ?? false;\n this.syncTimer();\n }\n\n hostDisconnected() {\n this.connected = false;\n this.media?.removeEventListener(\"change\", this.onMediaChange);\n this.media = undefined;\n this.endSwipe();\n this.syncTimer();\n }\n\n // Whatever the host changed (the player opening, new Stories) may start or\n // stop the automatic advance.\n hostUpdated() {\n this.syncTimer();\n }\n\n /** For a new list of Stories: the first one gets the highlight. */\n reset(count: number) {\n this.count = count;\n this.position = 0;\n this.distance = 1;\n // The carousel may leave the page now (the element renders nothing while\n // it loads). Removing the element with the pointer or focus doesn't fire\n // pointerleave or focusout, and the new one would never advance.\n this.hovered = false;\n this.focused = false;\n this.restartTimer();\n }\n\n /**\n * Moves the highlight by `delta` Stories, wrapping around the ends. While\n * locked, only with `evenIfLocked` (for example, the player stepping to\n * the next Story it shows).\n */\n step(delta: number, { evenIfLocked = false } = {}) {\n if (this.count < 2 || delta === 0) return;\n if (this.options.locked?.() && !evenIfLocked) return;\n\n const from = this.activeKey;\n this.position += delta;\n this.distance = Math.abs(delta);\n\n // The update is requested first, so onStep can wait for the render that\n // shows the step (the host's updateComplete).\n this.host.requestUpdate();\n this.options.onStep?.(from, this.activeKey);\n // A step by hand gives the new Story its full time.\n this.restartTimer();\n }\n\n private get shouldAdvance() {\n return (\n this.connected &&\n this.count > 1 &&\n !this.hovered &&\n !this.focused &&\n !this.options.locked?.()\n );\n }\n\n private syncTimer() {\n if (this.shouldAdvance && !this.timer) {\n this.timer = setInterval(() => this.step(1), AUTO_ADVANCE_MS);\n } else if (!this.shouldAdvance && this.timer) {\n this.stopTimer();\n }\n }\n\n private stopTimer() {\n clearInterval(this.timer);\n this.timer = undefined;\n }\n\n private restartTimer() {\n this.stopTimer();\n this.syncTimer();\n }\n\n private readonly onMediaChange = (event: MediaQueryListEvent) => {\n const layout = this.layout;\n this.narrow = event.matches;\n if (this.layout === layout) return;\n\n this.options.onLayoutChange?.();\n this.host.requestUpdate();\n };\n\n private readonly onPointerEnter = () => {\n this.hovered = true;\n this.syncTimer();\n };\n\n private readonly onPointerLeave = () => {\n this.hovered = false;\n this.syncTimer();\n };\n\n // Only keyboard focus stops the advance: a click also focuses the button\n // it hits, and the advance would then stay stopped after the pointer left.\n private readonly onFocusIn = (event: FocusEvent) => {\n this.focused = (event.target as Element).matches(\":focus-visible\");\n this.syncTimer();\n };\n\n private readonly onFocusOut = (event: FocusEvent) => {\n const carousel = event.currentTarget as Element;\n const next = event.relatedTarget as Node | null;\n if (!next || !carousel.contains(next)) this.focused = false;\n this.syncTimer();\n };\n\n // The release is listened for on the window: a mouse drag can end over an\n // arrow or off the carousel, where the track never gets the pointerup.\n private readonly onPointerDown = (event: PointerEvent) => {\n this.endSwipe();\n this.swipe = { x: event.clientX, moved: false };\n globalThis.addEventListener(\"pointerup\", this.onPointerUp);\n globalThis.addEventListener(\"pointercancel\", this.onPointerCancel);\n };\n\n private readonly onPointerUp = (event: PointerEvent) => {\n const { swipe } = this;\n this.removeSwipeListeners();\n if (!swipe) return;\n\n const distance = event.clientX - swipe.x;\n if (Math.abs(distance) > SWIPE_DISTANCE) {\n swipe.moved = true;\n this.step(distance < 0 ? 1 : -1);\n }\n };\n\n private readonly onPointerCancel = () => this.endSwipe();\n\n private endSwipe() {\n this.removeSwipeListeners();\n this.swipe = undefined;\n }\n\n private removeSwipeListeners() {\n globalThis.removeEventListener(\"pointerup\", this.onPointerUp);\n globalThis.removeEventListener(\"pointercancel\", this.onPointerCancel);\n }\n\n // A swipe ends with a click on the card under the pointer: it must not\n // open the player or select that card.\n private readonly onClickCapture = {\n handleEvent: (event: Event) => {\n if (this.swipe?.moved) {\n event.stopPropagation();\n event.preventDefault();\n }\n this.swipe = undefined;\n },\n capture: true,\n };\n\n private slide(fields: Omit<Slide, \"cardRef\" | \"focusRef\">): Slide {\n const slide: Slide = {\n ...fields,\n cardRef: (element) => track(element),\n focusRef: (element) => trackFocus(element),\n };\n const track = tracker(this.cards, slide);\n const trackFocus = tracker(this.focusTargets, slide);\n return slide;\n }\n\n /** Pair: both Stories, each keyed by its index. */\n private pairSlides(): Slide[] {\n const { active } = this;\n return [0, 1].map((index) =>\n this.slide({\n key: index,\n index,\n offset: index - active,\n active: index === active,\n hidden: false,\n }),\n );\n }\n\n /**\n * Rolling: the slides around the highlighted one, keyed by their position.\n * Up to VISIBLE_SIDE show on each side, fewer when there aren't enough\n * Stories to fill both sides without repeating: half on each side, the\n * extra one after it. With four, the Story opposite the highlighted one\n * shows at both ends; with two (narrow screens), the other one shows on\n * both sides.\n */\n private rollingSlides(): Slide[] {\n const { count } = this;\n const even = count === 2 || count === 4;\n const before = even ? count / 2 : Math.floor((count - 1) / 2);\n const after = even ? count / 2 : count - 1 - before;\n\n const slides: Slide[] = [];\n for (let offset = -RENDERED_SIDE; offset <= RENDERED_SIDE; offset += 1) {\n slides.push(\n this.slide({\n key: this.position + offset,\n index: wrap(this.position + offset, count),\n offset,\n active: offset === 0,\n hidden:\n Math.abs(offset) > VISIBLE_SIDE ||\n offset < -before ||\n offset > after,\n }),\n );\n }\n return slides;\n }\n\n private renderSlides<T>(items: readonly T[], renderSlide: RenderSlide<T>) {\n const { layout } = this;\n const slides = layout === \"pair\" ? this.pairSlides() : this.rollingSlides();\n\n // The layout is part of the key: the same key in another layout is a new\n // card, with a new video and controller (see onLayoutChange).\n return repeat(\n slides,\n (slide) => `${layout}:${slide.key}`,\n (slide) => {\n const { index } = slide;\n return html`\n <div\n class=\"slide\"\n data-index=${index}\n ?data-active=${slide.active}\n ?data-hidden=${slide.hidden}\n ?inert=${slide.hidden}\n style=${styleMap({ \"--place\": String(slide.offset) })}\n >\n ${renderSlide(items[index], slide)}\n </div>\n `;\n },\n );\n }\n\n /**\n * One item: the card centered over the background. More: the cards in the\n * pair or rolling layout, with the arrows.\n */\n render<T>(\n items: readonly T[],\n renderSlide: RenderSlide<T>,\n labels: StoryLabels,\n ) {\n if (this.layout === \"solo\") {\n return html`\n <div class=\"carousel\" data-layout=\"solo\">\n ${renderSlide(\n items[0],\n this.slide({\n key: 0,\n index: 0,\n offset: 0,\n active: true,\n hidden: false,\n }),\n )}\n </div>\n `;\n }\n\n const locked = this.options.locked?.() ?? false;\n\n return html`\n <div\n class=\"carousel\"\n data-layout=${this.layout}\n role=\"region\"\n aria-roledescription=${labels.carouselRole}\n aria-label=${labels.carousel}\n @pointerenter=${this.onPointerEnter}\n @pointerleave=${this.onPointerLeave}\n @focusin=${this.onFocusIn}\n @focusout=${this.onFocusOut}\n >\n <div\n class=\"track\"\n style=${styleMap({\n \"--slide-duration\": this.distance > 1 ? \"0.52s\" : \"0.4s\",\n })}\n @pointerdown=${this.onPointerDown}\n @click=${this.onClickCapture}\n >\n ${this.renderSlides(items, renderSlide)}\n </div>\n <button\n type=\"button\"\n class=\"arrow arrow-previous\"\n aria-label=${labels.previous}\n ?disabled=${locked}\n @click=${() => this.step(-1)}\n >\n ${icon(\"previous\")}\n </button>\n <button\n type=\"button\"\n class=\"arrow arrow-next\"\n aria-label=${labels.next}\n ?disabled=${locked}\n @click=${() => this.step(1)}\n >\n ${icon(\"next\")}\n </button>\n </div>\n `;\n }\n}\n","export const TAG_NAME = \"vtex-ads-story-carousel\";\n","import { httpUrl } from \"./http-url\";\nimport { TAG_NAME } from \"../tag-name\";\n\n// A CORS-safelisted type: the browser sends the event without a preflight\n// request, and sendBeacon accepts it everywhere. The event host reads the\n// body as JSON whatever its type.\nconst CONTENT_TYPE = \"text/plain;charset=utf-8\";\n\n/** Who the event is for: the same session sent in the ad request. */\nexport interface EventIdentity {\n sessionId: string;\n userId?: string;\n}\n\n/**\n * Sends an impression, view or click to the event URL from the ad response,\n * as VTEX Ads asks of browsers: a POST with a JSON body holding `session_id`\n * and, when known, `user_id`, through `navigator.sendBeacon`, so the event\n * survives the page being left. Without the Beacon API, or when the browser\n * refuses to queue the beacon, it falls back to a `fetch` with `keepalive`.\n * The body goes as `text/plain` (see CONTENT_TYPE).\n *\n * The fallback isn't awaited: it returns true once the `fetch` starts, and a\n * failed request is logged, not sent again. The server deduplicates by\n * session anyway, and a retry could outlive the page.\n *\n * Returns false, sending nothing, when the URL isn't an absolute http(s)\n * URL, during server-side rendering or when both ways fail at once.\n */\nexport function sendEvent(\n url: string | undefined,\n { sessionId, userId }: EventIdentity,\n): boolean {\n const target = httpUrl(url);\n if (!target || globalThis.window === undefined) return false;\n\n const body = JSON.stringify(\n userId\n ? { session_id: sessionId, user_id: userId }\n : { session_id: sessionId },\n );\n\n try {\n const queued = globalThis.navigator?.sendBeacon?.(\n target,\n new Blob([body], { type: CONTENT_TYPE }),\n );\n if (queued) return true;\n } catch {\n // A browser that throws instead of refusing (for example, for a URL it\n // won't beacon to): the fetch below sends it instead.\n }\n\n if (typeof globalThis.fetch !== \"function\") return false;\n\n globalThis\n .fetch(target, {\n method: \"POST\",\n headers: { \"Content-Type\": CONTENT_TYPE },\n body,\n keepalive: true,\n credentials: \"omit\",\n })\n .catch((error: unknown) => {\n console.error(`[${TAG_NAME}] Event request failed`, {\n url: target,\n error,\n });\n });\n return true;\n}\n","import type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport type { StoryAd } from \"../../types\";\nimport { sendEvent, type EventIdentity } from \"../../utils/send-event\";\n\nexport const VIEW_THRESHOLD = 0.5;\nexport const VIEW_DURATION_MS = 2000;\n\ntype EventKind = \"impression\" | \"view\" | \"click\";\n\nconst URL_FIELD = {\n impression: \"impression_url\",\n view: \"view_url\",\n click: \"click_url\",\n} as const satisfies Record<EventKind, keyof StoryAd>;\n\n/** An element that shows a Story, watched for the view. */\nexport type ViewTarget = readonly [element: Element, story: StoryAd];\n\nexport interface StoryEventsOptions {\n /**\n * The session and user the events are for, read when each one is sent.\n * Without a session, nothing is sent.\n */\n identity: () => Partial<EventIdentity>;\n /**\n * The elements on which a Story can be seen right now, read after every\n * render of the host. An element left out stops counting toward its view.\n */\n viewTargets: () => Iterable<ViewTarget>;\n}\n\ninterface Watched {\n story: StoryAd;\n /** Last reported by the observer: at least VIEW_THRESHOLD on screen. */\n visible: boolean;\n timer?: ReturnType<typeof setTimeout>;\n}\n\n/**\n * Sends a Story's impression, view and click URLs, each at most once per\n * Story and session (the ad API's `session_id`):\n *\n * - impression: when the Story is rendered in the carousel (impress());\n * - view: when one of its elements (see `viewTargets`) has stayed at least\n * 50% on screen for 2 continuous seconds, with the page visible;\n * - click: on the first touch on the Story (click()).\n *\n * Without IntersectionObserver, no view is sent. Leaving the page stops\n * the views counting; nothing sent is sent again on return.\n */\nexport class StoryEventsController implements ReactiveController {\n private readonly sent: Record<EventKind, Set<string>> = {\n impression: new Set(),\n view: new Set(),\n click: new Set(),\n };\n\n private pendingImpressions: readonly StoryAd[] = [];\n\n private observer?: IntersectionObserver;\n private readonly watched = new Map<Element, Watched>();\n\n constructor(\n private readonly host: ReactiveControllerHost,\n private readonly options: StoryEventsOptions,\n ) {\n host.addController(this);\n }\n\n hostConnected() {\n if (typeof IntersectionObserver === \"function\") {\n this.observer = new IntersectionObserver(this.onIntersect, {\n threshold: VIEW_THRESHOLD,\n });\n }\n globalThis.document?.addEventListener(\n \"visibilitychange\",\n this.onVisibilityChange,\n );\n // Moved on the page: the cards rendered before are still there, but lit\n // hands their refs back only after the controllers connect.\n this.host.updateComplete.then(() => this.syncViewTargets());\n }\n\n hostDisconnected() {\n globalThis.document?.removeEventListener(\n \"visibilitychange\",\n this.onVisibilityChange,\n );\n this.observer?.disconnect();\n this.observer = undefined;\n for (const watched of this.watched.values()) clearTimeout(watched.timer);\n this.watched.clear();\n // Stories that never rendered were never seen.\n this.pendingImpressions = [];\n }\n\n hostUpdated() {\n const stories = this.pendingImpressions;\n if (stories.length && this.options.identity().sessionId) {\n this.pendingImpressions = [];\n for (const story of stories) this.send(\"impression\", story);\n }\n\n this.syncViewTargets();\n }\n\n /**\n * The Stories the host renders next: their impressions go out once that\n * render is done, or, without a session yet, after the first render that\n * has one. Replaces Stories passed before and not sent yet.\n */\n impress(stories: readonly StoryAd[]) {\n this.pendingImpressions = stories;\n }\n\n /** A touch on the Story: its click goes out, the first time only. */\n click(story: StoryAd) {\n this.send(\"click\", story);\n }\n\n private key(sessionId: string, story: StoryAd) {\n return `${sessionId}|${story.ad_id}`;\n }\n\n private wasSent(kind: EventKind, story: StoryAd) {\n const { sessionId } = this.options.identity();\n return !!sessionId && this.sent[kind].has(this.key(sessionId, story));\n }\n\n private send(kind: EventKind, story: StoryAd) {\n const { sessionId, userId } = this.options.identity();\n if (!sessionId || this.wasSent(kind, story)) return;\n\n const success = sendEvent(story[URL_FIELD[kind]], { sessionId, userId });\n if (success) {\n this.sent[kind].add(this.key(sessionId, story));\n }\n }\n\n // Watches the elements the host shows now, and stops watching the others,\n // dropping the time they had on screen.\n private syncViewTargets() {\n const { observer } = this;\n if (!observer) return;\n\n const current = new Map<Element, StoryAd>();\n for (const [element, story] of this.options.viewTargets()) {\n if (!this.wasSent(\"view\", story)) current.set(element, story);\n }\n\n for (const [element, watched] of this.watched) {\n if (current.get(element) !== watched.story) {\n this.unwatch(element, watched);\n }\n }\n\n for (const [element, story] of current) {\n if (this.watched.has(element)) continue;\n this.watched.set(element, { story, visible: false });\n observer.observe(element);\n }\n }\n\n private readonly onIntersect = (entries: IntersectionObserverEntry[]) => {\n for (const entry of entries) {\n const watched = this.watched.get(entry.target);\n if (!watched) continue;\n\n watched.visible =\n entry.isIntersecting && entry.intersectionRatio >= VIEW_THRESHOLD;\n if (watched.visible) this.startTimer(watched);\n else this.stopTimer(watched);\n }\n };\n\n // A hidden page (another tab, minimized) breaks the 2 seconds: they start\n // over when it shows again.\n private readonly onVisibilityChange = () => {\n for (const watched of this.watched.values()) {\n if (document.hidden) this.stopTimer(watched);\n else if (watched.visible) this.startTimer(watched);\n }\n };\n\n private startTimer(watched: Watched) {\n if (watched.timer || globalThis.document?.hidden) return;\n watched.timer = setTimeout(() => {\n watched.timer = undefined;\n this.send(\"view\", watched.story);\n // Its other elements no longer need watching.\n if (this.wasSent(\"view\", watched.story)) this.unwatchStory(watched.story);\n }, VIEW_DURATION_MS);\n }\n\n private stopTimer(watched: Watched) {\n clearTimeout(watched.timer);\n watched.timer = undefined;\n }\n\n private unwatch(element: Element, watched: Watched) {\n this.stopTimer(watched);\n this.observer?.unobserve(element);\n this.watched.delete(element);\n }\n\n private unwatchStory(story: StoryAd) {\n for (const [element, watched] of this.watched) {\n if (watched.story.ad_id === story.ad_id) this.unwatch(element, watched);\n }\n }\n}\n","import { css, html, nothing } from \"lit\";\nimport type { StoryLabels } from \"../../locales\";\nimport type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport { createRef, ref } from \"lit/directives/ref.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { styleMap } from \"lit/directives/style-map.js\";\nimport { icon } from \"../icons\";\nimport {\n hasVideo,\n prefersReducedMotion,\n renderMedia,\n VideoController,\n} from \"../media\";\nimport { httpUrl } from \"../../utils/http-url\";\nimport {\n renderCta,\n renderExpandableProduct,\n type CardCta,\n type CardProduct,\n} from \"../product\";\nimport type { StoryMedia } from \"../../types\";\n\n/**\n * Expanded view gaps, in pixels: between the video and the nearest covers,\n * and between covers. Shared by the CSS and the step animation.\n */\nexport const NEAR_GAP = 72;\nexport const FAR_GAP = 48;\n\n// The player is a <dialog> shown in the top layer, so no store z-index,\n// overflow or transform can hide or move it.\n//\n// Mini: a manual popover (non-modal, the page stays usable), with the card at\n// the bottom right and the controls above it. Without popover support it is a\n// non-modal dialog, fixed with a high z-index.\n// Expanded: a modal dialog (showModal), so the browser makes the page behind\n// it inert. The card is centered over a dark backdrop, with the controls at\n// the top right of the screen. On narrow screens it fills the screen.\nexport const playerStyles = css`\n .player {\n position: fixed;\n inset: auto 16px 16px auto;\n z-index: 2147483000;\n box-sizing: border-box;\n width: calc(min(587px, 100vh - 80px) * 9 / 16);\n height: min(587px, 100vh - 80px);\n margin: 0;\n padding: 0;\n overflow: visible;\n border: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n animation: player-in 0.25s ease;\n }\n\n /* A <dialog> shown as a popover has no open attribute, which the browser\n hides by default. */\n .player:popover-open {\n display: block;\n }\n\n /* Switching modes shows the dialog again; only the first opening fades in. */\n .player[data-switched] {\n animation: none;\n }\n\n .player::backdrop {\n background: transparent;\n }\n\n /* Focusable only to keep the focus in the player when its video is clicked\n (see render): no ring around the whole player. */\n .player:focus {\n outline: none;\n }\n\n .player-frame {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n /* What moves in the expanded view, off center with two Stories and in the\n step animation: the video, its dimming and previous and next. Expand and\n close stay out of it: a transformed box becomes the one their fixed\n position, at the top right of the screen, is measured from. */\n .player-stage {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .player .card {\n width: 100%;\n height: 100%;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);\n }\n\n .player .card:has(.video) {\n cursor: pointer;\n }\n\n /* Play/pause reuses the card's glass .play button, as a real button. */\n .player-toggle {\n padding: 0;\n border: 0;\n color: #fff;\n font: inherit;\n cursor: pointer;\n }\n\n .player[data-paused] .player-toggle,\n .player-toggle:focus-visible {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n\n /* On touch, tapping the video pauses it; the button shows while paused. */\n @media (hover: none) {\n .player:not([data-paused]) .player-toggle {\n opacity: 0;\n }\n }\n\n .player-sound {\n position: absolute;\n top: 12px;\n right: 12px;\n z-index: 1;\n border-color: transparent;\n background: rgba(0, 0, 0, 0.3);\n }\n\n .player-sound .icon {\n width: 20px;\n height: 20px;\n }\n\n /* The product pill or the call to action. Their wrapper only stops clicks:\n the pill places itself. The product is larger than on the carousel card\n (as in the prototype). */\n .player-destination {\n display: contents;\n }\n\n .player .product-info {\n font-size: 14px;\n }\n\n .player .product-image {\n width: 72px;\n height: 72px;\n }\n\n .player .product-price {\n color: rgba(255, 255, 255, 0.7);\n }\n\n /* Above the card: on narrow screens the expanded card can cover them. */\n .player-controls {\n position: absolute;\n right: 0;\n bottom: calc(100% + 8px);\n z-index: 1;\n display: flex;\n gap: 8px;\n }\n\n /* Previous and next Story, above the card's top left (mini player only). */\n .player-nav {\n right: auto;\n left: 0;\n }\n\n .player-button {\n display: grid;\n width: 36px;\n height: 36px;\n place-items: center;\n padding: 0;\n border: 1px solid rgba(133, 133, 133, 0.3);\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.32);\n backdrop-filter: blur(5px);\n color: #fff;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n .player-button:hover {\n background: rgba(0, 0, 0, 0.55);\n }\n\n .player-button .icon {\n width: 18px;\n height: 18px;\n }\n\n .player[data-expanded] {\n inset: 0;\n display: grid;\n width: 100%;\n max-width: none;\n height: 100%;\n max-height: none;\n place-items: center;\n background: rgba(0, 0, 0, 0.85);\n animation: none;\n }\n\n .player[data-expanded] .player-frame {\n width: calc(min(78vh, 720px) * 9 / 16);\n height: min(78vh, 720px);\n }\n\n .player[data-expanded] .player-controls {\n position: fixed;\n top: 24px;\n right: 24px;\n bottom: auto;\n }\n\n .player[data-expanded] .player-button {\n width: 40px;\n height: 40px;\n }\n\n /* Expanded with more than one Story: the other Stories' covers beside the\n video, smaller and dimmed, as in the prototype. --side is -1 (before)\n or 1 (after), --beyond how many places past the nearest one. */\n .player[data-expanded] {\n --center-height: min(78vh, 720px);\n --side-height: min(38vh, 320px);\n --side-width: calc(var(--side-height) * 9 / 16);\n --center-half: calc(var(--center-height) * 9 / 32);\n --near-gap: ${NEAR_GAP}px;\n --far-gap: ${FAR_GAP}px;\n --near: calc(var(--center-half) + var(--near-gap) + var(--side-width) / 2);\n --pitch: calc(var(--side-width) + var(--far-gap));\n }\n\n .player-neighbor {\n position: absolute;\n top: 50%;\n left: 50%;\n width: var(--side-width);\n height: var(--side-height);\n padding: 0;\n overflow: hidden;\n border: 0;\n border-radius: 16px;\n background: #111;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);\n cursor: pointer;\n transform: translate(\n calc(-50% + var(--side) * var(--near) + var(--beyond) * var(--pitch)),\n -50%\n );\n }\n\n .player-neighbor img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n /* Fades out as the video arrives from a dimmed cover (see animateStep). */\n .player-dim {\n position: absolute;\n inset: 0;\n z-index: 3;\n border-radius: var(--vtex-ads-story-radius, 20px);\n background: rgba(0, 0, 0, 0.35);\n opacity: 0;\n pointer-events: none;\n }\n\n .player-neighbor::after {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.35);\n content: \"\";\n }\n\n .player-neighbor:hover::after,\n .player-neighbor:focus-visible::after {\n background: rgba(0, 0, 0, 0.12);\n }\n\n .player-neighbor:focus-visible {\n outline: 2px solid #fff;\n outline-offset: 2px;\n }\n\n /* Two Stories: the video moves off center toward --pair-dir, and the other\n Story sits on the other side. */\n .player[data-pair] .player-stage {\n transform: translateX(\n calc(var(--pair-dir) * (var(--near-gap) + var(--side-width)) / 2)\n );\n }\n\n .player[data-pair] .player-neighbor {\n transform: translate(\n calc(\n -50% + var(--pair-dir) * -1 * (var(--center-half) + var(--near-gap) / 2)\n ),\n -50%\n );\n }\n\n /* Expanded previous and next: beside the video, centered on its height. */\n .player[data-expanded] .player-nav {\n position: static;\n display: contents;\n }\n\n .player[data-expanded] .player-nav .player-button {\n position: absolute;\n top: 50%;\n z-index: 2;\n transform: translateY(-50%);\n }\n\n .player[data-expanded] .player-previous {\n left: -56px;\n }\n\n .player[data-expanded] .player-next {\n right: -56px;\n }\n\n /* With two, the other Story's cover beside the video does that. */\n .player[data-expanded][data-pair] .player-nav {\n display: none;\n }\n\n @media (max-width: 576px) {\n .player {\n right: 12px;\n width: 220px;\n height: 391px;\n }\n\n .player:not([data-expanded]) .product-image {\n width: 56px;\n height: 56px;\n }\n\n /* \"Adicionar ao carrinho\" fits on one line in the narrow mini player. */\n .player:not([data-expanded]) .product-action {\n height: 40px;\n padding: 0 8px;\n font-size: 12px;\n }\n\n .player[data-expanded] {\n background: #000;\n }\n\n /* The video stays 9:16 and centered; the rest of the screen is black. */\n .player[data-expanded] .player-frame {\n width: min(100vw, 100vh * 9 / 16);\n height: min(100vh, 100vw * 16 / 9);\n }\n\n .player[data-expanded] .card {\n border-radius: 0;\n }\n\n /* Below the sound button, at the top right of the video. Placed in the\n video frame, not the screen: the frame is centered, so on screens\n taller than 9:16 its top is below the screen's. */\n .player[data-expanded] .player-controls {\n position: absolute;\n top: 60px;\n right: 12px;\n }\n\n /* No room for the other Stories' covers: previous and next go inside\n the video's edges instead, also with two. */\n .player-neighbor {\n display: none;\n }\n\n .player[data-pair] .player-stage {\n transform: none;\n }\n\n .player[data-expanded][data-pair] .player-nav {\n display: contents;\n }\n\n .player[data-expanded] .player-previous {\n left: 12px;\n }\n\n .player[data-expanded] .player-next {\n right: 12px;\n }\n }\n\n @keyframes player-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .player {\n animation: none;\n }\n }\n`;\n\nexport interface PlayerOptions {\n /**\n * Called by the previous (-1) and next (1) buttons, by another Story's\n * cover in the expanded view (its offset) and, in the expanded view, when\n * the video ends (1). Show the Story it\n * leads to with the next render(), then call showNext().\n */\n onStep?: (delta: number) => void;\n /**\n * Called by the close button, Escape and a click on the expanded view's\n * backdrop. Call close() from it.\n */\n onClose: () => void;\n}\n\n/** Another Story shown beside the expanded video. */\nexport interface PlayerNeighbor {\n /** Places from the Story in the player: negative before, positive after. */\n offset: number;\n story: StoryMedia;\n /**\n * Accessible name of its cover, telling it apart from the others (default\n * the `show` text).\n */\n label?: string;\n}\n\nexport interface PlayerRenderOptions {\n labels: StoryLabels;\n /**\n * More than one Story: previous and next buttons and, in the expanded\n * view, the video moves on to the next Story when it ends.\n */\n navigation?: boolean;\n /** The other Stories beside the expanded video (see neighborOffsets). */\n neighbors?: readonly PlayerNeighbor[];\n /** The Story's product, shown at the bottom of the video. */\n product?: CardProduct;\n /** The Story's call to action, for a link destination (no product). */\n cta?: CardCta;\n /**\n * Called by any click on the video's card (the video, its play and sound\n * buttons, the product and the call to action), before what that click\n * does. Not by previous and next, the window buttons or the covers beside\n * the video.\n */\n onPress?: () => void;\n}\n\n// What shows at the bottom of the video: one or the other.\ntype StoryDestination = Pick<PlayerRenderOptions, \"product\" | \"cta\" | \"labels\">;\n\n/**\n * Offsets of the Stories shown beside the expanded video, as in the\n * prototype: one with two Stories, on the side away from the edge the\n * highlighted one is on; otherwise the nearest ones, up to two per side, each\n * Story once.\n */\nexport function neighborOffsets(count: number, active: number): number[] {\n if (count < 2) return [];\n if (count === 2) return [active === 0 ? 1 : -1];\n\n const offsets: number[] = [];\n const shown = new Set([0]);\n for (const offset of [-1, 1, -2, 2]) {\n const index = ((offset % count) + count) % count;\n if (!shown.has(index)) {\n shown.add(index);\n offsets.push(offset);\n }\n }\n return offsets;\n}\n\n/** The prototype's expanded step: slow at the end, without bounce. */\nexport const STEP_ANIMATION: KeyframeAnimationOptions = {\n duration: 560,\n easing: \"cubic-bezier(0.32, 0.72, 0, 1)\",\n};\n\n/** Widths of the expanded view, in pixels, as rendered. */\ninterface StepSizes {\n frameWidth: number;\n sideWidth: number;\n}\n\n/** The Story in the player and the covers beside it, as rendered. */\ninterface ShownStories {\n story: StoryMedia;\n neighbors: readonly PlayerNeighbor[];\n}\n\n/** A cover beside the expanded video and its place (see PlayerNeighbor). */\ninterface RenderedNeighbor {\n element: HTMLElement;\n offset: number;\n}\n\n// Each cover is centered on the screen by translate(-50%, -50%), then moved.\nconst coverTransform = (x: number, scale = 1) =>\n `translate(-50%, -50%) translateX(${x}px) scale(${scale})`;\n\nconst fadeIn = (element: HTMLElement) =>\n element.animate([{ opacity: 0 }, { opacity: 1 }], {\n ...STEP_ANIMATION,\n pseudoElement: \"::after\",\n });\n\n/**\n * Three or more Stories: the video comes from `frameFrom`, the place of the\n * cover of the Story it now shows. Each cover comes from `from`, its Story's\n * place before the step; the one that was the video, from the middle, at the\n * video's size, its dimming fading in. The places match the CSS\n * (--near, --pitch).\n */\nfunction animateRailStep(\n frame: HTMLElement,\n frameFrom: number,\n neighbors: readonly (RenderedNeighbor & { from: number })[],\n { frameWidth, sideWidth }: StepSizes,\n): Animation[] {\n const placeX = (place: number) => {\n if (place === 0) return 0;\n const side = Math.sign(place);\n const near = frameWidth / 2 + NEAR_GAP + sideWidth / 2;\n return side * near + (place - side) * (sideWidth + FAR_GAP);\n };\n const ratio = sideWidth / frameWidth;\n\n const animations = [\n frame.animate(\n [\n { transform: `translateX(${placeX(frameFrom)}px) scale(${ratio})` },\n { transform: \"none\" },\n ],\n STEP_ANIMATION,\n ),\n ];\n\n for (const { element, offset, from } of neighbors) {\n const wasVideo = from === 0;\n\n animations.push(\n element.animate(\n [\n { transform: coverTransform(placeX(from), wasVideo ? 1 / ratio : 1) },\n { transform: coverTransform(placeX(offset)) },\n ],\n STEP_ANIMATION,\n ),\n );\n if (wasVideo) animations.push(fadeIn(element));\n }\n return animations;\n}\n\n/**\n * Two Stories: the video and the other cover swap sides. `direction` is the\n * side the video ends on (--pair-dir). The places match the CSS.\n */\nfunction animatePairStep(\n frame: HTMLElement,\n neighbor: HTMLElement,\n direction: number,\n { frameWidth, sideWidth }: StepSizes,\n): Animation[] {\n const videoX = (side: number) => (side * (NEAR_GAP + sideWidth)) / 2;\n const coverX = (side: number) => (-side * (frameWidth + NEAR_GAP)) / 2;\n const ratio = sideWidth / frameWidth;\n\n return [\n frame.animate(\n [\n { transform: `translateX(${coverX(-direction)}px) scale(${ratio})` },\n { transform: `translateX(${videoX(direction)}px)` },\n ],\n STEP_ANIMATION,\n ),\n neighbor.animate(\n [\n { transform: coverTransform(videoX(-direction), 1 / ratio) },\n { transform: coverTransform(coverX(direction)) },\n ],\n STEP_ANIMATION,\n ),\n fadeIn(neighbor),\n ];\n}\n\n/** The keys that step to the previous (-1) and next (1) Story. */\nconst ARROW_STEPS: Readonly<Record<string, number>> = {\n ArrowLeft: -1,\n ArrowRight: 1,\n};\n\n/**\n * Whether an arrow key press is free for the player: not already handled,\n * and without a modifier (Alt+Left goes back in the browser).\n */\nconst isFreeArrowKey = (event: KeyboardEvent) =>\n !event.defaultPrevented &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey &&\n !event.shiftKey;\n\nfunction supportsPopover(dialog: HTMLDialogElement) {\n return typeof dialog.showPopover === \"function\";\n}\n\n/**\n * The Story player, rendered by its host with render(). open() shows it as\n * the mini player; expand switches to the expanded view, a modal dialog, and\n * back. The video starts muted and plays when the player opens. It closes on\n * its own when the host leaves the page.\n */\nexport class PlayerController implements ReactiveController {\n readonly video: VideoController;\n\n /** Rendered and, once the host has updated, shown. */\n isOpen = false;\n private expanded = false;\n\n /** Open in the expanded view, a modal over the page. */\n get isExpanded() {\n return this.isOpen && this.expanded;\n }\n\n /** The card with the video, while the player is open. */\n get stageCard(): Element | undefined {\n return this.isOpen ? this.stageCardRef.value : undefined;\n }\n\n /** The product panel is open. Closed again on a step and on opening. */\n private productOpen = false;\n /** Switched modes at least once: only the first opening fades in. */\n private switched = false;\n /** The dialog is showing, in the mode `expanded` says. */\n private shown = false;\n\n private readonly dialog = createRef<HTMLDialogElement>();\n private readonly expandButton = createRef<HTMLButtonElement>();\n private readonly closeButton = createRef<HTMLButtonElement>();\n private readonly stage = createRef<HTMLElement>();\n private readonly stageCardRef = createRef<HTMLElement>();\n private readonly dim = createRef<HTMLElement>();\n\n /** The covers beside the expanded video, by offset, as rendered. */\n private readonly neighborElements = new Map<number, HTMLElement>();\n /** One ref callback per offset: a new one each render would detach it. */\n private readonly neighborRefs = new Map<\n number,\n (element?: Element) => void\n >();\n /** Rendered with previous and next (see PlayerRenderOptions). */\n private navigation = false;\n /** Side the expanded video moved to with two Stories; 0 otherwise. */\n private pairDirection = 0;\n /** The Story and covers rendered, and those before the last step. */\n private rendered?: ShownStories;\n private beforeStep?: ShownStories;\n /** The step animation running, cancelled by the next step. */\n private animations: Animation[] = [];\n\n constructor(\n private readonly host: ReactiveControllerHost,\n private readonly options: PlayerOptions,\n ) {\n host.addController(this);\n this.video = new VideoController(host);\n }\n\n hostDisconnected() {\n this.close();\n }\n\n /**\n * Opens the mini player, plays the video and focuses the close button.\n * With `productOpen`, the product panel shows open (the shopper chose the\n * product).\n */\n async open({ productOpen = false }: { productOpen?: boolean } = {}) {\n if (this.isOpen) return;\n\n document.addEventListener(\"keydown\", this.onKeyDown);\n this.isOpen = true;\n this.expanded = false;\n this.productOpen = productOpen;\n this.switched = false;\n this.rendered = undefined;\n this.beforeStep = undefined;\n this.video.reset();\n this.host.requestUpdate();\n await this.host.updateComplete;\n\n const dialog = this.dialog.value;\n // Closed again before the host rendered it.\n if (!this.isOpen || !dialog) return;\n\n this.show(dialog);\n this.video.play();\n this.closeButton.value?.focus();\n }\n\n /** Hides the player now; the host removes it on its next update. */\n close() {\n if (!this.isOpen) return;\n\n document.removeEventListener(\"keydown\", this.onKeyDown);\n this.cancelAnimations();\n const dialog = this.dialog.value;\n if (dialog) this.hide(dialog);\n this.isOpen = false;\n this.host.requestUpdate();\n }\n\n /**\n * After the host renders a different Story in the open player, `delta`\n * places from the previous one: its video starts from the top and plays,\n * with the sound as the shopper left it. A failed load of the previous\n * video doesn't hide the new one. The expanded view animates the step.\n */\n async showNext(delta = 0) {\n if (!this.isOpen) return;\n\n // Read before the render: a Story without a video, or a video that\n // failed, replaces the <video> with a new one, muted.\n const withSound = !this.video.muted;\n this.video.failed = false;\n // Another Story, another product: its panel starts closed.\n this.productOpen = false;\n this.host.requestUpdate();\n await this.host.updateComplete;\n if (!this.isOpen) return;\n\n this.video.restart({ withSound });\n this.animateStep(delta);\n }\n\n /** Stops a step animation still running, leaving the CSS layout. */\n private cancelAnimations() {\n for (const animation of this.animations) animation.cancel();\n this.animations = [];\n }\n\n /**\n * The expanded step, as in the prototype: the video grows from the cover\n * of the Story it now shows, and the covers slide to their new places, the\n * previous Story's shrinking from the video's size. With two Stories, the\n * video and the other cover swap sides. Not with reduced motion, nor\n * without covers (narrow screens).\n */\n private animateStep(delta: number) {\n if (!this.expanded || delta === 0 || prefersReducedMotion()) return;\n\n const frame = this.stage.value;\n const dim = this.dim.value;\n if (!frame || !dim || typeof frame.animate !== \"function\") return;\n\n // Where each Story was before the step: the video (0), its cover's\n // offset, or, if it wasn't shown, `fallback`. Read from the Stories, not\n // from offset + delta: with wraparound (four Stories), a Story's offset\n // can change by more or less than the step.\n const { rendered, beforeStep } = this;\n const placeBefore = (story: StoryMedia | undefined, fallback: number) => {\n if (!story || !beforeStep) return fallback;\n if (story === beforeStep.story) return 0;\n const cover = beforeStep.neighbors.find((n) => n.story === story);\n return cover?.offset ?? fallback;\n };\n const neighbors = [...this.neighborElements].map(([offset, element]) => ({\n offset,\n element,\n from: placeBefore(\n rendered?.neighbors.find((n) => n.offset === offset)?.story,\n offset + delta,\n ),\n }));\n\n const sizes = {\n frameWidth: frame.offsetWidth,\n sideWidth: neighbors[0]?.element.offsetWidth ?? 0,\n };\n if (!sizes.frameWidth || !sizes.sideWidth) return;\n\n this.cancelAnimations();\n this.animations = [\n dim.animate([{ opacity: 1 }, { opacity: 0 }], STEP_ANIMATION),\n ...(this.pairDirection\n ? animatePairStep(\n frame,\n neighbors[0].element,\n this.pairDirection,\n sizes,\n )\n : animateRailStep(\n frame,\n placeBefore(rendered?.story, delta),\n neighbors,\n sizes,\n )),\n ];\n }\n\n // Keeps neighborElements in step with the covers Lit renders.\n private neighborRef(offset: number) {\n let callback = this.neighborRefs.get(offset);\n if (!callback) {\n callback = (element?: Element) => {\n if (element) this.neighborElements.set(offset, element as HTMLElement);\n else this.neighborElements.delete(offset);\n };\n this.neighborRefs.set(offset, callback);\n }\n return callback;\n }\n\n // Mini: a manual popover, or a non-modal dialog without popover support.\n // Expanded: a modal dialog.\n // Already showing: a second expand click in the same task resumes after the\n // first one has shown the dialog, and showing it again would throw.\n private show(dialog: HTMLDialogElement) {\n if (this.shown) return;\n if (this.expanded) dialog.showModal();\n else if (supportsPopover(dialog)) dialog.showPopover();\n else dialog.show();\n this.shown = true;\n }\n\n // A dialog can't be shown as a popover and as a modal at the same time, so\n // switching modes hides it first, the same way it was shown.\n private hide(dialog: HTMLDialogElement) {\n if (!this.shown) return;\n if (!this.expanded && supportsPopover(dialog)) dialog.hidePopover();\n else dialog.close();\n this.shown = false;\n }\n\n private readonly toggleExpanded = async () => {\n const dialog = this.dialog.value;\n if (!dialog) return;\n\n // A step animation would go on moving the video in the other mode.\n this.cancelAnimations();\n this.hide(dialog);\n this.expanded = !this.expanded;\n this.switched = true;\n this.host.requestUpdate();\n await this.host.updateComplete;\n\n if (!this.isOpen) return;\n this.show(dialog);\n this.expandButton.value?.focus();\n };\n\n // Escape anywhere on the page, also in the mini player, which is not modal.\n private readonly onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") this.options.onClose();\n };\n\n // With the focus in the player and more than one Story, the arrows step, as\n // the previous and next buttons do. Only there: the mini player leaves the\n // page usable, and the page's own arrow keys (a gallery, a slider) keep\n // working.\n private readonly onPlayerKeyDown = (event: KeyboardEvent) => {\n const delta = ARROW_STEPS[event.key];\n if (!delta || !this.navigation || !isFreeArrowKey(event)) return;\n\n // The arrow would also scroll the page.\n event.preventDefault();\n this.options.onStep?.(delta);\n };\n\n // Clicks on the backdrop of the expanded view reach the dialog itself.\n private readonly onDialogClick = (event: Event) => {\n if (this.expanded && event.target === event.currentTarget) {\n this.options.onClose();\n }\n };\n\n // Escape on a modal dialog would only hide it: close the player instead.\n private readonly onCancel = (event: Event) => {\n event.preventDefault();\n this.options.onClose();\n };\n\n /**\n * Play/pause in the middle of the video and sound on/off at its top right.\n * They follow the video's own events, so a blocked autoplay shows as\n * paused.\n */\n private readonly toggleProduct = () => {\n this.productOpen = !this.productOpen;\n this.host.requestUpdate();\n };\n\n /**\n * A click on the video: closes the product panel when it is open, plays or\n * pauses the video otherwise.\n */\n private readonly onVideoClick = () => {\n if (this.productOpen) this.toggleProduct();\n else this.video.togglePlayback();\n };\n\n /**\n * At the bottom of the video, the product pill, which opens the panel with\n * its actions, or the call to action of a link destination. Clicks on them\n * don't reach the video.\n */\n private renderDestination({ product, cta, labels }: StoryDestination) {\n let content;\n if (product) {\n content = renderExpandableProduct(product, {\n open: this.productOpen,\n onToggle: this.toggleProduct,\n panelId: \"player-product-panel\",\n labels,\n });\n } else if (cta) {\n content = renderCta(cta);\n } else {\n return nothing;\n }\n\n return html`\n <div\n class=\"player-destination\"\n @click=${(event: Event) => event.stopPropagation()}\n >\n ${content}\n </div>\n `;\n }\n\n private renderVideoControls(labels: StoryLabels) {\n const { video } = this;\n\n // Not a .player-button: it keeps the card's larger glass look.\n const onToggle = (event: Event) => {\n event.stopPropagation();\n video.togglePlayback();\n };\n const onSound = (event: Event) => {\n event.stopPropagation();\n video.toggleMuted();\n };\n\n return html`\n <button\n type=\"button\"\n class=\"play player-toggle\"\n aria-label=${video.paused ? labels.play : labels.pause}\n @click=${onToggle}\n >\n ${icon(video.paused ? \"play\" : \"pause\")}\n </button>\n <button\n type=\"button\"\n class=\"player-button player-sound\"\n aria-label=${video.muted ? labels.soundOn : labels.soundOff}\n @click=${onSound}\n >\n ${icon(video.muted ? \"soundOff\" : \"soundOn\")}\n </button>\n `;\n }\n\n /**\n * Previous and next Story: above the mini player's top left, beside the\n * expanded video.\n */\n private renderNavigation(labels: StoryLabels) {\n const { options } = this;\n const step = (delta: number) => () => options.onStep?.(delta);\n\n return html`\n <div class=\"player-controls player-nav\">\n <button\n type=\"button\"\n class=\"player-button player-previous\"\n aria-label=${labels.previous}\n @click=${step(-1)}\n >\n ${icon(\"previous\")}\n </button>\n <button\n type=\"button\"\n class=\"player-button player-next\"\n aria-label=${labels.next}\n @click=${step(1)}\n >\n ${icon(\"next\")}\n </button>\n </div>\n `;\n }\n\n /** The other Stories' covers beside the expanded video. */\n private renderNeighbors(\n neighbors: readonly PlayerNeighbor[],\n labels: StoryLabels,\n ) {\n const { options } = this;\n\n // With two Stories, the single cover's offset flips between 1 and -1 on\n // each step: a stable key keeps its button, and the focus on it.\n return repeat(\n neighbors,\n ({ offset }) => (neighbors.length === 1 ? \"single\" : offset),\n ({ offset, story, label }) => {\n const poster = httpUrl(story.poster_url);\n const side = Math.sign(offset);\n return html`\n <button\n type=\"button\"\n class=\"player-neighbor\"\n aria-label=${label ?? labels.show}\n style=${styleMap({\n \"--side\": String(side),\n \"--beyond\": String(offset - side),\n })}\n ${ref(this.neighborRef(offset))}\n @click=${() => options.onStep?.(offset)}\n >\n ${poster ? html`<img alt=\"\" src=${poster} />` : nothing}\n </button>\n `;\n },\n );\n }\n\n /** Expand or collapse, and close: above the video, or at the top right. */\n private renderWindowControls(labels: StoryLabels) {\n const { options, expanded } = this;\n\n return html`\n <div class=\"player-controls\">\n <button\n type=\"button\"\n class=\"player-button player-expand\"\n aria-label=${expanded ? labels.collapse : labels.expand}\n ${ref(this.expandButton)}\n @click=${this.toggleExpanded}\n >\n ${icon(expanded ? \"collapse\" : \"expand\")}\n </button>\n <button\n type=\"button\"\n class=\"player-button player-close\"\n aria-label=${labels.close}\n ${ref(this.closeButton)}\n @click=${options.onClose}\n >\n ${icon(\"close\")}\n </button>\n </div>\n `;\n }\n\n /**\n * The video with its controls and the product or call to action. With\n * `advances`, it plays once and moves on to the next Story when it ends;\n * otherwise it loops.\n */\n private renderVideo(\n story: StoryMedia,\n advances: boolean,\n destination: StoryDestination,\n ) {\n const { video, options } = this;\n\n return html`\n <div class=\"card\" ${ref(this.stageCardRef)} @click=${this.onVideoClick}>\n ${renderMedia(story, video, {\n loop: !advances,\n onEnded: advances ? () => options.onStep?.(1) : undefined,\n })}\n ${hasVideo(story, video)\n ? this.renderVideoControls(destination.labels)\n : nothing}\n ${this.renderDestination(destination)}\n </div>\n `;\n }\n\n /**\n * Keeps what this render shows, for the step animation: the covers beside\n * the video (only in the expanded view) and the side the video moves to\n * with two Stories. A new Story makes what was shown the animation's\n * start.\n */\n private track(story: StoryMedia, neighbors: readonly PlayerNeighbor[]) {\n const shown = this.expanded ? neighbors : [];\n this.pairDirection = shown.length === 1 ? -Math.sign(shown[0].offset) : 0;\n\n if (this.rendered && story !== this.rendered.story) {\n this.beforeStep = this.rendered;\n }\n this.rendered = { story, neighbors: shown };\n return shown;\n }\n\n /**\n * The player <dialog> while it is open. Clicking the video also plays or\n * pauses it, and keeps the focus in the player (the dialog is focusable,\n * though not by Tab), so the arrow keys still step. With `navigation`\n * (more than one Story), it has previous and next buttons and arrow keys,\n * and the expanded view moves on when the video ends instead of looping.\n * The expanded view also shows the `neighbors` beside it.\n */\n render(\n story: StoryMedia,\n {\n labels,\n navigation = false,\n neighbors = [],\n product,\n cta,\n onPress,\n }: PlayerRenderOptions,\n ) {\n if (!this.isOpen) return nothing;\n\n const { video, expanded } = this;\n const shownNeighbors = this.track(story, neighbors);\n const pair = this.pairDirection !== 0;\n this.navigation = navigation;\n\n return html`\n <dialog\n class=\"player\"\n popover=\"manual\"\n aria-label=${labels.player}\n ?data-expanded=${expanded}\n ?data-pair=${pair}\n style=${styleMap({\n \"--pair-dir\": pair ? String(this.pairDirection) : undefined,\n })}\n ?data-switched=${this.switched}\n ?data-paused=${hasVideo(story, video) && video.paused}\n tabindex=\"-1\"\n ${ref(this.dialog)}\n @click=${this.onDialogClick}\n @cancel=${this.onCancel}\n @keydown=${this.onPlayerKeyDown}\n >\n ${this.renderNeighbors(shownNeighbors, labels)}\n <div class=\"player-frame\">\n ${this.renderWindowControls(labels)}\n <div\n class=\"player-stage\"\n ${ref(this.stage)}\n @click=${{\n handleEvent: (event: Event) => {\n const card = this.stageCardRef.value;\n if (card?.contains(event.target as Node)) onPress?.();\n },\n capture: true,\n }}\n >\n ${navigation ? this.renderNavigation(labels) : nothing}\n ${this.renderVideo(story, navigation && expanded, {\n product,\n cta,\n labels,\n })}\n <span class=\"player-dim\" aria-hidden=\"true\" ${ref(this.dim)}></span>\n </div>\n </div>\n </dialog>\n `;\n }\n}\n","import {\n hydrateAds,\n intelligentSearchAvailability,\n intelligentSearchFetcher,\n intelligentSearchMatcher,\n intelligentSearchPrice,\n type Identity,\n type Offer,\n type Product,\n type ProductFetcher,\n type ProductPrice,\n} from \"@vtex/ads-core\";\nimport { TAG_NAME } from \"../tag-name\";\nimport type { StoryAd } from \"../types\";\nimport { withTimeout } from \"./with-timeout\";\n\nconst DEFAULT_HYDRATION_TIMEOUT_MS = 5000;\n\n/**\n * Where the element gets its products' details: a fetcher and a matcher, as\n * in `@vtex/ads-core`, and a reader for the price of a fetched product.\n */\nexport interface StoryHydration<TProduct extends object = object> {\n fetcher: ProductFetcher<TProduct>;\n matcher(product: TProduct, offer: Offer): boolean;\n price(product: TProduct, offer: Offer): ProductPrice | undefined;\n /** Whether the product can be bought. Without it, it isn't checked. */\n available?(product: TProduct, offer: Offer): boolean | undefined;\n}\n\nexport const intelligentSearchHydration: StoryHydration<Product> = {\n fetcher: intelligentSearchFetcher,\n matcher: intelligentSearchMatcher,\n price: intelligentSearchPrice,\n available: intelligentSearchAvailability,\n};\n\nexport interface StoryProductDetails {\n price?: ProductPrice;\n /** Missing when the strategy doesn't say. */\n available?: boolean;\n}\n\nexport interface HydrateProductsOptions {\n signal?: AbortSignal;\n timeout?: number;\n}\n\nexport async function hydrateStoryProducts(\n placement: string,\n stories: StoryAd[],\n hydration: StoryHydration,\n identity: Identity,\n { signal, timeout }: HydrateProductsOptions = {},\n): Promise<Map<string, StoryProductDetails>> {\n const products = new Map<string, StoryProductDetails>();\n const limit = withTimeout(timeout, DEFAULT_HYDRATION_TIMEOUT_MS, signal);\n\n try {\n const hydrated = await hydrateAds(\n { stories: { [placement]: stories } },\n hydration.fetcher,\n (product, offer) => hydration.matcher(product, offer),\n identity,\n { signal: limit.signal },\n );\n\n for (const { story, product, offer } of hydrated.stories[placement] ?? []) {\n if (!product || !offer) continue;\n const price = hydration.price(product, offer);\n const available = hydration.available?.(product, offer);\n products.set(story.ad_id, {\n ...(price && { price }),\n ...(available !== undefined && { available }),\n });\n }\n } catch (error) {\n // As for the Story request: a cancelled or timed out request needs no\n // log, any other failure does.\n if (!limit.signal.aborted) {\n console.error(`[${TAG_NAME}] Product request failed`, error);\n }\n } finally {\n limit.clear();\n }\n\n return products;\n}\n","/**\n * A signal that aborts when the caller's signal aborts or after `timeout`\n * milliseconds, whichever comes first. A `timeout` missing, zero, negative or\n * not a number uses `fallback`. Built by hand instead of with\n * `AbortSignal.any` and `AbortSignal.timeout`, which older browsers lack.\n *\n * Call `clear()` once the work is done, so the timer and the listener on the\n * caller's signal don't outlive it.\n */\nexport const withTimeout = (\n timeout: number | undefined,\n fallback: number,\n signal?: AbortSignal,\n): { signal: AbortSignal; clear: () => void } => {\n const ms =\n timeout !== undefined && Number.isFinite(timeout) && timeout > 0\n ? timeout\n : fallback;\n const controller = new AbortController();\n\n const timer = setTimeout(\n () =>\n controller.abort(\n new DOMException(`Timed out after ${ms} ms`, \"TimeoutError\"),\n ),\n ms,\n );\n const onAbort = () => controller.abort(signal?.reason);\n\n if (signal?.aborted) {\n onAbort();\n } else {\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n }\n\n return {\n signal: controller.signal,\n clear: () => {\n clearTimeout(timer);\n signal?.removeEventListener(\"abort\", onAbort);\n },\n };\n};\n","import { getRawAds, type Channel } from \"@vtex/ads-core\";\nimport { TAG_NAME } from \"../tag-name\";\nimport type { StoryAd } from \"../types\";\nimport { withTimeout } from \"./with-timeout\";\n\n/**\n * Default time limit for the Story request, in milliseconds. A card that\n * shows up later than this would appear well after the page loaded.\n */\nexport const DEFAULT_TIMEOUT_MS = 2000;\n\n/**\n * How many Stories the element asks for.\n */\nexport const DEFAULT_QUANTITY = 8;\n\n/** What the element sends to the ad API. */\nexport interface StoryRequest {\n /** Required. */\n publisherId?: string;\n /** Required. */\n sessionId?: string;\n /** Required. */\n placement?: string;\n userId?: string;\n accountName?: string;\n channel?: Channel;\n /**\n * How many Stories to ask for: the carousel positions. Missing, below 1 or\n * not a number: DEFAULT_QUANTITY. A fraction is rounded down.\n */\n quantity?: number;\n}\n\nexport interface FetchStoryOptions {\n /** Cancels the request. */\n signal?: AbortSignal;\n /**\n * Time limit in milliseconds. Missing, zero, negative or not a number:\n * DEFAULT_TIMEOUT_MS.\n */\n timeout?: number;\n}\n\nconst toQuantity = (quantity?: number) =>\n quantity !== undefined && Number.isFinite(quantity) && quantity >= 1\n ? Math.floor(quantity)\n : DEFAULT_QUANTITY;\n\n/**\n * Requests up to `quantity` Stories for the placement from the ad API, in\n * the order the ad API returns them.\n *\n * Resolves to an empty list, without throwing, when a required value is\n * missing, during server-side rendering, when the request fails, is cancelled\n * or takes longer than the time limit, or when the placement has no Story.\n */\nexport async function fetchStories(\n {\n publisherId,\n sessionId,\n placement,\n userId,\n accountName,\n channel,\n quantity,\n }: StoryRequest,\n { signal, timeout }: FetchStoryOptions = {},\n): Promise<StoryAd[]> {\n // No request during server-side rendering, where nothing renders. Not\n // Lit's isServer: it is also true in Node with a DOM, as in the tests.\n const onServer = globalThis.window === undefined;\n if (onServer || !publisherId || !sessionId || !placement) return [];\n\n const limit = withTimeout(timeout, DEFAULT_TIMEOUT_MS, signal);\n const count = toQuantity(quantity);\n\n try {\n const { stories } = await getRawAds(\n {\n identity: {\n accountName: accountName ?? \"\",\n publisherId,\n sessionId,\n userId,\n channel,\n },\n search: {},\n placements: {\n [placement]: { quantity: count, types: [\"story\"] },\n },\n },\n { signal: limit.signal },\n );\n\n // The ad API may send more than asked for: only the first ones fit.\n return (stories[placement] ?? []).slice(0, count);\n } catch (error) {\n // A cancelled or timed out request needs no log. Anything else (network\n // failure, HTTP or validation error) is logged, so a failing request can\n // be told apart from a placement with no Story.\n if (!limit.signal.aborted) {\n console.error(`[${TAG_NAME}] Story request failed`, {\n placement,\n publisherId,\n error,\n });\n }\n return [];\n } finally {\n limit.clear();\n }\n}\n","import type { StoryLabels } from \"./types\";\n\n/** The texts in English. */\nexport const en: StoryLabels = {\n watch: \"Watch video\",\n show: \"Show video\",\n carousel: \"Videos\",\n carouselRole: \"carousel\",\n previous: \"Previous video\",\n next: \"Next video\",\n player: \"Video\",\n expand: \"Expand video\",\n collapse: \"Collapse video\",\n close: \"Close video\",\n play: \"Play video\",\n pause: \"Pause video\",\n soundOn: \"Turn sound on\",\n soundOff: \"Turn sound off\",\n addToCart: \"Add to cart\",\n unavailable: \"Product unavailable\",\n soldOut: \"Sold out\",\n viewProduct: \"View product\",\n product: (name, price, listPrice) => {\n if (price && listPrice) return `${name}, was ${listPrice}, now ${price}`;\n return price ? `${name}, ${price}` : name;\n },\n position: (label, index, count) =>\n count > 1 ? `${label} ${index + 1} of ${count}` : label,\n};\n","import type { StoryLabels } from \"./types\";\n\n/** The texts in Spanish. */\nexport const es: StoryLabels = {\n watch: \"Ver video\",\n show: \"Mostrar video\",\n carousel: \"Videos\",\n carouselRole: \"carrusel\",\n previous: \"Video anterior\",\n next: \"Video siguiente\",\n player: \"Video\",\n expand: \"Ampliar video\",\n collapse: \"Reducir video\",\n close: \"Cerrar video\",\n play: \"Reproducir video\",\n pause: \"Pausar video\",\n soundOn: \"Activar sonido\",\n soundOff: \"Desactivar sonido\",\n addToCart: \"Agregar al carrito\",\n unavailable: \"Producto no disponible\",\n soldOut: \"Agotado\",\n viewProduct: \"Ver producto\",\n product: (name, price, listPrice) => {\n if (price && listPrice)\n return `${name}, antes ${listPrice}, ahora ${price}`;\n return price ? `${name}, ${price}` : name;\n },\n position: (label, index, count) =>\n count > 1 ? `${label} ${index + 1} de ${count}` : label,\n};\n","import type { StoryLabels } from \"./types\";\n\n/** The texts in Portuguese, the default. */\nexport const pt: StoryLabels = {\n watch: \"Assistir vídeo\",\n show: \"Mostrar vídeo\",\n carousel: \"Vídeos\",\n carouselRole: \"carrossel\",\n previous: \"Vídeo anterior\",\n next: \"Próximo vídeo\",\n player: \"Vídeo\",\n expand: \"Expandir vídeo\",\n collapse: \"Reduzir vídeo\",\n close: \"Fechar vídeo\",\n play: \"Reproduzir vídeo\",\n pause: \"Pausar vídeo\",\n soundOn: \"Ativar som\",\n soundOff: \"Desativar som\",\n addToCart: \"Adicionar ao carrinho\",\n unavailable: \"Produto indisponível\",\n soldOut: \"Esgotado\",\n viewProduct: \"Ver produto\",\n product: (name, price, listPrice) => {\n if (price && listPrice) return `${name}, de ${listPrice} por ${price}`;\n return price ? `${name}, ${price}` : name;\n },\n position: (label, index, count) =>\n count > 1 ? `${label} ${index + 1} de ${count}` : label,\n};\n","import { en } from \"./en\";\nimport { es } from \"./es\";\nimport { pt } from \"./pt\";\nimport type { StoryLabels } from \"./types\";\n\nexport type { StoryLabels } from \"./types\";\nexport { en } from \"./en\";\nexport { es } from \"./es\";\nexport { pt } from \"./pt\";\n\nexport interface StoryLabelOverrides {\n addToCart?: string;\n viewProduct?: string;\n}\n\nconst BY_LANGUAGE = new Map<string, StoryLabels>([\n [\"pt\", pt],\n [\"es\", es],\n [\"en\", en],\n]);\n\nexport function labelsFor(\n locale: string,\n overrides: StoryLabelOverrides = {},\n): StoryLabels {\n const language = locale.split(\"-\")[0].toLowerCase();\n const labels = BY_LANGUAGE.get(language) ?? pt;\n const addToCart = overrides.addToCart?.trim();\n const viewProduct = overrides.viewProduct?.trim();\n\n return {\n ...labels,\n ...(addToCart && { addToCart }),\n ...(viewProduct && { viewProduct }),\n };\n}\n"],"mappings":";AAAA,SAAS,OAAAA,MAAK,QAAAC,OAAM,YAAY,WAAAC,gBAAoC;;;ACApE,SAAS,OAAAC,MAAK,QAAAC,OAAM,WAAAC,gBAAe;AACnC,SAAS,OAAAC,YAA+B;;;ACExC;AAAA,EACE;AAAA,OAEK;;;ACNP;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;AVsBO,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKA,IAAM,SAAS,OAAO;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A,QAE9D,KAAK,OAAO,OAAO,QAAQ;AAAA,MAC3B,QAAQ,KAAK;AAAA,MACb,YAAY,QAAQ,SAAS;AAAA,MAC7B;AAAA,MACA,SAAS,KAAK,UAAU,MAAM;AAAA,MAC9B,KAAK,UAAU,MAAM;AAAA,MACrB,SAAS,MAAM,KAAK,OAAO,MAAM,MAAM;AAAA,IACzC,CAAC,CAAC;AAAA;AAAA,EAEN;AACF;AA3da,4BACK,aAAa;AAAA,EAC3B,aAAa,EAAE,WAAW,eAAe;AAAA,EACzC,WAAW,EAAE,WAAW,aAAa;AAAA,EACrC,WAAW,CAAC;AAAA,EACZ,QAAQ,EAAE,WAAW,UAAU;AAAA,EAC/B,aAAa,EAAE,WAAW,eAAe;AAAA,EACzC,SAAS,EAAE,WAAW,iBAAiB;AAAA,EACvC,SAAS,EAAE,MAAM,OAAO;AAAA,EACxB,UAAU,EAAE,MAAM,OAAO;AAAA,EACzB,UAAU,CAAC;AAAA,EACX,gBAAgB,EAAE,WAAW,oBAAoB;AAAA,EACjD,kBAAkB,EAAE,WAAW,qBAAqB;AAAA,EACpD,WAAW,EAAE,WAAW,mBAAmB;AAAA,EAC3C,kBAAkB,EAAE,MAAM,QAAQ,WAAW,oBAAoB;AAAA,EACjE,kBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AAAA,EACA,SAAS,EAAE,OAAO,KAAK;AAAA,EACvB,UAAU,EAAE,OAAO,KAAK;AAC1B;AAtBW,4BA+FK,SAAS;AAAA,EACvBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA2XK,SAAS,6BAA6B;AAC3C,MAAI,OAAO,mBAAmB,YAAa;AAC3C,MAAI,eAAe,IAAI,QAAQ,EAAG;AAElC,iBAAe,OAAO,UAAU,2BAA2B;AAC7D;","names":["css","html","nothing","css","html","nothing","ref","html","nothing","html","nothing","html","html","css","html","ref","_a","nothing","css","html","css","html","css","html","nothing","createRef","ref","repeat","styleMap","css","createRef","_a","nothing","html","repeat","styleMap","ref","nothing","html","css"]}
|