@vouchfor/embeds 2.0.15 → 2.0.18
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/embeds.js +2 -2
- package/dist/iife/dialog-embed/embed.iife.js +2 -2
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
- package/dist/iife/embeds.iife.js +2 -2
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/embed.iife.js +2 -2
- package/dist/iife/player-embed/embed.iife.js.map +1 -1
- package/package.json +2 -2
package/dist/iife/embeds.iife.js
CHANGED
@@ -145,7 +145,7 @@ ${e}`,Ng=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Mg=Objec
|
|
145
145
|
"src": {{ it._derived?.src }},
|
146
146
|
"playlist": {{ it._derived?.playlist }},
|
147
147
|
"captions": {{ it._derived?.captions }}
|
148
|
-
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:720,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function tf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Vu);return new s.Image}return new Image}const xl=Ei(async function(e){return e?new Promise((t,i)=>{tf().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{i(n)},r.src=e})}):null});async function wo({element:s,meta:e},t,i){var r,n,o;let a={...s};const{node:A}=s;if((A==null?void 0:A.type)==="video"&&((r=A==null?void 0:A.value)!=null&&r.src||(n=A==null?void 0:A.value)!=null&&n.playlist)){const l=await t(A.value,e);let c;try{c=await xl(A.value.poster)}catch{c=null}a={...a,node:{...A,video:l,poster:c,meta:await i(A.value,l.node,e)}}}if((A==null?void 0:A.type)==="image"&&A.value){let l;try{l=await xl(A.value)}catch{l=null}a={...a,node:{...A,image:l}}}return a.node&&((o=s.node)!=null&&o.elements)&&(a.node.elements=await Promise.all(s.node.elements.map(l=>wo({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>wo({element:l,meta:e},t,i)))),a}async function Xr(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Vu),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function er(s=[]){var e;for(const t of s){if(((e=t==null?void 0:t.node)==null?void 0:e.type)==="video")return t.node;const i=er(t==null?void 0:t.elements);if(i)return i}}function sf(s,e){return s.reduce((t,i,r)=>[...t,i.map(({duration:n},o)=>r===s.length-1&&o===i.length-1?n:n-e)],[])}function rf(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let e=s;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(s)===e}function nf(s){return s.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function zr(s){return s.flatMap(e=>e).reduce((e,t)=>e+t,0)}const of=Ei(()=>ul.loadYoga());Io.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${nf(s)}"`:rf(s)||Array.isArray(s)?JSON.stringify(s):s);const cs=(s,e,t)=>Io.render(s,e,Io.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function hs({data:s,template:e,burnCaptions:t=!1,debug:i=!1},r,n,o){var a,A,l,c;const h=await of(),u=e??ef;if(!((a=u.templates)!=null&&a.length))throw new Error(`No templates found for template instance: ${u.id}`);let d=u.templates.find(({version:L})=>L===Ro);if(!d){const L=u.templates.map(({version:G})=>`"${G}"`).join(", ");console.warn(`Template renderer expects template version "${Ro}" but got ${L}`),d=u.templates[u.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:L,root:G})=>{const F={...u.options,...s,intro:u.intro,outro:u.outro};async function U(j,J){return Promise.all(L.map(async({layout:z,duration:w,data:x,derived:$,options:R})=>{var S,T,K;const M={...F,_index:J,_root:j,_derived:await r({data:s,rootData:j,index:J})},q=x?JSON.parse(await cs(x,M)):{},ie=$?JSON.parse(await cs($,M)):{},ce=R?JSON.parse(await cs(R,M)):{},ae=w?parseFloat(await cs(w,M)):NaN,me=(S=d.layouts.find(ve=>ve.name===z))==null?void 0:S.tree;if(!me)throw new Error(`Layout tree "${z}" not found in template "${d.id}" layouts.`);const Qe=JSON.parse(await cs(me,{...q,...ie,...ce})),Te=await Promise.all(Qe.flatMap(ve=>wo({element:ve,meta:u.meta},n,o))),re=er(Te);return{duration:(isNaN(ae)?null:ae)??((T=re==null?void 0:re.meta)==null?void 0:T.duration)??0,captions:(K=re==null?void 0:re.meta)==null?void 0:K.captions,elements:Te}}))}if(G){const j=JSON.parse(await cs(G,F));return Array.isArray(j)?(await Promise.all(j.map(async(J,z)=>U(J,z)))).flatMap(J=>J):U(j,null)}return U(s,null)}));if(g.every(L=>L.every(G=>{const F=er(G.elements);return!(F!=null&&F.value.src)&&!(F!=null&&F.value.playlist)}))){const L=g.flatMap(G=>G.map(F=>{const U=er(F.elements);return!(U!=null&&U.value.src)&&!(U!=null&&U.value.playlist)&&(U==null?void 0:U.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${L} failed to load, video can not be processed`)}if(g.every(L=>L.every(G=>G.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((L,G)=>{const F=G.filter(U=>U.duration>0);return F.length>0&&(L=[...L,F]),L},[]),y=((A=u.meta)==null?void 0:A.frameRate)??30,b=((l=u.meta)==null?void 0:l.resolution)??720,C=((c=u.meta)==null?void 0:c.transitionDuration)??1/3,Q=sf(v,C),B=zr(Q);return{scenes:(await Promise.all(v.map((L,G)=>{const F=zr(Q[G]),U=zr(Q.slice(0,G));return Promise.all(L.map(async({duration:j,captions:J,elements:z},w)=>{var x,$;const R=await Xr(),S=await Xr(),T=await Xr(),K=await Xr(),M=er(z),q=zr([...Q.slice(0,G),...Q[G].slice(0,w)]);return{draw:({canvas:ce,currentTime:ae})=>{const me=Math.max(0,ae-U),Qe=Math.max(0,ae-q);So({yoga:h,debug:i,canvas:ce,cropCanvas:R,posterCanvas:K,letterboxCanvas:S,elements:z,currentTime:ae,contentTime:me,sceneTime:Qe,totalDuration:B,contentDuration:F,sceneDuration:j}),J&&t&&Zg({canvas:ce,dx:0,dy:0,dw:ce.width,dh:ce.height,vttCaptions:J,sceneTime:Qe+((M==null?void 0:M.meta.start)??0)})},duration:j,transitionCanvas:T,start:q,video:M==null?void 0:M.video,videoMeta:M==null?void 0:M.meta,audio:{duration:j,src:(x=M==null?void 0:M.value)==null?void 0:x.src,start:($=M==null?void 0:M.meta)==null?void 0:$.start}}}))}))).flatMap(L=>L),frameRate:y,resolution:b,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Ro="3",af={name:"@vouchfor/embeds",version:"2.0.15",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},engines:{node:">=18.18.0"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js","test:watch":"yarn test --watch"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/canvas-video":"^8.0.4","@vouchfor/media-player":"^3.0.15",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.2"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^4.0.0","@storybook/addon-essentials":"^8.0.4","@storybook/addon-links":"^8.0.4","@storybook/blocks":"^8.0.4","@storybook/web-components":"^8.0.4","@storybook/web-components-vite":"^8.0.4","@svgr/core":"^8.1.0","@types/flat":"^5.0.5","@types/mocha":"^10.0.6","@vouchfor/eslint-config":"^1.0.1","@vouchfor/prettier-config":"^1.0.1","@vouchfor/video-utils":"^1.0.9","@web/dev-server-esbuild":"^1.0.2","@web/test-runner":"^0.18.1","@web/test-runner-browserstack":"^0.7.1","@web/test-runner-mocha":"^0.9.0","@web/test-runner-playwright":"^0.11.0",glob:"^10.3.10","lint-staged":"^15.2.2",lit:"^3.1.2",lodash:"^4.17.21",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-tla":"^0.0.2",sinon:"^17.0.1",storybook:"^8.0.4",svgson:"^5.3.1",typescript:"^5.4.3",vite:"^5.2.2","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.7.3","web-component-analyzer":"^2.0.0"}};function Af(s){const{publicApiUrl:e}=Dr(s),t=Di();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function lf(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Di()};let e=(o=(n=window.localStorage)==null?void 0:n.getItem)==null?void 0:o.call(n,"vouch-uid-visitor"),t=(A=(a=window.localStorage)==null?void 0:a.getItem)==null?void 0:A.call(a,"vouch-uid-client"),i=(c=(l=window.sessionStorage)==null?void 0:l.getItem)==null?void 0:c.call(l,"vouch-uid-tab");const r=Di();return e||(e=Af(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Di(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Di(),(p=(f=window.sessionStorage)==null?void 0:f.setItem)==null||p.call(f,"vouch-uid-tab",i)),{client:t,tab:i,request:r,visitor:e}}function cf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function hf(s="embedded_player"){var r,n;const[e,t]=((n=(r=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:r.split)==null?void 0:n.call(r,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([o,a])=>{if(/utm/.test(o)){const A=o.toLowerCase().replace(/[-_][a-z0-9]/g,l=>l.slice(-1).toUpperCase());i[A]=a}}),{source:s,time:new Date,region:t,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:af.version,templateVersion:Ro,...i}}const Tl=1;class uf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=cf(i,this.host.vouch);!r||this.host.disableTracking||this._batchedEvents.push({event:t,payload:{...i,vouchId:r,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:t}=Dr(this.host.env),{client:i,tab:r,request:n,visitor:o}=lf(this.host.env);navigator.sendBeacon(`${t}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":r,"x-uid-request":n,"x-uid-visitor":o,"x-reporting-metadata":hf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Tl&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:t})=>{t&&(this._hasLoaded[t]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:t}),this._hasLoaded[t]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:t,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:t}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:t,key:i,node:r}})=>{var n,o;!this.host.paused&&t===((o=(n=this.host.scene)==null?void 0:n.video)==null?void 0:o.id)&&(this._currentlyPlayingVideo={id:t,key:i,node:r},this._streamLatestTime[i]=r.currentTime,this._streamStartTime[i]||(this._streamStartTime[i]=r.currentTime,this._streamLatestTime[i]=r.currentTime))},this._handleVideoPause=({detail:{id:t,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+Tl&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]},this._pageUnloading=()=>{this._streamEnded(),this._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=e,e.addController(this)}hostConnected(){requestAnimationFrame(()=>{var e,t,i,r;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.addEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var e,t,i,r;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.removeEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}var xo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Mr<"u"&&Mr,i=function(){function n(){this.fetch=!1,this.DOMException=t.DOMException}return n.prototype=t,new n}();(function(n){(function(o){var a=typeof n<"u"&&n||typeof self<"u"&&self||typeof a<"u"&&a,A={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function l(w){return w&&DataView.prototype.isPrototypeOf(w)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(w){return w&&c.indexOf(Object.prototype.toString.call(w))>-1};function u(w){if(typeof w!="string"&&(w=String(w)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(w)||w==="")throw new TypeError('Invalid character in header field name: "'+w+'"');return w.toLowerCase()}function d(w){return typeof w!="string"&&(w=String(w)),w}function g(w){var x={next:function(){var $=w.shift();return{done:$===void 0,value:$}}};return A.iterable&&(x[Symbol.iterator]=function(){return x}),x}function f(w){this.map={},w instanceof f?w.forEach(function(x,$){this.append($,x)},this):Array.isArray(w)?w.forEach(function(x){this.append(x[0],x[1])},this):w&&Object.getOwnPropertyNames(w).forEach(function(x){this.append(x,w[x])},this)}f.prototype.append=function(w,x){w=u(w),x=d(x);var $=this.map[w];this.map[w]=$?$+", "+x:x},f.prototype.delete=function(w){delete this.map[u(w)]},f.prototype.get=function(w){return w=u(w),this.has(w)?this.map[w]:null},f.prototype.has=function(w){return this.map.hasOwnProperty(u(w))},f.prototype.set=function(w,x){this.map[u(w)]=d(x)},f.prototype.forEach=function(w,x){for(var $ in this.map)this.map.hasOwnProperty($)&&w.call(x,this.map[$],$,this)},f.prototype.keys=function(){var w=[];return this.forEach(function(x,$){w.push($)}),g(w)},f.prototype.values=function(){var w=[];return this.forEach(function(x){w.push(x)}),g(w)},f.prototype.entries=function(){var w=[];return this.forEach(function(x,$){w.push([$,x])}),g(w)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(w){if(w.bodyUsed)return Promise.reject(new TypeError("Already read"));w.bodyUsed=!0}function v(w){return new Promise(function(x,$){w.onload=function(){x(w.result)},w.onerror=function(){$(w.error)}})}function y(w){var x=new FileReader,$=v(x);return x.readAsArrayBuffer(w),$}function b(w){var x=new FileReader,$=v(x);return x.readAsText(w),$}function C(w){for(var x=new Uint8Array(w),$=new Array(x.length),R=0;R<x.length;R++)$[R]=String.fromCharCode(x[R]);return $.join("")}function Q(w){if(w.slice)return w.slice(0);var x=new Uint8Array(w.byteLength);return x.set(new Uint8Array(w)),x.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(w){this.bodyUsed=this.bodyUsed,this._bodyInit=w,w?typeof w=="string"?this._bodyText=w:A.blob&&Blob.prototype.isPrototypeOf(w)?this._bodyBlob=w:A.formData&&FormData.prototype.isPrototypeOf(w)?this._bodyFormData=w:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)?this._bodyText=w.toString():A.arrayBuffer&&A.blob&&l(w)?(this._bodyArrayBuffer=Q(w.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(w)||h(w))?this._bodyArrayBuffer=Q(w):this._bodyText=w=Object.prototype.toString.call(w):this._bodyText="",this.headers.get("content-type")||(typeof w=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):A.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var w=p(this);if(w)return w;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var w=p(this);return w||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(y)}),this.text=function(){var w=p(this);if(w)return w;if(this._bodyBlob)return b(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(C(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},A.formData&&(this.formData=function(){return this.text().then(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var _=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function L(w){var x=w.toUpperCase();return _.indexOf(x)>-1?x:w}function G(w,x){if(!(this instanceof G))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');x=x||{};var $=x.body;if(w instanceof G){if(w.bodyUsed)throw new TypeError("Already read");this.url=w.url,this.credentials=w.credentials,x.headers||(this.headers=new f(w.headers)),this.method=w.method,this.mode=w.mode,this.signal=w.signal,!$&&w._bodyInit!=null&&($=w._bodyInit,w.bodyUsed=!0)}else this.url=String(w);if(this.credentials=x.credentials||this.credentials||"same-origin",(x.headers||!this.headers)&&(this.headers=new f(x.headers)),this.method=L(x.method||this.method||"GET"),this.mode=x.mode||this.mode||null,this.signal=x.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&$)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody($),(this.method==="GET"||this.method==="HEAD")&&(x.cache==="no-store"||x.cache==="no-cache")){var R=/([?&])_=[^&]*/;if(R.test(this.url))this.url=this.url.replace(R,"$1_="+new Date().getTime());else{var S=/\?/;this.url+=(S.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}G.prototype.clone=function(){return new G(this,{body:this._bodyInit})};function F(w){var x=new FormData;return w.trim().split("&").forEach(function($){if($){var R=$.split("="),S=R.shift().replace(/\+/g," "),T=R.join("=").replace(/\+/g," ");x.append(decodeURIComponent(S),decodeURIComponent(T))}}),x}function U(w){var x=new f,$=w.replace(/\r?\n[\t ]+/g," ");return $.split("\r").map(function(R){return R.indexOf(`
|
148
|
+
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:720,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function tf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Vu);return new s.Image}return new Image}const xl=Ei(async function(e){return e?new Promise((t,i)=>{tf().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{i(n)},r.src=e})}):null});async function wo({element:s,meta:e},t,i){var r,n,o;let a={...s};const{node:A}=s;if((A==null?void 0:A.type)==="video"&&((r=A==null?void 0:A.value)!=null&&r.src||(n=A==null?void 0:A.value)!=null&&n.playlist)){const l=await t(A.value,e);let c;try{c=await xl(A.value.poster)}catch{c=null}a={...a,node:{...A,video:l,poster:c,meta:await i(A.value,l.node,e)}}}if((A==null?void 0:A.type)==="image"&&A.value){let l;try{l=await xl(A.value)}catch{l=null}a={...a,node:{...A,image:l}}}return a.node&&((o=s.node)!=null&&o.elements)&&(a.node.elements=await Promise.all(s.node.elements.map(l=>wo({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>wo({element:l,meta:e},t,i)))),a}async function Xr(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Vu),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function er(s=[]){var e;for(const t of s){if(((e=t==null?void 0:t.node)==null?void 0:e.type)==="video")return t.node;const i=er(t==null?void 0:t.elements);if(i)return i}}function sf(s,e){return s.reduce((t,i,r)=>[...t,i.map(({duration:n},o)=>r===s.length-1&&o===i.length-1?n:n-e)],[])}function rf(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let e=s;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(s)===e}function nf(s){return s.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function zr(s){return s.flatMap(e=>e).reduce((e,t)=>e+t,0)}const of=Ei(()=>ul.loadYoga());Io.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${nf(s)}"`:rf(s)||Array.isArray(s)?JSON.stringify(s):s);const cs=(s,e,t)=>Io.render(s,e,Io.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function hs({data:s,template:e,burnCaptions:t=!1,debug:i=!1},r,n,o){var a,A,l,c;const h=await of(),u=e??ef;if(!((a=u.templates)!=null&&a.length))throw new Error(`No templates found for template instance: ${u.id}`);let d=u.templates.find(({version:L})=>L===Ro);if(!d){const L=u.templates.map(({version:G})=>`"${G}"`).join(", ");console.warn(`Template renderer expects template version "${Ro}" but got ${L}`),d=u.templates[u.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:L,root:G})=>{const F={...u.options,...s,intro:u.intro,outro:u.outro};async function U(j,J){return Promise.all(L.map(async({layout:z,duration:w,data:x,derived:$,options:R})=>{var S,T,K;const M={...F,_index:J,_root:j,_derived:await r({data:s,rootData:j,index:J})},q=x?JSON.parse(await cs(x,M)):{},ie=$?JSON.parse(await cs($,M)):{},ce=R?JSON.parse(await cs(R,M)):{},ae=w?parseFloat(await cs(w,M)):NaN,me=(S=d.layouts.find(ve=>ve.name===z))==null?void 0:S.tree;if(!me)throw new Error(`Layout tree "${z}" not found in template "${d.id}" layouts.`);const Qe=JSON.parse(await cs(me,{...q,...ie,...ce})),Te=await Promise.all(Qe.flatMap(ve=>wo({element:ve,meta:u.meta},n,o))),re=er(Te);return{duration:(isNaN(ae)?null:ae)??((T=re==null?void 0:re.meta)==null?void 0:T.duration)??0,captions:(K=re==null?void 0:re.meta)==null?void 0:K.captions,elements:Te}}))}if(G){const j=JSON.parse(await cs(G,F));return Array.isArray(j)?(await Promise.all(j.map(async(J,z)=>U(J,z)))).flatMap(J=>J):U(j,null)}return U(s,null)}));if(g.every(L=>L.every(G=>{const F=er(G.elements);return!(F!=null&&F.value.src)&&!(F!=null&&F.value.playlist)}))){const L=g.flatMap(G=>G.map(F=>{const U=er(F.elements);return!(U!=null&&U.value.src)&&!(U!=null&&U.value.playlist)&&(U==null?void 0:U.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${L} failed to load, video can not be processed`)}if(g.every(L=>L.every(G=>G.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((L,G)=>{const F=G.filter(U=>U.duration>0);return F.length>0&&(L=[...L,F]),L},[]),y=((A=u.meta)==null?void 0:A.frameRate)??30,b=((l=u.meta)==null?void 0:l.resolution)??720,C=((c=u.meta)==null?void 0:c.transitionDuration)??1/3,Q=sf(v,C),B=zr(Q);return{scenes:(await Promise.all(v.map((L,G)=>{const F=zr(Q[G]),U=zr(Q.slice(0,G));return Promise.all(L.map(async({duration:j,captions:J,elements:z},w)=>{var x,$;const R=await Xr(),S=await Xr(),T=await Xr(),K=await Xr(),M=er(z),q=zr([...Q.slice(0,G),...Q[G].slice(0,w)]);return{draw:({canvas:ce,currentTime:ae})=>{const me=Math.max(0,ae-U),Qe=Math.max(0,ae-q);So({yoga:h,debug:i,canvas:ce,cropCanvas:R,posterCanvas:K,letterboxCanvas:S,elements:z,currentTime:ae,contentTime:me,sceneTime:Qe,totalDuration:B,contentDuration:F,sceneDuration:j}),J&&t&&Zg({canvas:ce,dx:0,dy:0,dw:ce.width,dh:ce.height,vttCaptions:J,sceneTime:Qe+((M==null?void 0:M.meta.start)??0)})},duration:j,transitionCanvas:T,start:q,video:M==null?void 0:M.video,videoMeta:M==null?void 0:M.meta,audio:{duration:j,src:(x=M==null?void 0:M.value)==null?void 0:x.src,start:($=M==null?void 0:M.meta)==null?void 0:$.start}}}))}))).flatMap(L=>L),frameRate:y,resolution:b,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Ro="3",af={name:"@vouchfor/embeds",version:"2.0.18",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},engines:{node:">=18.18.0"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js","test:watch":"yarn test --watch"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/canvas-video":"^8.0.4","@vouchfor/media-player":"^3.0.18",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.2"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^4.0.0","@storybook/addon-essentials":"^8.0.4","@storybook/addon-links":"^8.0.4","@storybook/blocks":"^8.0.4","@storybook/web-components":"^8.0.4","@storybook/web-components-vite":"^8.0.4","@svgr/core":"^8.1.0","@types/flat":"^5.0.5","@types/mocha":"^10.0.6","@vouchfor/eslint-config":"^1.0.1","@vouchfor/prettier-config":"^1.0.1","@vouchfor/video-utils":"^1.0.9","@web/dev-server-esbuild":"^1.0.2","@web/test-runner":"^0.18.1","@web/test-runner-browserstack":"^0.7.1","@web/test-runner-mocha":"^0.9.0","@web/test-runner-playwright":"^0.11.0",glob:"^10.3.10","lint-staged":"^15.2.2",lit:"^3.1.2",lodash:"^4.17.21",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-tla":"^0.0.2",sinon:"^17.0.1",storybook:"^8.0.4",svgson:"^5.3.1",typescript:"^5.4.3",vite:"^5.2.2","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.7.3","web-component-analyzer":"^2.0.0"}};function Af(s){const{publicApiUrl:e}=Dr(s),t=Di();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function lf(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Di()};let e=(o=(n=window.localStorage)==null?void 0:n.getItem)==null?void 0:o.call(n,"vouch-uid-visitor"),t=(A=(a=window.localStorage)==null?void 0:a.getItem)==null?void 0:A.call(a,"vouch-uid-client"),i=(c=(l=window.sessionStorage)==null?void 0:l.getItem)==null?void 0:c.call(l,"vouch-uid-tab");const r=Di();return e||(e=Af(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Di(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Di(),(p=(f=window.sessionStorage)==null?void 0:f.setItem)==null||p.call(f,"vouch-uid-tab",i)),{client:t,tab:i,request:r,visitor:e}}function cf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function hf(s="embedded_player"){var r,n;const[e,t]=((n=(r=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:r.split)==null?void 0:n.call(r,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([o,a])=>{if(/utm/.test(o)){const A=o.toLowerCase().replace(/[-_][a-z0-9]/g,l=>l.slice(-1).toUpperCase());i[A]=a}}),{source:s,time:new Date,region:t,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:af.version,templateVersion:Ro,...i}}const Tl=1;class uf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=cf(i,this.host.vouch);!r||this.host.disableTracking||this._batchedEvents.push({event:t,payload:{...i,vouchId:r,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:t}=Dr(this.host.env),{client:i,tab:r,request:n,visitor:o}=lf(this.host.env);navigator.sendBeacon(`${t}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":r,"x-uid-request":n,"x-uid-visitor":o,"x-reporting-metadata":hf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Tl&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:t})=>{t&&(this._hasLoaded[t]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:t}),this._hasLoaded[t]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:t,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:t}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:t,key:i,node:r}})=>{var n,o;!this.host.paused&&t===((o=(n=this.host.scene)==null?void 0:n.video)==null?void 0:o.id)&&(this._currentlyPlayingVideo={id:t,key:i,node:r},this._streamLatestTime[i]=r.currentTime,this._streamStartTime[i]||(this._streamStartTime[i]=r.currentTime,this._streamLatestTime[i]=r.currentTime))},this._handleVideoPause=({detail:{id:t,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+Tl&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]},this._pageUnloading=()=>{this._streamEnded(),this._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=e,e.addController(this)}hostConnected(){requestAnimationFrame(()=>{var e,t,i,r;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.addEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var e,t,i,r;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.removeEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}var xo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Mr<"u"&&Mr,i=function(){function n(){this.fetch=!1,this.DOMException=t.DOMException}return n.prototype=t,new n}();(function(n){(function(o){var a=typeof n<"u"&&n||typeof self<"u"&&self||typeof a<"u"&&a,A={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function l(w){return w&&DataView.prototype.isPrototypeOf(w)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(w){return w&&c.indexOf(Object.prototype.toString.call(w))>-1};function u(w){if(typeof w!="string"&&(w=String(w)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(w)||w==="")throw new TypeError('Invalid character in header field name: "'+w+'"');return w.toLowerCase()}function d(w){return typeof w!="string"&&(w=String(w)),w}function g(w){var x={next:function(){var $=w.shift();return{done:$===void 0,value:$}}};return A.iterable&&(x[Symbol.iterator]=function(){return x}),x}function f(w){this.map={},w instanceof f?w.forEach(function(x,$){this.append($,x)},this):Array.isArray(w)?w.forEach(function(x){this.append(x[0],x[1])},this):w&&Object.getOwnPropertyNames(w).forEach(function(x){this.append(x,w[x])},this)}f.prototype.append=function(w,x){w=u(w),x=d(x);var $=this.map[w];this.map[w]=$?$+", "+x:x},f.prototype.delete=function(w){delete this.map[u(w)]},f.prototype.get=function(w){return w=u(w),this.has(w)?this.map[w]:null},f.prototype.has=function(w){return this.map.hasOwnProperty(u(w))},f.prototype.set=function(w,x){this.map[u(w)]=d(x)},f.prototype.forEach=function(w,x){for(var $ in this.map)this.map.hasOwnProperty($)&&w.call(x,this.map[$],$,this)},f.prototype.keys=function(){var w=[];return this.forEach(function(x,$){w.push($)}),g(w)},f.prototype.values=function(){var w=[];return this.forEach(function(x){w.push(x)}),g(w)},f.prototype.entries=function(){var w=[];return this.forEach(function(x,$){w.push([$,x])}),g(w)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(w){if(w.bodyUsed)return Promise.reject(new TypeError("Already read"));w.bodyUsed=!0}function v(w){return new Promise(function(x,$){w.onload=function(){x(w.result)},w.onerror=function(){$(w.error)}})}function y(w){var x=new FileReader,$=v(x);return x.readAsArrayBuffer(w),$}function b(w){var x=new FileReader,$=v(x);return x.readAsText(w),$}function C(w){for(var x=new Uint8Array(w),$=new Array(x.length),R=0;R<x.length;R++)$[R]=String.fromCharCode(x[R]);return $.join("")}function Q(w){if(w.slice)return w.slice(0);var x=new Uint8Array(w.byteLength);return x.set(new Uint8Array(w)),x.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(w){this.bodyUsed=this.bodyUsed,this._bodyInit=w,w?typeof w=="string"?this._bodyText=w:A.blob&&Blob.prototype.isPrototypeOf(w)?this._bodyBlob=w:A.formData&&FormData.prototype.isPrototypeOf(w)?this._bodyFormData=w:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)?this._bodyText=w.toString():A.arrayBuffer&&A.blob&&l(w)?(this._bodyArrayBuffer=Q(w.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(w)||h(w))?this._bodyArrayBuffer=Q(w):this._bodyText=w=Object.prototype.toString.call(w):this._bodyText="",this.headers.get("content-type")||(typeof w=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):A.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var w=p(this);if(w)return w;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var w=p(this);return w||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(y)}),this.text=function(){var w=p(this);if(w)return w;if(this._bodyBlob)return b(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(C(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},A.formData&&(this.formData=function(){return this.text().then(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var _=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function L(w){var x=w.toUpperCase();return _.indexOf(x)>-1?x:w}function G(w,x){if(!(this instanceof G))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');x=x||{};var $=x.body;if(w instanceof G){if(w.bodyUsed)throw new TypeError("Already read");this.url=w.url,this.credentials=w.credentials,x.headers||(this.headers=new f(w.headers)),this.method=w.method,this.mode=w.mode,this.signal=w.signal,!$&&w._bodyInit!=null&&($=w._bodyInit,w.bodyUsed=!0)}else this.url=String(w);if(this.credentials=x.credentials||this.credentials||"same-origin",(x.headers||!this.headers)&&(this.headers=new f(x.headers)),this.method=L(x.method||this.method||"GET"),this.mode=x.mode||this.mode||null,this.signal=x.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&$)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody($),(this.method==="GET"||this.method==="HEAD")&&(x.cache==="no-store"||x.cache==="no-cache")){var R=/([?&])_=[^&]*/;if(R.test(this.url))this.url=this.url.replace(R,"$1_="+new Date().getTime());else{var S=/\?/;this.url+=(S.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}G.prototype.clone=function(){return new G(this,{body:this._bodyInit})};function F(w){var x=new FormData;return w.trim().split("&").forEach(function($){if($){var R=$.split("="),S=R.shift().replace(/\+/g," "),T=R.join("=").replace(/\+/g," ");x.append(decodeURIComponent(S),decodeURIComponent(T))}}),x}function U(w){var x=new f,$=w.replace(/\r?\n[\t ]+/g," ");return $.split("\r").map(function(R){return R.indexOf(`
|
149
149
|
`)===0?R.substr(1,R.length):R}).forEach(function(R){var S=R.split(":"),T=S.shift().trim();if(T){var K=S.join(":").trim();x.append(T,K)}}),x}B.call(G.prototype);function j(w,x){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');x||(x={}),this.type="default",this.status=x.status===void 0?200:x.status,this.ok=this.status>=200&&this.status<300,this.statusText=x.statusText===void 0?"":""+x.statusText,this.headers=new f(x.headers),this.url=x.url||"",this._initBody(w)}B.call(j.prototype),j.prototype.clone=function(){return new j(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},j.error=function(){var w=new j(null,{status:0,statusText:""});return w.type="error",w};var J=[301,302,303,307,308];j.redirect=function(w,x){if(J.indexOf(x)===-1)throw new RangeError("Invalid status code");return new j(null,{status:x,headers:{location:w}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(x,$){this.message=x,this.name=$;var R=Error(x);this.stack=R.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function z(w,x){return new Promise(function($,R){var S=new G(w,x);if(S.signal&&S.signal.aborted)return R(new o.DOMException("Aborted","AbortError"));var T=new XMLHttpRequest;function K(){T.abort()}T.onload=function(){var q={status:T.status,statusText:T.statusText,headers:U(T.getAllResponseHeaders()||"")};q.url="responseURL"in T?T.responseURL:q.headers.get("X-Request-URL");var ie="response"in T?T.response:T.responseText;setTimeout(function(){$(new j(ie,q))},0)},T.onerror=function(){setTimeout(function(){R(new TypeError("Network request failed"))},0)},T.ontimeout=function(){setTimeout(function(){R(new TypeError("Network request failed"))},0)},T.onabort=function(){setTimeout(function(){R(new o.DOMException("Aborted","AbortError"))},0)};function M(q){try{return q===""&&a.location.href?a.location.href:q}catch{return q}}T.open(S.method,M(S.url),!0),S.credentials==="include"?T.withCredentials=!0:S.credentials==="omit"&&(T.withCredentials=!1),"responseType"in T&&(A.blob?T.responseType="blob":A.arrayBuffer&&S.headers.get("Content-Type")&&S.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(T.responseType="arraybuffer")),x&&typeof x.headers=="object"&&!(x.headers instanceof f)?Object.getOwnPropertyNames(x.headers).forEach(function(q){T.setRequestHeader(q,d(x.headers[q]))}):S.headers.forEach(function(q,ie){T.setRequestHeader(ie,q)}),S.signal&&(S.signal.addEventListener("abort",K),T.onreadystatechange=function(){T.readyState===4&&S.signal.removeEventListener("abort",K)}),T.send(typeof S._bodyInit>"u"?null:S._bodyInit)})}return z.polyfill=!0,a.fetch||(a.fetch=z,a.Headers=f,a.Request=G,a.Response=j),o.Headers=f,o.Request=G,o.Response=j,o.fetch=z,o})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var r=t.fetch?t:i;e=r.fetch,e.default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,s.exports=e})(xo,xo.exports);var df=xo.exports;const Dl=hl(df);async function gf(s){var e;try{if((e=await Dl(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function Ll({sources:s}){let e=null;const t=s==null?void 0:s.filter(Boolean),i=t==null?void 0:t.find(n=>n.startsWith("blob:")),r=t==null?void 0:t.find(n=>!n.startsWith("http")&&!n.startsWith("blob:"));if(i||r)return i??r;if(t.length>0){const n=t.map(o=>gf(o));e=(await Promise.all(n)).find(Boolean)}return e}async function ff(s){try{return(await Dl(s)).text()}catch{return null}}async function pf(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?ff(s):s}const Ef=Ei(async({original:s,translation:e,originalLanguage:t="",translationLanguage:i=""},{language:r})=>{var n,o;const a={[(n=i==null?void 0:i.split("-"))==null?void 0:n[0]]:e,[(o=t==null?void 0:t.split("-"))==null?void 0:o[0]]:s},A=(r&&a[r])??s;return A?pf(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})});async function If(s){var e,t,i,r,n,o;const a=(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,A=(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input,l=(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist;return{src:await Ll({sources:[a,A]}),playlist:await Ll({sources:[l]})}}function mf(s){var e,t,i,r,n,o,a,A,l,c,h,u;const d=((t=(e=s==null?void 0:s.answer)==null?void 0:e.contact)==null?void 0:t.name)==="Anonymous"?"":((n=(r=(i=s==null?void 0:s.answer)==null?void 0:i.contact)==null?void 0:r.name)==null?void 0:n.trim())??"",g=((A=(a=(o=s==null?void 0:s.answer)==null?void 0:o.contact)==null?void 0:a.client)==null?void 0:A.name)==="Not Supplied"?"":((u=(h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.contact)==null?void 0:c.client)==null?void 0:h.name)==null?void 0:u.trim())??"",[f,p]=d.split(" ");return{name:d,firstName:f,lastName:p,companyName:g}}async function To({rootData:s,index:e},t){var i,r,n,o,a,A,l,c,h,u,d,g,f,p;return{...mf(s),...await If(s),key:`${s==null?void 0:s.id}-${e}`,captions:await Ef({original:((r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.captions)??((o=(n=s==null?void 0:s.answer)==null?void 0:n.captions)==null?void 0:o.current),translation:((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.translation)??((c=(l=s==null?void 0:s.answer)==null?void 0:l.captions)==null?void 0:c.translation),originalLanguage:(u=(h=s==null?void 0:s.answer)==null?void 0:h.transcription)==null?void 0:u.language,translationLanguage:(f=(g=(d=s==null?void 0:s.answer)==null?void 0:d.transcription)==null?void 0:g.translation)==null?void 0:f.language},t),answerLabel:((p=s==null?void 0:s.answer)==null?void 0:p.label)??(s==null?void 0:s.title)}}const Zr={af:"Afrikaans",sq:"Albanian",am:"Amharic",ar:"Arabic",hy:"Armenian",az:"Azerbaijani",eu:"Basque",be:"Belarusian",bn:"Bengali",bs:"Bosnian",bg:"Bulgarian",ca:"Catalan",zh:"Chinese (Simplified)",zh_TW:"Chinese (Traditional)",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch",en:"English",et:"Estonian",fi:"Finnish",fr:"French",fa:"Farsi",tl:"Filipino",ka:"Georgian",de:"German",el:"Greek",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",ga:"Irish",it:"Italian",ja:"Japanese",kn:"Kannada",kk:"Kazakh",ko:"Korean",lv:"Latvian",lt:"Lithuanian",mk:"Macedonian",ms:"Malay",ml:"Malayalam",mt:"Maltese",mr:"Marathi",mn:"Mongolian",no:"Norwegian",ps:"Pashto",pl:"Polish",pt:"Portuguese",pa:"Punjabi",ro:"Romanian",ru:"Russian",sr:"Serbian",si:"Sinhala",sk:"Slovak",sl:"Slovenian",so:"Somali",es:"Spanish",sw:"Swahili",sv:"Swedish",ta:"Tamil",te:"Telugu",th:"Thai",tr:"Turkish",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",vi:"Vietnamese",cy:"Welsh"};function Cf({data:s}){var e,t;return((t=(e=s==null?void 0:s.questions)==null?void 0:e.items)==null?void 0:t.reduce((i,r)=>{var n,o,a,A,l,c,h;const u=(a=(o=(n=r==null?void 0:r.answer)==null?void 0:n.transcription)==null?void 0:o.language)==null?void 0:a.split("-")[0],d=(h=(c=(l=(A=r==null?void 0:r.answer)==null?void 0:A.transcription)==null?void 0:l.translation)==null?void 0:c.language)==null?void 0:h.split("-")[0];return u&&Zr[u]&&!i.find(g=>g.value===u)&&i.push({value:u,label:Zr[u]}),d&&Zr[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:Zr[d]}),i},[]))??[]}/**
|
150
150
|
* @license
|
151
151
|
* Copyright 2018 Google LLC
|
@@ -1440,7 +1440,7 @@ ${e}`,Ng=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Mg=Objec
|
|
1440
1440
|
vmp-captions.hiddenControls {
|
1441
1441
|
transform: translateY(calc(var(--space-small) * -1));
|
1442
1442
|
}
|
1443
|
-
`],ht([V({type:Boolean})],st.prototype,"loading",2),ht([V({type:Boolean})],st.prototype,"playing",2),ht([V({type:Number})],st.prototype,"volume",2),ht([V({type:Boolean})],st.prototype,"muted",2),ht([V({type:Number})],st.prototype,"currentTime",2),ht([V({type:Number})],st.prototype,"duration",2),ht([V({type:Array})],st.prototype,"languages",2),ht([V({type:String})],st.prototype,"language",2),ht([V({type:Array,attribute:!1})],st.prototype,"levels",2),ht([V({type:Number})],st.prototype,"level",2),ht([V({type:Number})],st.prototype,"playbackRate",2),ht([V({type:String})],st.prototype,"caption",2),ht([V({type:Array})],st.prototype,"buffer",2),ht([V({type:Boolean})],st.prototype,"captions",2),ht([V({type:Boolean})],st.prototype,"fullscreen",2),ht([V({type:Array})],st.prototype,"controls",2),ht([ze()],st.prototype,"showControls",2),st=ht([bt("vmp-player-overlay")],st);var mv=Object.defineProperty,Cv=Object.getOwnPropertyDescriptor,Ye=(s,e,t,i)=>{for(var r=i>1?void 0:i?Cv(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(r=(i?o(e,t,r):o(r))||r);return i&&r&&mv(e,t,r),r};const vv=1e3/60;let Oe=class extends Me{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Bo,this.dataResolver=To,this.languageResolver=Cf,this._sceneController=new TC(this),this._drawController=new bC(this),this._observer=null,this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._seekerTimeout=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=dt(),this._canvasRef=dt(),this._pageHidden=document.visibilityState==="hidden",this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],this._seeking=!1,this._language=this.propLanguage,this._languages=[],this._captions=!1,this._fullscreen=!1,this._initialised=null,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{var s;(s=this.shadowRoot)!=null&&s.host&&!this.propAspectRatio&&(this._aspectRatio=this.shadowRoot.host.clientWidth/this.shadowRoot.host.clientHeight)},this._handleCanvasResize=()=>{this.draw()},this._loop=()=>{this._endLoop(),this._pageHidden?this._seekerTimeout=setTimeout(this._seeker,vv):this._seekerRAF=requestAnimationFrame(this._seeker)},this._endLoop=()=>{this._seekerRAF&&cancelAnimationFrame(this._seekerRAF),this._seekerTimeout&&clearTimeout(this._seekerTimeout),this._seekerRAF=null,this._seekerTimeout=null},this._seeker=(s=performance.now())=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:e})=>{if(e){const{key:t}=e,i=this.videoState[t];return!i||!i.initialised||i.waiting||e.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),s-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(s-(this._lastTimestamp??s))/1e3*this.playbackRate,this._lastTimestamp=s),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||this._loop()},this._handleError=s=>{this._errors=[...this.errors,s.error],s.error.fatal&&this.pause()},this._handleFullscreenChange=()=>{this===document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1},this._handleVisibilityChange=()=>{this._pageHidden=document.visibilityState==="hidden",this.paused||this._loop()}}get aspectRatio(){return this._aspectRatio}get processing(){return this._processing}get waiting(){return!this.paused&&this._waiting}get errors(){return this._errors}get seeking(){return this._seeking}get language(){return this._language}get languages(){return this._languages}get captions(){return this._captions}get fullscreen(){return this._fullscreen}get initialised(){return this._initialised=this._initialised??new Promise(s=>{const e=setInterval(()=>{!!this.errors.find(i=>i.fatal)&&s(!1),!this.loading&&!this.processing&&this.scenes.length>0&&s(!0)},500);setTimeout(()=>{clearInterval(e),s(!1)},60*1e3)}),this._initialised}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var s;return((s=this._sceneController.scenes)==null?void 0:s.scenes)??[]}get sceneConfig(){return this._sceneController.scenes}get videos(){return this._sceneController.videos??{}}get videoState(){return this._sceneController.videoState}get sceneVideoState(){return this.scenes.reduce((s,{video:e,start:t,duration:i})=>{const r=(e==null?void 0:e.key)??`${t}-${i}`;return s[r]=this.videoState[r],s},{})}set paused(s){s!==this._paused&&(this._paused=s,this.requestUpdate(),this.dispatchEvent(new CustomEvent(s?"pause":"play")))}get paused(){return this._paused}set playbackRate(s){s!==this._playbackRate&&(this._playbackRate=s,this.scenes.forEach(({video:e})=>{e&&(e.node.playbackRate=s)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:s})))}get playbackRate(){return this._playbackRate}set volume(s){const e=Math.min(1,Math.max(0,s));e!==this._volume&&(this.scenes.forEach(({video:t})=>{t&&(t.node.volume=e)}),localStorage.setItem("vmp-player-volume",e.toString()),this._volume=e,e>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(s){this.scenes.forEach(({video:e})=>{e&&(e.node.muted=s)}),s!==this._muted&&(this._muted=s,localStorage.setItem("vmp-player-muted",s.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(s){s!==this._videoResolution&&(this._videoResolution=s,this.scenes.forEach(({video:e})=>{if(e!=null&&e.hls){const t=e.hls.levels.findIndex(i=>Math.min(i.height,i.width)===s);e.hls.currentLevel=t??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(s){s!==this._drawController.currentTime&&(this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s))}get currentTime(){return this._drawController.currentTime}reset(s=0,e=!1){this._lastTimestamp=null,this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s),e?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._loop()}pause(){this._endLoop(),this.paused=!0,this.scenes.forEach(({video:s})=>{s&&s.node.pause()})}draw(s){return this._drawController.draw(s)}setScene(s){var e,t;if((e=this._sceneController)!=null&&e.scenes){const i=(t=this.scenes)==null?void 0:t[s];if(!i){const r=new Ai(`No scene at index: ${s}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:r,message:r.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(s){s??this.fullscreen?LC():this._playerRef.value&&DC(this._playerRef.value)}connectedCallback(){var s;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),document.addEventListener("visibilitychange",this._handleVisibilityChange),(s=this.shadowRoot)!=null&&s.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(s){s.has("propAspectRatio")&&(this._aspectRatio=this.propAspectRatio),s.has("propLanguage")&&(this._language=this.propLanguage)}updated(s){s.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.
|
1443
|
+
`],ht([V({type:Boolean})],st.prototype,"loading",2),ht([V({type:Boolean})],st.prototype,"playing",2),ht([V({type:Number})],st.prototype,"volume",2),ht([V({type:Boolean})],st.prototype,"muted",2),ht([V({type:Number})],st.prototype,"currentTime",2),ht([V({type:Number})],st.prototype,"duration",2),ht([V({type:Array})],st.prototype,"languages",2),ht([V({type:String})],st.prototype,"language",2),ht([V({type:Array,attribute:!1})],st.prototype,"levels",2),ht([V({type:Number})],st.prototype,"level",2),ht([V({type:Number})],st.prototype,"playbackRate",2),ht([V({type:String})],st.prototype,"caption",2),ht([V({type:Array})],st.prototype,"buffer",2),ht([V({type:Boolean})],st.prototype,"captions",2),ht([V({type:Boolean})],st.prototype,"fullscreen",2),ht([V({type:Array})],st.prototype,"controls",2),ht([ze()],st.prototype,"showControls",2),st=ht([bt("vmp-player-overlay")],st);var mv=Object.defineProperty,Cv=Object.getOwnPropertyDescriptor,Ye=(s,e,t,i)=>{for(var r=i>1?void 0:i?Cv(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(r=(i?o(e,t,r):o(r))||r);return i&&r&&mv(e,t,r),r};const vv=1e3/60;let Oe=class extends Me{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Bo,this.dataResolver=To,this.languageResolver=Cf,this._sceneController=new TC(this),this._drawController=new bC(this),this._observer=null,this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._seekerTimeout=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=dt(),this._canvasRef=dt(),this._pageHidden=document.visibilityState==="hidden",this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],this._seeking=!1,this._language=this.propLanguage,this._languages=[],this._captions=!1,this._fullscreen=!1,this._initialised=null,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{var s;(s=this.shadowRoot)!=null&&s.host&&!this.propAspectRatio&&(this._aspectRatio=this.shadowRoot.host.clientWidth/this.shadowRoot.host.clientHeight)},this._handleCanvasResize=()=>{this.draw()},this._loop=()=>{this._endLoop(),this._pageHidden?this._seekerTimeout=setTimeout(this._seeker,vv):this._seekerRAF=requestAnimationFrame(this._seeker)},this._endLoop=()=>{this._seekerRAF&&cancelAnimationFrame(this._seekerRAF),this._seekerTimeout&&clearTimeout(this._seekerTimeout),this._seekerRAF=null,this._seekerTimeout=null},this._seeker=(s=performance.now())=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:e})=>{if(e){const{key:t}=e,i=this.videoState[t];return!i||!i.initialised||i.waiting||e.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),s-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(s-(this._lastTimestamp??s))/1e3*this.playbackRate,this._lastTimestamp=s),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||this._loop()},this._handleError=s=>{this._errors=[...this.errors,s.error],s.error.fatal&&this.pause()},this._handleFullscreenChange=()=>{this===document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1},this._handleVisibilityChange=()=>{this._pageHidden=document.visibilityState==="hidden",this.paused||this._loop()}}get aspectRatio(){return this._aspectRatio}get processing(){return this._processing}get waiting(){return!this.paused&&this._waiting}get errors(){return this._errors}get seeking(){return this._seeking}get language(){return this._language}get languages(){return this._languages}get captions(){return this._captions}get fullscreen(){return this._fullscreen}get initialised(){return this._initialised=this._initialised??new Promise(s=>{const e=setInterval(()=>{!!this.errors.find(i=>i.fatal)&&s(!1),!this.loading&&!this.processing&&this.scenes.length>0&&s(!0)},500);setTimeout(()=>{clearInterval(e),s(!1)},60*1e3)}),this._initialised}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var s;return((s=this._sceneController.scenes)==null?void 0:s.scenes)??[]}get sceneConfig(){return this._sceneController.scenes}get videos(){return this._sceneController.videos??{}}get videoState(){return this._sceneController.videoState}get sceneVideoState(){return this.scenes.reduce((s,{video:e,start:t,duration:i})=>{const r=(e==null?void 0:e.key)??`${t}-${i}`;return s[r]=this.videoState[r],s},{})}set paused(s){s!==this._paused&&(this._paused=s,this.requestUpdate(),this.dispatchEvent(new CustomEvent(s?"pause":"play")))}get paused(){return this._paused}set playbackRate(s){s!==this._playbackRate&&(this._playbackRate=s,this.scenes.forEach(({video:e})=>{e&&(e.node.playbackRate=s)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:s})))}get playbackRate(){return this._playbackRate}set volume(s){const e=Math.min(1,Math.max(0,s));e!==this._volume&&(this.scenes.forEach(({video:t})=>{t&&(t.node.volume=e)}),localStorage.setItem("vmp-player-volume",e.toString()),this._volume=e,e>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(s){this.scenes.forEach(({video:e})=>{e&&(e.node.muted=s)}),s!==this._muted&&(this._muted=s,localStorage.setItem("vmp-player-muted",s.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(s){s!==this._videoResolution&&(this._videoResolution=s,this.scenes.forEach(({video:e})=>{if(e!=null&&e.hls){const t=e.hls.levels.findIndex(i=>Math.min(i.height,i.width)===s);e.hls.currentLevel=t??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(s){s!==this._drawController.currentTime&&(this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s))}get currentTime(){return this._drawController.currentTime}reset(s=0,e=!1){this._lastTimestamp=null,this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s),e?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._loop()}pause(){this._endLoop(),this.paused=!0,this.scenes.forEach(({video:s})=>{s&&s.node.pause()})}draw(s){return this._drawController.draw(s)}setScene(s){var e,t;if((e=this._sceneController)!=null&&e.scenes){const i=(t=this.scenes)==null?void 0:t[s];if(!i){const r=new Ai(`No scene at index: ${s}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:r,message:r.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(s){s??this.fullscreen?LC():this._playerRef.value&&DC(this._playerRef.value)}connectedCallback(){var s;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),document.addEventListener("visibilitychange",this._handleVisibilityChange),(s=this.shadowRoot)!=null&&s.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(s){s.has("propAspectRatio")&&(this._aspectRatio=this.propAspectRatio),s.has("propLanguage")&&(this._language=this.propLanguage)}updated(s){s.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this._sceneController.hasPlayed&&!this.processing&&s.get("_processing")&&this.play()}disconnectedCallback(){var s;super.disconnectedCallback(),(s=this._observer)==null||s.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange),document.removeEventListener("visibilitychange",this._handleVisibilityChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?pe`
|
1444
1444
|
<style>
|
1445
1445
|
:host {
|
1446
1446
|
aspect-ratio: ${this.propAspectRatio};
|