@vtex/ads-stories 0.3.0 → 0.4.1

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @vtex/ads-stories
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 47bdafb: `<vtex-ads-story>` is now built with Lit. It looks and behaves the same in the browser; `lit` is a new dependency of the npm package (bundled in the CJS build and in the CDN script). In Node (SSR), importing the package now installs Lit's DOM shim, so `globalThis.customElements` is defined there.
8
+ - 46b3798: The card's sound on/off button now only shows while the card's video plays. It no longer shows when the video doesn't play: for people who prefer reduced motion, when the browser blocks autoplay (as iOS Low Power Mode does), and while the player is open.
9
+
10
+ ## 0.4.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 2c00914: `<vtex-ads-story>` now plays the Story's video. For now it renders one fixed test Story from public URLs, until the carousel passes in Stories from the ad API. The card loops the video muted over the cover (not for people who prefer reduced motion), with a sound on/off button at its top right, and pauses while the player is open. The player plays it muted, with play/pause in the middle (also by clicking the video) and a sound on/off button at the top right. If the video can't load, the cover stays and the video controls are hidden.
15
+
3
16
  ## 0.3.0
4
17
 
5
18
  ### Minor Changes
package/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  VTEX Ads Stories web component. Framework-agnostic: works on any HTML5 page,
4
4
  including VTEX IO, FastStore and non-VTEX storefronts.
5
5
 
6
- > Work in progress. Currently renders one placeholder 9:16 card that opens in a
7
- > player at the bottom right; video and Stories from the ad API come next.
6
+ > Work in progress. Currently renders one fixed test Story, which opens in a
7
+ > player at the bottom right. The carousel, fed by the ad API, comes next.
8
8
 
9
9
  ## npm
10
10
 
@@ -24,10 +24,18 @@ defineVtexAdsStories();
24
24
  <vtex-ads-story></vtex-ads-story>
25
25
  ```
26
26
 
27
- Importing the package has no side effects: nothing is registered until
28
- `defineVtexAdsStories()` is called. It can be imported during server-side
29
- rendering, where `defineVtexAdsStories()` does nothing. Both ESM (`import`) and
30
- CommonJS (`require`) builds are published, with type declarations.
27
+ Importing the package registers nothing: the element is only registered when
28
+ `defineVtexAdsStories()` is called. Both ESM (`import`) and CommonJS
29
+ (`require`) builds are published, with type declarations.
30
+
31
+ The package can be imported during server-side rendering (for example in
32
+ FastStore, which is Next.js). The element is built with
33
+ [Lit](https://lit.dev), and in Node Lit installs a minimal DOM shim, so after
34
+ the import `globalThis.customElements` is defined on the server too. Don't use
35
+ `typeof customElements` to tell the server from the browser; use
36
+ `typeof window` instead. Calling `defineVtexAdsStories()` on the server is
37
+ safe: it registers the element in Lit's server-side registry and renders
38
+ nothing.
31
39
 
32
40
  ### TypeScript and React
33
41
 
@@ -1,8 +1,33 @@
1
- "use strict";var VtexAdsStories=(()=>{var u=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var T=(r,t)=>{for(var e in t)u(r,e,{get:t[e],enumerable:!0})},N=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of V(t))!P.call(r,o)&&o!==e&&u(r,o,{get:()=>t[o],enumerable:!(a=C(t,o))||a.enumerable});return r};var Z=r=>N(u({},"__esModule",{value:!0}),r);var K={};T(K,{TAG_NAME:()=>c,VtexAdsStoryElement:()=>l,defineVtexAdsStories:()=>h});var v=`<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>
2
- `;var w=`<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>
3
- `;var E=`<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>
4
- `;var A=`<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>
5
- `;var I={close:v,collapse:w,expand:E,play:A};function i(r){let t=document.createElement("template");t.innerHTML=I[r];let e=t.content.firstElementChild;return e.classList.add("icon"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false"),e}var x=`
1
+ "use strict";var VtexAdsStories=(()=>{var pe=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var ft=(i,e)=>{for(var t in e)pe(i,t,{get:e[t],enumerable:!0})},mt=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ct(e))!ut.call(i,o)&&o!==t&&pe(i,o,{get:()=>e[o],enumerable:!(s=pt(e,o))||s.enumerable});return i};var yt=i=>mt(pe({},"__esModule",{value:!0}),i);var Dt={};ft(Dt,{TAG_NAME:()=>F,VtexAdsStoryElement:()=>O,defineVtexAdsStories:()=>Y});var Q=globalThis,X=Q.ShadowRoot&&(Q.ShadyCSS===void 0||Q.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ce=Symbol(),Me=new WeakMap,R=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==ce)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(X&&e===void 0){let s=t!==void 0&&t.length===1;s&&(e=Me.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&Me.set(t,e))}return e}toString(){return this.cssText}},Te=i=>new R(typeof i=="string"?i:i+"",void 0,ce),x=(i,...e)=>{let t=i.length===1?i[0]:e.reduce((s,o,r)=>s+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+i[r+1],i[0]);return new R(t,i,ce)},Le=(i,e)=>{if(X)i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let s=document.createElement("style"),o=Q.litNonce;o!==void 0&&s.setAttribute("nonce",o),s.textContent=t.cssText,i.appendChild(s)}},ue=X?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(let s of e.cssRules)t+=s.cssText;return Te(t)})(i):i;var{is:gt,defineProperty:$t,getOwnPropertyDescriptor:vt,getOwnPropertyNames:_t,getOwnPropertySymbols:bt,getPrototypeOf:At}=Object,_=globalThis,Oe=_.trustedTypes,xt=Oe?Oe.emptyScript:"",fe=_.reactiveElementPolyfillSupport,U=(i,e)=>i,me={toAttribute(i,e){switch(e){case Boolean:i=i?xt:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch(s){t=null}}return t}},Re=(i,e)=>!gt(i,e),Pe={attribute:!0,type:String,converter:me,reflect:!1,useDefault:!1,hasChanged:Re},He,Ve;(He=Symbol.metadata)!=null||(Symbol.metadata=Symbol("metadata")),(Ve=_.litPropertyMetadata)!=null||(_.litPropertyMetadata=new WeakMap);var y=class extends HTMLElement{static addInitializer(e){var t;this._$Ei(),((t=this.l)!=null?t:this.l=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Pe){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let s=Symbol(),o=this.getPropertyDescriptor(e,s,t);o!==void 0&&$t(this.prototype,e,o)}}static getPropertyDescriptor(e,t,s){var n;let{get:o,set:r}=(n=vt(this.prototype,e))!=null?n:{get(){return this[t]},set(l){this[t]=l}};return{get:o,set(l){let a=o==null?void 0:o.call(this);r==null||r.call(this,l),this.requestUpdate(e,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){var t;return(t=this.elementProperties.get(e))!=null?t:Pe}static _$Ei(){if(this.hasOwnProperty(U("elementProperties")))return;let e=At(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(U("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(U("properties"))){let t=this.properties,s=[..._t(t),...bt(t)];for(let o of s)this.createProperty(o,t[o])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[s,o]of t)this.elementProperties.set(s,o)}this._$Eh=new Map;for(let[t,s]of this.elementProperties){let o=this._$Eu(t,s);o!==void 0&&this._$Eh.set(o,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let s=new Set(e.flat(1/0).reverse());for(let o of s)t.unshift(ue(o))}else e!==void 0&&t.push(ue(e));return t}static _$Eu(e,t){let s=t.attribute;return s===!1?void 0:typeof s=="string"?s:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t,s;((t=this._$EO)!=null?t:this._$EO=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&((s=e.hostConnected)==null||s.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let s of t.keys())this.hasOwnProperty(s)&&(e.set(s,this[s]),delete this[s]);e.size>0&&(this._$Ep=e)}createRenderRoot(){var t;let e=(t=this.shadowRoot)!=null?t:this.attachShadow(this.constructor.shadowRootOptions);return Le(e,this.constructor.elementStyles),e}connectedCallback(){var e,t;(e=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(s=>{var o;return(o=s.hostConnected)==null?void 0:o.call(s)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var s;return(s=t.hostDisconnected)==null?void 0:s.call(t)})}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$ET(e,t){var r;let s=this.constructor.elementProperties.get(e),o=this.constructor._$Eu(e,s);if(o!==void 0&&s.reflect===!0){let n=(((r=s.converter)==null?void 0:r.toAttribute)!==void 0?s.converter:me).toAttribute(t,s.type);this._$Em=e,n==null?this.removeAttribute(o):this.setAttribute(o,n),this._$Em=null}}_$AK(e,t){var r,n,l;let s=this.constructor,o=s._$Eh.get(e);if(o!==void 0&&this._$Em!==o){let a=s.getPropertyOptions(o),d=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)==null?void 0:r.fromAttribute)!==void 0?a.converter:me;this._$Em=o;let p=d.fromAttribute(t,a.type);this[o]=(l=p!=null?p:(n=this._$Ej)==null?void 0:n.get(o))!=null?l:p,this._$Em=null}}requestUpdate(e,t,s,o=!1,r){var n,l;if(e!==void 0){let a=this.constructor;if(o===!1&&(r=this[e]),s!=null||(s=a.getPropertyOptions(e)),!(((n=s.hasChanged)!=null?n:Re)(r,t)||s.useDefault&&s.reflect&&r===((l=this._$Ej)==null?void 0:l.get(e))&&!this.hasAttribute(a._$Eu(e,s))))return;this.C(e,t,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:s,reflect:o,wrapped:r},n){var l,a,d;s&&!((l=this._$Ej)!=null?l:this._$Ej=new Map).has(e)&&(this._$Ej.set(e,(a=n!=null?n:t)!=null?a:this[e]),r!==!0||n!==void 0)||(this._$AL.has(e)||(this.hasUpdated||s||(t=void 0),this._$AL.set(e,t)),o===!0&&this._$Em!==e&&((d=this._$Eq)!=null?d:this._$Eq=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s,o;if(!this.isUpdatePending)return;if(!this.hasUpdated){if((s=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[n,l]of this._$Ep)this[n]=l;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[n,l]of r){let{wrapped:a}=l,d=this[n];a!==!0||this._$AL.has(n)||d===void 0||this.C(n,void 0,l,d)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(o=this._$EO)==null||o.forEach(r=>{var n;return(n=r.hostUpdate)==null?void 0:n.call(r)}),this.update(t)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(s=>{var o;return(o=s.hostUpdated)==null?void 0:o.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}},ke;y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[U("elementProperties")]=new Map,y[U("finalized")]=new Map,fe==null||fe({ReactiveElement:y}),((ke=_.reactiveElementVersions)!=null?ke:_.reactiveElementVersions=[]).push("2.1.2");var D=globalThis,Ue=i=>i,ee=D.trustedTypes,Ne=ee?ee.createPolicy("lit-html",{createHTML:i=>i}):void 0,$e="$lit$",g=`lit$${Math.random().toFixed(9).slice(2)}$`,ve="?"+g,wt=`<${ve}>`,C=document,B=()=>C.createComment(""),I=i=>i===null||typeof i!="object"&&typeof i!="function",_e=Array.isArray,Ge=i=>_e(i)||typeof(i==null?void 0:i[Symbol.iterator])=="function",ye=`[
2
+ \f\r]`,N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,De=/-->/g,Be=/>/g,w=RegExp(`>|${ye}(?:([^\\s"'>=/]+)(${ye}*=${ye}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ie=/'/g,ze=/"/g,qe=/^(?:script|style|textarea|title)$/i,be=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),u=be(1),Gt=be(2),qt=be(3),$=Symbol.for("lit-noChange"),h=Symbol.for("lit-nothing"),je=new WeakMap,E=C.createTreeWalker(C,129);function We(i,e){if(!_e(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ne!==void 0?Ne.createHTML(e):e}var Ke=(i,e)=>{let t=i.length-1,s=[],o,r=e===2?"<svg>":e===3?"<math>":"",n=N;for(let l=0;l<t;l++){let a=i[l],d,p,c=-1,m=0;for(;m<a.length&&(n.lastIndex=m,p=n.exec(a),p!==null);)m=n.lastIndex,n===N?p[1]==="!--"?n=De:p[1]!==void 0?n=Be:p[2]!==void 0?(qe.test(p[2])&&(o=RegExp("</"+p[2],"g")),n=w):p[3]!==void 0&&(n=w):n===w?p[0]===">"?(n=o!=null?o:N,c=-1):p[1]===void 0?c=-2:(c=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?w:p[3]==='"'?ze:Ie):n===ze||n===Ie?n=w:n===De||n===Be?n=N:(n=w,o=void 0);let v=n===w&&i[l+1].startsWith("/>")?" ":"";r+=n===N?a+wt:c>=0?(s.push(d),a.slice(0,c)+$e+a.slice(c)+g+v):a+g+(c===-2?l:v)}return[We(i,r+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),s]},z=class i{constructor({strings:e,_$litType$:t},s){let o;this.parts=[];let r=0,n=0,l=e.length-1,a=this.parts,[d,p]=Ke(e,t);if(this.el=i.createElement(d,s),E.currentNode=this.el.content,t===2||t===3){let c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(o=E.nextNode())!==null&&a.length<l;){if(o.nodeType===1){if(o.hasAttributes())for(let c of o.getAttributeNames())if(c.endsWith($e)){let m=p[n++],v=o.getAttribute(c).split(g),J=/([.?@])?(.*)/.exec(m);a.push({type:1,index:r,name:J[2],strings:v,ctor:J[1]==="."?se:J[1]==="?"?ie:J[1]==="@"?oe:M}),o.removeAttribute(c)}else c.startsWith(g)&&(a.push({type:6,index:r}),o.removeAttribute(c));if(qe.test(o.tagName)){let c=o.textContent.split(g),m=c.length-1;if(m>0){o.textContent=ee?ee.emptyScript:"";for(let v=0;v<m;v++)o.append(c[v],B()),E.nextNode(),a.push({type:2,index:++r});o.append(c[m],B())}}}else if(o.nodeType===8)if(o.data===ve)a.push({type:2,index:r});else{let c=-1;for(;(c=o.data.indexOf(g,c+1))!==-1;)a.push({type:7,index:r}),c+=g.length-1}r++}}static createElement(e,t){let s=C.createElement("template");return s.innerHTML=e,s}};function S(i,e,t=i,s){var n,l,a;if(e===$)return e;let o=s!==void 0?(n=t._$Co)==null?void 0:n[s]:t._$Cl,r=I(e)?void 0:e._$litDirective$;return(o==null?void 0:o.constructor)!==r&&((l=o==null?void 0:o._$AO)==null||l.call(o,!1),r===void 0?o=void 0:(o=new r(i),o._$AT(i,t,s)),s!==void 0?((a=t._$Co)!=null?a:t._$Co=[])[s]=o:t._$Cl=o),o!==void 0&&(e=S(i,o._$AS(i,e.values),o,s)),e}var te=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var d;let{el:{content:t},parts:s}=this._$AD,o=((d=e==null?void 0:e.creationScope)!=null?d:C).importNode(t,!0);E.currentNode=o;let r=E.nextNode(),n=0,l=0,a=s[0];for(;a!==void 0;){if(n===a.index){let p;a.type===2?p=new P(r,r.nextSibling,this,e):a.type===1?p=new a.ctor(r,a.name,a.strings,this,e):a.type===6&&(p=new re(r,this,e)),this._$AV.push(p),a=s[++l]}n!==(a==null?void 0:a.index)&&(r=E.nextNode(),n++)}return E.currentNode=C,o}p(e){let t=0;for(let s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}},P=class i{get _$AU(){var e,t;return(t=(e=this._$AM)==null?void 0:e._$AU)!=null?t:this._$Cv}constructor(e,t,s,o){var r;this.type=2,this._$AH=h,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=o,this._$Cv=(r=o==null?void 0:o.isConnected)!=null?r:!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=S(this,e,t),I(e)?e===h||e==null||e===""?(this._$AH!==h&&this._$AR(),this._$AH=h):e!==this._$AH&&e!==$&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Ge(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==h&&I(this._$AH)?this._$AA.nextSibling.data=e:this.T(C.createTextNode(e)),this._$AH=e}$(e){var r;let{values:t,_$litType$:s}=e,o=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=z.createElement(We(s.h,s.h[0]),this.options)),s);if(((r=this._$AH)==null?void 0:r._$AD)===o)this._$AH.p(t);else{let n=new te(o,this),l=n.u(this.options);n.p(t),this.T(l),this._$AH=n}}_$AC(e){let t=je.get(e.strings);return t===void 0&&je.set(e.strings,t=new z(e)),t}k(e){_e(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,s,o=0;for(let r of e)o===t.length?t.push(s=new i(this.O(B()),this.O(B()),this,this.options)):s=t[o],s._$AI(r),o++;o<t.length&&(this._$AR(s&&s._$AB.nextSibling,o),t.length=o)}_$AR(e=this._$AA.nextSibling,t){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,t);e!==this._$AB;){let o=Ue(e).nextSibling;Ue(e).remove(),e=o}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},M=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,s,o,r){this.type=1,this._$AH=h,this._$AN=void 0,this.element=e,this.name=t,this._$AM=o,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=h}_$AI(e,t=this,s,o){let r=this.strings,n=!1;if(r===void 0)e=S(this,e,t,0),n=!I(e)||e!==this._$AH&&e!==$,n&&(this._$AH=e);else{let l=e,a,d;for(e=r[0],a=0;a<r.length-1;a++)d=S(this,l[s+a],t,a),d===$&&(d=this._$AH[a]),n||(n=!I(d)||d!==this._$AH[a]),d===h?e=h:e!==h&&(e+=(d!=null?d:"")+r[a+1]),this._$AH[a]=d}n&&!o&&this.j(e)}j(e){e===h?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e!=null?e:"")}},se=class extends M{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===h?void 0:e}},ie=class extends M{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==h)}},oe=class extends M{constructor(e,t,s,o,r){super(e,t,s,o,r),this.type=5}_$AI(e,t=this){var n;if((e=(n=S(this,e,t,0))!=null?n:h)===$)return;let s=this._$AH,o=e===h&&s!==h||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==h&&(s===h||o);o&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,s;typeof this._$AH=="function"?this._$AH.call((s=(t=this.options)==null?void 0:t.host)!=null?s:this.element,e):this._$AH.handleEvent(e)}},re=class{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){S(this,e)}},Fe={M:$e,P:g,A:ve,C:1,L:Ke,R:te,D:Ge,V:S,I:P,H:M,N:ie,U:oe,B:se,F:re},ge=D.litHtmlPolyfillSupport,Ze;ge==null||ge(z,P),((Ze=D.litHtmlVersions)!=null?Ze:D.litHtmlVersions=[]).push("3.3.3");var Ye=(i,e,t)=>{var r,n;let s=(r=t==null?void 0:t.renderBefore)!=null?r:e,o=s._$litPart$;if(o===void 0){let l=(n=t==null?void 0:t.renderBefore)!=null?n:null;s._$litPart$=o=new P(e.insertBefore(B(),l),l,void 0,t!=null?t:{})}return o._$AI(i),o};var T=globalThis,b=class extends y{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,s;let e=super.createRenderRoot();return(s=(t=this.renderOptions).renderBefore)!=null||(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Ye(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return $}},Je;b._$litElement$=!0,b.finalized=!0,(Je=T.litElementHydrateSupport)==null||Je.call(T,{LitElement:b});var Ae=T.litElementPolyfillSupport;Ae==null||Ae({LitElement:b});var Qe;((Qe=T.litElementVersions)!=null?Qe:T.litElementVersions=[]).push("4.2.2");var ne={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},j=i=>(...e)=>({_$litDirective$:i,values:e}),H=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,s){this._$Ct=e,this._$AM=t,this._$Ci=s}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var Z=class extends H{constructor(e){if(super(e),this.it=h,e.type!==ne.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===h||e==null)return this._t=void 0,this.it=e;if(e===$)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};Z.directiveName="unsafeHTML",Z.resultType=1;var Xe=j(Z);var et=`<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>
4
+ `;var tt=`<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>
5
+ `;var st=`<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>
6
+ `;var it=`<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>
7
+ `;var ot=`<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>
8
+ `;var rt=`<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>
9
+ `;var nt=`<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>
10
+ `;var Pt={close:et,collapse:tt,expand:st,pause:it,play:ot,soundOff:rt,soundOn:nt},Ht=Object.fromEntries(Object.entries(Pt).map(([i,e])=>[i,e.replace("<svg",'<svg class="icon" aria-hidden="true" focusable="false"')]));function A(i){return Xe(Ht[i])}var{I:Ms}=Fe;var at=i=>i.strings===void 0;var G=(i,e)=>{var s;let t=i._$AN;if(t===void 0)return!1;for(let o of t)(s=o._$AO)==null||s.call(o,e,!1),G(o,e);return!0},ae=i=>{let e,t;do{if((e=i._$AM)===void 0)break;t=e._$AN,t.delete(i),i=e}while((t==null?void 0:t.size)===0)},lt=i=>{for(let e;e=i._$AM;i=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(i))break;t.add(i),Rt(e)}};function Vt(i){this._$AN!==void 0?(ae(this),this._$AM=i,lt(this)):this._$AM=i}function kt(i,e=!1,t=0){let s=this._$AH,o=this._$AN;if(o!==void 0&&o.size!==0)if(e)if(Array.isArray(s))for(let r=t;r<s.length;r++)G(s[r],!1),ae(s[r]);else s!=null&&(G(s,!1),ae(s));else G(this,i)}var Rt=i=>{var e,t;i.type==ne.CHILD&&((e=i._$AP)!=null||(i._$AP=kt),(t=i._$AQ)!=null||(i._$AQ=Vt))},le=class extends H{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,s){super._$AT(e,t,s),lt(this),this.isConnected=e._$AU}_$AO(e,t=!0){var s,o;e!==this.isConnected&&(this.isConnected=e,e?(s=this.reconnected)==null||s.call(this):(o=this.disconnected)==null||o.call(this)),t&&(G(this,e),ae(this))}setValue(e){if(at(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};var V=()=>new we,we=class{},xe=new WeakMap,k=j(class extends le{render(i){return h}update(i,[e]){var s;let t=e!==this.G;return t&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=(s=i.options)==null?void 0:s.host,this.rt(this.ct=i.element)),h}rt(i){var e;if(this.G!==void 0)if(this.isConnected||(i=void 0),typeof this.G=="function"){let t=(e=this.ht)!=null?e:globalThis,s=xe.get(t);s===void 0&&(s=new WeakMap,xe.set(t,s)),s.get(this.G)!==void 0&&this.G.call(this.ht,void 0),s.set(this.G,i),i!==void 0&&this.G.call(this.ht,i)}else this.G.value=i}get lt(){var i,e,t;return typeof this.G=="function"?(e=xe.get((i=this.ht)!=null?i:globalThis))==null?void 0:e.get(this.G):(t=this.G)==null?void 0:t.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function he(i){if(!i)return null;try{let{protocol:e}=new URL(i);return e==="https:"||e==="http:"?i:null}catch(e){return null}}function Ut(){var i,e;return(e=(i=globalThis.matchMedia)==null?void 0:i.call(globalThis,"(prefers-reduced-motion: reduce)").matches)!=null?e:!1}function q(i,e){return!e.failed&&he(i.media_url)!==null}function W(i,e){let t=he(i.poster_url),s=he(i.media_url);return u`
11
+ ${t?u`<img class="poster" alt="" src=${t} />`:h}
12
+ ${s&&!e.failed?u`
13
+ <video
14
+ class="video"
15
+ muted
16
+ playsinline
17
+ loop
18
+ preload="metadata"
19
+ .muted=${!0}
20
+ ?autoplay=${!Ut()}
21
+ poster=${t!=null?t:h}
22
+ src=${s}
23
+ ${k(e.ref)}
24
+ @play=${e.sync}
25
+ @pause=${e.sync}
26
+ @volumechange=${e.sync}
27
+ @error=${e.fail}
28
+ ></video>
29
+ `:h}
30
+ `}function de(i){var e;(e=i.play())==null||e.catch(()=>{})}var L=class{constructor(e){this.host=e;this.ref=V();this.paused=!0;this.muted=!0;this.failed=!1;this.sync=()=>{let e=this.ref.value;e&&(this.paused=e.paused,this.muted=e.muted,this.host.requestUpdate())};this.fail=()=>{this.failed=!0,this.host.requestUpdate()}}reset(){this.paused=!0,this.muted=!0,this.failed=!1}play(){let e=this.ref.value;e&&de(e)}pause(){var e;(e=this.ref.value)==null||e.pause()}resume(){let e=this.ref.value;e!=null&&e.autoplay&&de(e)}togglePlayback(){let e=this.ref.value;e&&(e.paused?de(e):e.pause())}toggleMuted(){let e=this.ref.value;e&&(e.muted=!e.muted)}};var Ee=x`
6
31
  .card {
7
32
  position: relative;
8
33
  box-sizing: border-box;
@@ -13,11 +38,29 @@
13
38
  background: #000;
14
39
  }
15
40
 
16
- .card[role="button"] {
41
+ /* The card's button covers it. The focus ring goes on the card, since the
42
+ card's overflow would clip the button's own. */
43
+ .card-open {
44
+ position: absolute;
45
+ inset: 0;
46
+ width: 100%;
47
+ height: 100%;
48
+ padding: 0;
49
+ border: 0;
50
+ background: transparent;
17
51
  cursor: pointer;
18
52
  }
19
53
 
20
- .poster {
54
+ .card-open:focus-visible {
55
+ outline: none;
56
+ }
57
+
58
+ .card:has(> .card-open:focus-visible) {
59
+ outline: auto;
60
+ }
61
+
62
+ .poster,
63
+ .video {
21
64
  position: absolute;
22
65
  inset: 0;
23
66
  width: 100%;
@@ -53,6 +96,29 @@
53
96
  color: #fff;
54
97
  }
55
98
 
99
+ /* Sound on/off, at the top right of the card (as in the prototype). */
100
+ .card-sound {
101
+ position: absolute;
102
+ top: 22px;
103
+ right: 12px;
104
+ z-index: 1;
105
+ display: grid;
106
+ width: 28px;
107
+ height: 28px;
108
+ place-items: center;
109
+ padding: 0;
110
+ border: 0;
111
+ background: transparent;
112
+ color: #fff;
113
+ cursor: pointer;
114
+ filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
115
+ }
116
+
117
+ .card-sound .icon {
118
+ width: 20px;
119
+ height: 20px;
120
+ }
121
+
56
122
  /* With a mouse, the play button shows only on hover or keyboard focus.
57
123
  Touch screens have no hover, so it stays visible there. */
58
124
  @media (hover: hover) and (pointer: fine) {
@@ -62,12 +128,34 @@
62
128
  }
63
129
 
64
130
  .card:hover .play,
65
- .card:focus-visible .play {
131
+ .card-open:focus-visible .play {
66
132
  opacity: 1;
67
133
  transform: translate(-50%, -50%);
68
134
  }
69
135
  }
70
- `;function B(r){try{let{protocol:t}=new URL(r);return t==="https:"||t==="http:"}catch(t){return!1}}function p(r,t){let e=document.createElement("div");if(e.className="card",r.poster_url&&B(r.poster_url)){let a=document.createElement("img");a.className="poster",a.alt="",a.src=r.poster_url,e.append(a)}if(t){e.setAttribute("role","button"),e.setAttribute("aria-label",t.label),e.tabIndex=0;let a=document.createElement("span");a.className="play",a.setAttribute("aria-hidden","true"),a.append(i("play")),e.append(a),e.addEventListener("click",t.onSelect),e.addEventListener("keydown",o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),t.onSelect())})}return e}var f=`
136
+ `;function Nt(i,e){return u`
137
+ <button
138
+ type="button"
139
+ class="card-sound"
140
+ aria-label=${i.muted?e.soundOnLabel:e.soundOffLabel}
141
+ @click=${()=>i.toggleMuted()}
142
+ >
143
+ ${A(i.muted?"soundOff":"soundOn")}
144
+ </button>
145
+ `}function Ce(i,e,t){return u`
146
+ <div class="card">
147
+ ${W(i,e)}
148
+ <button
149
+ type="button"
150
+ class="card-open"
151
+ aria-label=${t.label}
152
+ @click=${t.onSelect}
153
+ >
154
+ <span class="play" aria-hidden="true">${A("play")}</span>
155
+ </button>
156
+ ${q(i,e)&&!e.paused?Nt(e,t):h}
157
+ </div>
158
+ `}var Se=x`
71
159
  .player {
72
160
  position: fixed;
73
161
  inset: auto 16px 16px auto;
@@ -112,6 +200,46 @@
112
200
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
113
201
  }
114
202
 
203
+ .player .card:has(.video) {
204
+ cursor: pointer;
205
+ }
206
+
207
+ /* Play/pause reuses the card's glass .play button, as a real button. */
208
+ .player-toggle {
209
+ padding: 0;
210
+ border: 0;
211
+ color: #fff;
212
+ font: inherit;
213
+ cursor: pointer;
214
+ }
215
+
216
+ .player[data-paused] .player-toggle,
217
+ .player-toggle:focus-visible {
218
+ opacity: 1;
219
+ transform: translate(-50%, -50%);
220
+ }
221
+
222
+ /* On touch, tapping the video pauses it; the button shows while paused. */
223
+ @media (hover: none) {
224
+ .player:not([data-paused]) .player-toggle {
225
+ opacity: 0;
226
+ }
227
+ }
228
+
229
+ .player-sound {
230
+ position: absolute;
231
+ top: 12px;
232
+ right: 12px;
233
+ z-index: 1;
234
+ border-color: transparent;
235
+ background: rgba(0, 0, 0, 0.3);
236
+ }
237
+
238
+ .player-sound .icon {
239
+ width: 20px;
240
+ height: 20px;
241
+ }
242
+
115
243
  /* Above the card: on narrow screens the expanded card can cover them. */
116
244
  .player-controls {
117
245
  position: absolute;
@@ -196,8 +324,12 @@
196
324
  border-radius: 0;
197
325
  }
198
326
 
327
+ /* Below the sound button, at the top right of the video. Placed in the
328
+ video frame, not the screen: the frame is centered, so on screens
329
+ taller than 9:16 its top is below the screen's. */
199
330
  .player[data-expanded] .player-controls {
200
- top: 12px;
331
+ position: absolute;
332
+ top: 60px;
201
333
  right: 12px;
202
334
  }
203
335
  }
@@ -214,14 +346,109 @@
214
346
  animation: none;
215
347
  }
216
348
  }
217
- `;function L(r,t,e){let a=document.createElement("button");return a.type="button",a.className=`player-button ${r}`,a.setAttribute("aria-label",t),a.append(i(e)),a}function k(r){return typeof r.showPopover=="function"}function y(r){k(r)?r.showPopover():r.show()}function b(r,t){let e=document.createElement("dialog");e.className="player",e.setAttribute("popover","manual"),e.setAttribute("aria-label",t.label);let a=document.createElement("div");a.className="player-frame";let o=document.createElement("div");o.className="player-controls";let s=L("player-expand",t.expandLabel,"expand"),g=L("player-close",t.closeLabel,"close");o.append(s,g);let n=!1;function M(){!n&&k(e)?e.hidePopover():e.close()}return s.addEventListener("click",()=>{M(),n=!n,e.toggleAttribute("data-expanded",n),e.dataset.switched="",s.setAttribute("aria-label",n?t.collapseLabel:t.expandLabel),s.replaceChildren(i(n?"collapse":"expand")),n?e.showModal():y(e),s.focus()}),g.addEventListener("click",t.onClose),e.addEventListener("click",m=>{n&&m.target===e&&t.onClose()}),e.addEventListener("cancel",m=>{m.preventDefault(),t.onClose()}),a.append(o,p(r)),e.append(a),e}var c="vtex-ads-story",H,z=(H=globalThis.HTMLElement)!=null?H:Object,G=`
218
- :host {
219
- display: block;
220
- font-family: var(--vtex-ads-story-font-family, inherit);
221
- color: var(--vtex-ads-story-color-text, inherit);
222
- }
223
- ${x}
224
- ${f}
225
- `,S={ad_id:"placeholder",poster_url:"https://dummyimage.com/1080x1920/e31c57/fff"},d={watch:"Assistir v\xEDdeo",player:"V\xEDdeo",expand:"Expandir v\xEDdeo",collapse:"Reduzir v\xEDdeo",close:"Fechar v\xEDdeo"},l=class extends z{constructor(){super(...arguments);this.player=null;this.onKeyDown=e=>{e.key==="Escape"&&this.closePlayer()}}render(){var a;let e=(a=this.shadowRoot)==null?void 0:a.querySelector(".root");e&&e.replaceChildren(p(S,{label:d.watch,onSelect:()=>this.openPlayer()}))}openPlayer(){var e;this.player||!this.shadowRoot||(this.player=b(S,{label:d.player,expandLabel:d.expand,collapseLabel:d.collapse,closeLabel:d.close,onClose:()=>this.closePlayer()}),this.shadowRoot.append(this.player),y(this.player),document.addEventListener("keydown",this.onKeyDown),(e=this.player.querySelector(".player-close"))==null||e.focus())}closePlayer({restoreFocus:e=!0}={}){var a,o;this.player&&(document.removeEventListener("keydown",this.onKeyDown),this.player.remove(),this.player=null,e&&((o=(a=this.shadowRoot)==null?void 0:a.querySelector(".root .card"))==null||o.focus()))}connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`<style>${G}</style><div class="root"></div>`}this.render()}disconnectedCallback(){this.closePlayer({restoreFocus:!1})}};function h(){typeof customElements!="undefined"&&(customElements.get(c)||customElements.define(c,l))}h();return Z(K);})();
349
+ `;function ht(i){return typeof i.showPopover=="function"}var K=class{constructor(e,t){this.host=e;this.options=t;this.isOpen=!1;this.expanded=!1;this.switched=!1;this.shown=!1;this.dialog=V();this.expandButton=V();this.closeButton=V();this.toggleExpanded=async()=>{var t;let e=this.dialog.value;e&&(this.hide(e),this.expanded=!this.expanded,this.switched=!0,this.host.requestUpdate(),await this.host.updateComplete,this.isOpen&&(this.show(e),(t=this.expandButton.value)==null||t.focus()))};this.onKeyDown=e=>{e.key==="Escape"&&this.options.onClose()};this.onDialogClick=e=>{this.expanded&&e.target===e.currentTarget&&this.options.onClose()};this.onCancel=e=>{e.preventDefault(),this.options.onClose()};e.addController(this),this.video=new L(e)}hostDisconnected(){this.close()}async open(){var t;if(this.isOpen)return;document.addEventListener("keydown",this.onKeyDown),this.isOpen=!0,this.expanded=!1,this.switched=!1,this.video.reset(),this.host.requestUpdate(),await this.host.updateComplete;let e=this.dialog.value;!this.isOpen||!e||(this.show(e),this.video.play(),(t=this.closeButton.value)==null||t.focus())}close(){if(!this.isOpen)return;document.removeEventListener("keydown",this.onKeyDown);let e=this.dialog.value;e&&this.hide(e),this.isOpen=!1,this.host.requestUpdate()}show(e){this.shown||(this.expanded?e.showModal():ht(e)?e.showPopover():e.show(),this.shown=!0)}hide(e){this.shown&&(!this.expanded&&ht(e)?e.hidePopover():e.close(),this.shown=!1)}renderVideoControls(){let{video:e,options:t}=this,s=r=>{r.stopPropagation(),e.togglePlayback()},o=r=>{r.stopPropagation(),e.toggleMuted()};return u`
350
+ <button
351
+ type="button"
352
+ class="play player-toggle"
353
+ aria-label=${e.paused?t.playLabel:t.pauseLabel}
354
+ @click=${s}
355
+ >
356
+ ${A(e.paused?"play":"pause")}
357
+ </button>
358
+ <button
359
+ type="button"
360
+ class="player-button player-sound"
361
+ aria-label=${e.muted?t.soundOnLabel:t.soundOffLabel}
362
+ @click=${o}
363
+ >
364
+ ${A(e.muted?"soundOff":"soundOn")}
365
+ </button>
366
+ `}render(e){if(!this.isOpen)return h;let{video:t,options:s,expanded:o}=this,r=q(e,t);return u`
367
+ <dialog
368
+ class="player"
369
+ popover="manual"
370
+ aria-label=${s.label}
371
+ ?data-expanded=${o}
372
+ ?data-switched=${this.switched}
373
+ ?data-paused=${r&&t.paused}
374
+ ${k(this.dialog)}
375
+ @click=${this.onDialogClick}
376
+ @cancel=${this.onCancel}
377
+ >
378
+ <div class="player-frame">
379
+ <div class="player-controls">
380
+ <button
381
+ type="button"
382
+ class="player-button player-expand"
383
+ aria-label=${o?s.collapseLabel:s.expandLabel}
384
+ ${k(this.expandButton)}
385
+ @click=${this.toggleExpanded}
386
+ >
387
+ ${A(o?"collapse":"expand")}
388
+ </button>
389
+ <button
390
+ type="button"
391
+ class="player-button player-close"
392
+ aria-label=${s.closeLabel}
393
+ ${k(this.closeButton)}
394
+ @click=${s.onClose}
395
+ >
396
+ ${A("close")}
397
+ </button>
398
+ </div>
399
+ <div class="card" @click=${()=>t.togglePlayback()}>
400
+ ${W(e,t)}
401
+ ${r?this.renderVideoControls():h}
402
+ </div>
403
+ </div>
404
+ </dialog>
405
+ `}};var F="vtex-ads-story",dt={poster_url:"https://dummyimage.com/1080x1920/e31c57/fff",media_url:"https://samplelib.com/mp4/sample-10s-vp9.mp4"},f={watch:"Assistir v\xEDdeo",player:"V\xEDdeo",expand:"Expandir v\xEDdeo",collapse:"Reduzir v\xEDdeo",close:"Fechar v\xEDdeo",play:"Reproduzir v\xEDdeo",pause:"Pausar v\xEDdeo",soundOn:"Ativar som",soundOff:"Desativar som"},O=class extends b{constructor(){super(...arguments);this.cardVideo=new L(this);this.player=new K(this,{label:f.player,expandLabel:f.expand,collapseLabel:f.collapse,closeLabel:f.close,playLabel:f.play,pauseLabel:f.pause,soundOnLabel:f.soundOn,soundOffLabel:f.soundOff,onClose:()=>this.closePlayer()})}connectedCallback(){super.connectedCallback(),this.cardVideo.resume()}openPlayer(){this.player.isOpen||(this.cardVideo.pause(),this.player.open())}closePlayer(){var t;this.player.isOpen&&(this.player.close(),this.cardVideo.resume(),(t=this.renderRoot.querySelector(".root .card-open"))==null||t.focus())}render(){return u`
406
+ <div class="root">
407
+ ${Ce(dt,this.cardVideo,{label:f.watch,soundOnLabel:f.soundOn,soundOffLabel:f.soundOff,onSelect:()=>this.openPlayer()})}
408
+ </div>
409
+ ${this.player.render(dt)}
410
+ `}};O.styles=[x`
411
+ :host {
412
+ display: block;
413
+ font-family: var(--vtex-ads-story-font-family, inherit);
414
+ color: var(--vtex-ads-story-color-text, inherit);
415
+ }
416
+ `,Ee,Se];function Y(){typeof customElements!="undefined"&&(customElements.get(F)||customElements.define(F,O))}Y();return yt(Dt);})();
226
417
  /*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */
418
+ /*! Bundled license information:
419
+
420
+ @lit/reactive-element/css-tag.js:
421
+ (**
422
+ * @license
423
+ * Copyright 2019 Google LLC
424
+ * SPDX-License-Identifier: BSD-3-Clause
425
+ *)
426
+
427
+ @lit/reactive-element/reactive-element.js:
428
+ lit-html/lit-html.js:
429
+ lit-element/lit-element.js:
430
+ lit-html/directive.js:
431
+ lit-html/directives/unsafe-html.js:
432
+ lit-html/async-directive.js:
433
+ (**
434
+ * @license
435
+ * Copyright 2017 Google LLC
436
+ * SPDX-License-Identifier: BSD-3-Clause
437
+ *)
438
+
439
+ lit-html/is-server.js:
440
+ (**
441
+ * @license
442
+ * Copyright 2022 Google LLC
443
+ * SPDX-License-Identifier: BSD-3-Clause
444
+ *)
445
+
446
+ lit-html/directive-helpers.js:
447
+ lit-html/directives/ref.js:
448
+ (**
449
+ * @license
450
+ * Copyright 2020 Google LLC
451
+ * SPDX-License-Identifier: BSD-3-Clause
452
+ *)
453
+ */
227
454
  //# sourceMappingURL=vtex-ads-stories.js.map