(()=>{"use strict";const e=document.getElementsByClassName("videowise-background");let t="";void 0!==window.Shopify?t=window.Shopify.shop:void 0!==window.videowiseSFCC&&(t=window.videowiseSFCC.host);const i=[];let s;for(let o=0;o<e.length;o++)if(s=e[o].getAttribute("data-widget-id"),i.push(s),null!==e[o]){const n=e[o].querySelector("video"),l=n.querySelector("source"),r=`https://api-cdn.videowise.com/widget/bulk.json?widget=${s}&shop=${t}`;function w(){e[o].removeAttribute("data-widget-id"),e[o].setAttribute("id",`reeview-app-widget_${s}`),n.remove()}function c(t,i){const s=document.createElement("meta");s.content=i,s.setAttribute("itemProp",t),e[o].appendChild(s)}(d=e[o]).setAttribute("itemprop","video"),d.setAttribute("itemscope","true"),d.setAttribute("itemtype","https://schema.org/VideoObject"),fetch(r).then((e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()})).then((t=>{for(let d=0;d<t?.widgets?.length;d++)if(s.includes(t.widgets[d].id)){let r=t.widgets[d].videos.find((e=>"DESKTOP"===e.skinType));if(window.matchMedia("(max-width: 768px)").matches&&t.widgets[d].videos.find((e=>"MOBILE"===e.skinType))&&(r=t.widgets[d].videos.find((e=>"MOBILE"===e.skinType))),!r)return void w();c("contentUrl",r.url),c("uploadDate",r.createdAt),c("thumbnailUrl",r.thumbnail.url),c("name",r.title),r.description&&c("description",r.description);let a="vw-bottom-left";setTimeout((()=>{try{window.dispatchEvent(new CustomEvent("videowiseBackgroundV2Rendered",{detail:{campaignId:null,event_source:"SHOP",organisationId:t.organisationId,siteId:t.widgets[d].siteId,trackingId:null,videoType:t.widgets[d].videoType,widgetId:t.widgets[d].id,widgetType:t.widgets[d].type}}))}catch(e){console.error("Error dispatching VIDEO_BACKGROUND_V2_RENDERED event:",e)}}),5e3);let u=t.widgets[d].videos[0].meta?.convertedH264?.videoUrl||t.widgets[d].videos[0].url||[];var i="16px";if(window.matchMedia("(max-width: 768px)").matches){i=`${t.widgets[d].skins[1].iconSize}px`;const y=t.widgets[d].skins[1].video.format,C=t.widgets[d].skins[1].iconPosition;if("FULL_SCREEN"===y?e[o].classList.add("vw--background-widget-cover"):e[o].classList.add("vw--background-widget-contain"),"BOTTOM_LEFT"===C&&(a="vw-bottom-left",e[o].classList.add(a)),"BOTTOM_RIGHT"===C&&(a="vw-bottom-right",e[o].classList.add(a)),"TOP_LEFT"===C&&(a="vw-top-left",e[o].classList.add(a)),"TOP_RIGHT"===C&&(a="vw-top-right",e[o].classList.add(a)),1==t.widgets[d].videos.length){if(0!=(t.widgets[d].videos[0].muxAssetId||!1))return void w();if(u=t.widgets[d].videos[0].meta?.convertedH264?.mobileVideoUrl||t.widgets[d].videos[0].url||[],!(u&&u.length>0))return void w();l.src!=u&&(n.src=u)}else for(let k=0;k<t.widgets[d].videos.length;k++)if("MOBILE"==t.widgets[d].videos[k].skinType){if(0!=(t.widgets[d].videos[k].muxAssetId||!1))return void w();if(u=t.widgets[d].videos[k].meta?.convertedH264?.videoUrl||t.widgets[d].videos[0].url||[],!(u&&u.length>0))return void w();l.src!=u&&(n.src=u)}}else{i=`${t.widgets[d].skins[0].iconSize}px`,"FULL_SCREEN"===t.widgets[d].skins[0].video.format?e[o].classList.add("vw--background-widget-cover"):e[o].classList.add("vw--background-widget-contain");const b=t.widgets[d].skins[0].iconPosition;"BOTTOM_LEFT"===b&&(a="vw-bottom-left",e[o].classList.add(a)),"BOTTOM_RIGHT"===b&&(a="vw-bottom-right",e[o].classList.add(a)),"TOP_LEFT"===b&&(a="vw-top-left",e[o].classList.add(a)),"TOP_RIGHT"===b&&(a="vw-top-right",e[o].classList.add(a));for(let E=0;E<t.widgets[d].videos.length;E++)if("DESKTOP"==t.widgets[d].videos[E].skinType){if(0!=(t.widgets[d].videos[E].muxAssetId||!1))return void w();if(u=t.widgets[d].videos[E].meta?.convertedH264?.videoUrl||t.widgets[d].videos[0].url||[],!(u&&u.length>0))return void w();l.src!=u&&(n.src=u)}}function v(){return window.matchMedia("(max-width: 768px)").matches?"MOBILE":"DESKTOP"}const g=document.createElement("div");g.className=`vw-container-icons ${a}`;const h=document.querySelector(`.videowise-background-component_${t.widgets[d].id}`).appendChild(g);let p=t.widgets[d].skins[0].showControls,m=t.widgets[d].skins[0].showPlayControl,L=t.widgets[d].skins[0].showSoundControl,f=t.widgets[d].skins[0].showFullscreenControl;if("MOBILE"==v&&(p=t.widgets[d].skins[1].showControls,m=t.widgets[d].skins[1].showPlayControl,L=t.widgets[d].skins[1].showSoundControl,f=t.widgets[d].skins[1].showFullscreenControl),p&&m){const T=`<div class="vw--play-and-pause" style="width:${i};height:${i}"><button type="button" aria-label="PlayPause" id="btn-${s}"><svg class="play" xmlns="http://www.w3.org/2000/svg" width="${i}" height="${i}"viewBox="0 0 32 32" fill="none"><path d="M10.6665 10H13.6665V22H10.6665V10Z" fill="white"/><path d="M18.3281 10H21.3281V22H18.3281V10Z" fill="white"/><g><circle cx="16" cy="16" r="13.25" stroke="white" stroke-width="1.5" /></svg><svg class="pause" xmlns="http://www.w3.org/2000/svg"${i}" height="${i}"viewBox="0 0 32 32" fill="none"><path d="M13 11L22 16L13 21V11Z" fill="white"/><g><circle cx="16" cy="16" r="13.25" stroke="white" stroke-width="1.5" /></g></svg></button> </div>`;h.innerHTML+=T,setTimeout((()=>{const e=document.getElementById(`btn-${s}`);e.addEventListener("click",(t=>{const i=e.querySelector(".play"),s=e.querySelector(".pause");n.paused?(n.play(),i.style.display="block",s.style.display="none"):(n.pause(),i.style.display="none",s.style.display="block")}),!1)}),1e3)}if(p&&L){let H="";H+=`<div class="vw--mute-and-unmute"  style="width:${i};height:${i}">`,H+=`<button type="button" aria-label="MuteUnmute" id="videoSound-${s}">`,H+=`<svg class="mute" width="${i}" height="${i}" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.7916 2.48099C15.933 2.33343 16.1286 2.25 16.333 2.25H19C19.4142 2.25 19.75 2.58579 19.75 3V29C19.75 29.4142 19.4142 29.75 19 29.75H16.333C16.1286 29.75 15.9331 29.6666 15.7916 29.5191L8.01263 21.4055L2.9983 21.3929C2.58483 21.3918 2.2502 21.0563 2.2502 20.6429V11.3571C2.2502 10.9436 2.58494 10.6081 2.99848 10.6071L8.01286 10.5956L15.7916 2.48099ZM16.653 3.75L8.87497 11.8639C8.73393 12.011 8.53909 12.0944 8.33528 12.0949L3.7502 12.1054V19.8948L8.33525 19.9064C8.53898 19.9069 8.73373 19.9902 8.87472 20.1373L16.653 28.25H18.25V3.75H16.653ZM27.3117 6.98611L27.6628 7.64885C29.0001 10.1731 29.7188 13.0535 29.75 15.992V16.0079C29.7188 18.9464 29.0001 21.8268 27.6628 24.3511L27.3117 25.0138L25.9862 24.3116L26.3373 23.6488C27.5576 21.3455 28.22 18.7044 28.25 16C28.22 13.2955 27.5576 10.6544 26.3373 8.35107L25.9862 7.68834L27.3117 6.98611ZM23.6383 11.606L23.2443 10.9678L21.9679 11.7557L22.3618 12.3939C22.9678 13.3756 23.2925 14.6526 23.2456 15.9734C23.245 15.9911 23.245 16.0088 23.2456 16.0266C23.2925 17.3473 22.9678 18.6243 22.3618 19.606L21.9679 20.2442L23.2443 21.0321L23.6383 20.3939C24.4115 19.1411 24.7966 17.5759 24.7456 16C24.7966 14.424 24.4115 12.8588 23.6383 11.606Z" fill="white"/></svg>`,H+=`<svg class="unmute" width="${i}" height="${i}" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.7916 2.48099C15.933 2.33343 16.1286 2.25 16.333 2.25H19C19.4142 2.25 19.75 2.58579 19.75 3V29C19.75 29.4142 19.4142 29.75 19 29.75H16.333C16.1286 29.75 15.9331 29.6666 15.7916 29.5191L8.01263 21.4055L2.9983 21.3929C2.58483 21.3918 2.2502 21.0563 2.2502 20.6429V11.3571C2.2502 10.9436 2.58494 10.6081 2.99848 10.6071L8.01286 10.5956L15.7916 2.48099ZM16.653 3.75L8.87497 11.8639C8.73393 12.011 8.53909 12.0944 8.33528 12.0949L3.7502 12.1054V19.8948L8.33525 19.9064C8.53898 19.9069 8.73373 19.9902 8.87472 20.1373L16.653 28.25H18.25V3.75H16.653Z" fill="white"/><path d="M23.5 12.5L30.5 19.5M23.5 19.5L30.5 12.5" stroke="white" stroke-width="1.5" stroke-linecap="square"/></svg>`,H+="</button>",H+="</div>",h.innerHTML+=H,setTimeout((()=>{const e=document.getElementById(`videoSound-${s}`);e.addEventListener("click",(()=>{const i=e.querySelector(".mute"),s=e.querySelector(".unmute");if(n.muted){n.muted=!1,s.style.display="none",i.style.display="block";try{window.dispatchEvent(new CustomEvent("videowiseVideoSoundOn",{detail:{videoTitle:t.widgets[d].videos[0].title,videoId:t.widgets[d].videos[0].id,deviceType:v(),url:t.widgets[d].videos[0].url,widgetId:t.widgets[d].id}}))}catch(e){console.error("Error dispatching VIDEO_SOUND_ON event:",e)}}else{n.muted=!0,s.style.display="block",i.style.display="none";try{window.dispatchEvent(new CustomEvent("videowiseVideoSoundOff",{detail:{videoTitle:t.widgets[d].videos[0].title,videoId:t.widgets[d].videos[0].id,deviceType:v(),url:t.widgets[d].videos[0].url,widgetId:t.widgets[d].id}}))}catch(e){console.error("Error dispatching VIDEO_SOUND_OFF event:",e)}}}),!1)}),1e3)}if(p&&f){let V="";V+=`<div class="vw--full-screen" style="width:${i};height:${i}">`,V+=`<button type="button" aria-label="FullUnfull" id="fullScreen-${s}">`,V+=`<svg width="${i}" height="${i}" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4C3.75 3.86193 3.86193 3.75 4 3.75H11V2.25H4C3.0335 2.25 2.25 3.0335 2.25 4V11H3.75V4ZM3.75 28C3.75 28.1381 3.86193 28.25 4 28.25H11V29.75H4C3.0335 29.75 2.25 28.9665 2.25 28V21H3.75V28ZM28 3.75C28.1381 3.75 28.25 3.86193 28.25 4V11H29.75V4C29.75 3.0335 28.9665 2.25 28 2.25H21V3.75H28ZM28.25 28C28.25 28.1381 28.1381 28.25 28 28.25H21V29.75H28C28.9665 29.75 29.75 28.9665 29.75 28V21H28.25V28Z" fill="white"/></svg>`,V+="</button>",V+="</div>",h.innerHTML+=V,setTimeout((()=>{const e=document.getElementById(`fullScreen-${s}`);e&&e.addEventListener("click",(()=>{n.requestFullscreen?n.requestFullscreen().catch((e=>{console.error("Error attempting to enter fullscreen mode:",e.message)})):n.webkitEnterFullscreen?n.webkitEnterFullscreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():console.warn("Fullscreen API is not supported in this browser for the video element.")}))}),1e3)}}})).catch((e=>{w(),console.error("Error:",e)}))}var d})();