@vouchfor/embeds 3.0.0 → 3.0.2
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/dist/es/embeds.js +4 -4
- package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +2 -1
- package/dist/es/src/components/PlayerEmbed/tests/media-data.d.ts +19 -0
- package/dist/iife/dialog-embed/embed.iife.js +1 -1
- package/dist/iife/embeds.iife.js +1 -1
- package/dist/iife/player-embed/embed.iife.js +1 -1
- package/package.json +4 -4
- package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +7 -0
- package/src/components/PlayerEmbed/tests/data.ts +99 -58
- package/src/components/PlayerEmbed/tests/media-data.ts +22 -0
package/dist/es/embeds.js
CHANGED
|
@@ -196,7 +196,7 @@ class FetcherController {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
const name = "@vouchfor/embeds";
|
|
199
|
-
const version = "3.0.
|
|
199
|
+
const version = "3.0.2";
|
|
200
200
|
const license = "MIT";
|
|
201
201
|
const author = "Aaron Williams";
|
|
202
202
|
const main = "dist/es/embeds.js";
|
|
@@ -238,8 +238,8 @@ const scripts = {
|
|
|
238
238
|
const dependencies = {
|
|
239
239
|
"@a11y/focus-trap": "^1.0.5",
|
|
240
240
|
"@lit/task": "^1.0.0",
|
|
241
|
-
"@vouchfor/canvas-video": "^8.2.
|
|
242
|
-
"@vouchfor/media-player": "^4.0.
|
|
241
|
+
"@vouchfor/canvas-video": "^8.2.1",
|
|
242
|
+
"@vouchfor/media-player": "^4.0.2",
|
|
243
243
|
uuid: "^9.0.1"
|
|
244
244
|
};
|
|
245
245
|
const peerDependencies = {
|
|
@@ -258,7 +258,7 @@ const devDependencies = {
|
|
|
258
258
|
"@types/mocha": "^10.0.6",
|
|
259
259
|
"@vouchfor/eslint-config": "^1.0.1",
|
|
260
260
|
"@vouchfor/prettier-config": "^1.0.1",
|
|
261
|
-
"@vouchfor/video-utils": "^1.2.
|
|
261
|
+
"@vouchfor/video-utils": "^1.2.1",
|
|
262
262
|
"@web/dev-server-esbuild": "^1.0.2",
|
|
263
263
|
"@web/test-runner": "^0.18.1",
|
|
264
264
|
"@web/test-runner-browserstack": "^0.7.1",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const VIDEOA: {
|
|
2
|
+
mp4: string;
|
|
3
|
+
m3u8: string;
|
|
4
|
+
jpg: string;
|
|
5
|
+
duration: number;
|
|
6
|
+
};
|
|
7
|
+
declare const VIDEOB: {
|
|
8
|
+
mp4: string;
|
|
9
|
+
m3u8: string;
|
|
10
|
+
jpg: string;
|
|
11
|
+
duration: number;
|
|
12
|
+
};
|
|
13
|
+
declare const VIDEOC: {
|
|
14
|
+
mp4: string;
|
|
15
|
+
m3u8: string;
|
|
16
|
+
jpg: string;
|
|
17
|
+
duration: number;
|
|
18
|
+
};
|
|
19
|
+
export { VIDEOA, VIDEOB, VIDEOC };
|
|
@@ -149,7 +149,7 @@ ${e}`,Gg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Hg=Objec
|
|
|
149
149
|
"playlist": {{ it._derived?.playlist }},
|
|
150
150
|
"preview": {{ it._derived?.preview }},
|
|
151
151
|
"captions": {{ it._derived?.captions }}
|
|
152
|
-
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:1080,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function uf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Xu);return new s.Image}return new Image}const Fl=Kt(async function(e){return e?new Promise((t,i)=>{uf().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{i(n)},r.src=e})}):null});async function Do({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 Fl(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 Fl(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=>Do({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>Do({element:l,meta:e},t,i)))),a}async function en(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Xu),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function ir(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=ir(t==null?void 0:t.elements);if(i)return i}}function df(s,e){return s.reduce((t,i,r)=>[...t,i.map((n,o)=>n.map(({duration:a},A)=>r===s.length-1&&o===i.length-1&&A===n.length-1?a:a-e))],[])}function gf(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 ff(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 tn(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const pf=Kt(()=>El.loadYoga());vo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${ff(s)}"`:gf(s)||Array.isArray(s)?JSON.stringify(s):s);const us=(s,e,t)=>vo.render(s,e,vo.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function ds({data:s,template:e,burnCaptions:t=!1,debug:i=!1},r,n,o){var a,A,l,c;const h=await pf(),u=e??hf;if(!((a=u.templates)!=null&&a.length))throw new Error(`No templates found for template instance: ${u.id}`);let d=u.templates.find(({version:k})=>k===Lo);if(!d){const k=u.templates.map(({version:O})=>`"${O}"`).join(", ");console.warn(`Template renderer expects template version "${Lo}" but got ${k}`),d=u.templates[u.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:k,root:O})=>{const X={...u.options,...s,intro:u.intro,outro:u.outro};async function V(q,S){return Promise.all(k.map(async({layout:R,duration:G,data:x,derived:w,options:T})=>{var $,U,j;const ie={...X,_index:S,_root:q,_derived:await r({data:s,rootData:q,index:S})},he=x?JSON.parse(await us(x,ie)):{},re=w?JSON.parse(await us(w,ie)):{},ve=T?JSON.parse(await us(T,ie)):{},Qe=G?parseFloat(await us(G,ie)):NaN,be=($=d.layouts.find(le=>le.name===R))==null?void 0:$.tree;if(!be)throw new Error(`Layout tree "${R}" not found in template "${d.id}" layouts.`);const ne=JSON.parse(await us(be,{...he,...re,...ve})),fe=await Promise.all(ne.flatMap(le=>Do({element:le,meta:u.meta},n,o))),Ce=ir(fe);return{duration:(isNaN(Qe)?null:Qe)??((U=Ce==null?void 0:Ce.meta)==null?void 0:U.duration)??0,captions:(j=Ce==null?void 0:Ce.meta)==null?void 0:j.captions,elements:fe}}))}if(O){const q=JSON.parse(await us(O,X));return Array.isArray(q)?Promise.all(q.map(async(S,R)=>V(S,R))):Promise.all([V(q,null)])}return Promise.all([V(s,null)])}));if(g.every(k=>k.every(O=>O.every(X=>{const V=ir(X.elements);return!(V!=null&&V.value.src)&&!(V!=null&&V.value.playlist)})))){const k=g.flatMap(O=>O.flatMap(X=>X.map(V=>{const q=ir(V.elements);return!(q!=null&&q.value.src)&&!(q!=null&&q.value.playlist)&&(q==null?void 0:q.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${k} failed to load, video can not be processed`)}if(g.every(k=>k.every(O=>O.every(X=>X.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((k,O)=>{const X=O.reduce((V,q)=>{const S=q.filter(R=>R.duration>0);return S.length>0?[...V,S]:V},[]);return X.length>0?[...k,X]:k},[]),y=((A=u.meta)==null?void 0:A.frameRate)??30,b=((l=u.meta)==null?void 0:l.resolution)??1080,C=((c=u.meta)==null?void 0:c.transitionDuration)??1/3,Q=df(v,C),B=tn(Q),L=await Promise.all(v.map((k,O)=>{const X=tn(Q[O]),V=tn(Q.slice(0,O));return Promise.all(k.map((q,S)=>Promise.all(q.map(async({duration:R,captions:G,elements:x},w)=>{var T,$;const U=await en(),j=await en(),ie=await en(),he=await en(),re=ir(x),ve=tn([...Q.slice(0,O),...Q[O].slice(0,S),...Q[O][S].slice(0,w)]);return{draw:({canvas:be,currentTime:ne})=>{const fe=Math.max(0,ne-V),Ce=Math.max(0,ne-ve);To({yoga:h,debug:i,canvas:be,cropCanvas:U,posterCanvas:he,letterboxCanvas:j,elements:x,currentTime:ne,contentTime:fe,sceneTime:Ce,totalDuration:B,contentDuration:X,sceneDuration:R}),G&&t&&of({canvas:be,dx:0,dy:0,dw:be.width,dh:be.height,vttCaptions:G,sceneTime:Ce+((re==null?void 0:re.meta.start)??0)})},duration:R,transitionCanvas:ie,id:cf(),start:ve,video:re==null?void 0:re.video,videoMeta:re==null?void 0:re.meta,audio:{duration:R,src:(T=re==null?void 0:re.value)==null?void 0:T.src,start:($=re==null?void 0:re.meta)==null?void 0:$.start}}}))))})),_=L.flatMap(k=>k);return{scenes:_.flatMap(k=>k),sections:_,contents:L,frameRate:y,resolution:b,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Lo="3",Ef={name:"@vouchfor/embeds",version:"3.0.0",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.2.0","@vouchfor/media-player":"^4.0.0",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.2.0","@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 If(s){const{publicApiUrl:e}=_r(s),t=_i();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function mf(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:_i()};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=_i();return e||(e=If(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=_i(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=_i(),(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 vf(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:Ef.version,templateVersion:Lo,...i}}const Nl=1;class yf{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}=_r(this.host.env),{client:i,tab:r,request:n,visitor:o}=mf(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":vf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Nl&&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]+Nl&&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 _o={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Pr<"u"&&Pr,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(S){return S&&DataView.prototype.isPrototypeOf(S)}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(S){return S&&c.indexOf(Object.prototype.toString.call(S))>-1};function u(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(S)||S==="")throw new TypeError('Invalid character in header field name: "'+S+'"');return S.toLowerCase()}function d(S){return typeof S!="string"&&(S=String(S)),S}function g(S){var R={next:function(){var G=S.shift();return{done:G===void 0,value:G}}};return A.iterable&&(R[Symbol.iterator]=function(){return R}),R}function f(S){this.map={},S instanceof f?S.forEach(function(R,G){this.append(G,R)},this):Array.isArray(S)?S.forEach(function(R){this.append(R[0],R[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(R){this.append(R,S[R])},this)}f.prototype.append=function(S,R){S=u(S),R=d(R);var G=this.map[S];this.map[S]=G?G+", "+R:R},f.prototype.delete=function(S){delete this.map[u(S)]},f.prototype.get=function(S){return S=u(S),this.has(S)?this.map[S]:null},f.prototype.has=function(S){return this.map.hasOwnProperty(u(S))},f.prototype.set=function(S,R){this.map[u(S)]=d(R)},f.prototype.forEach=function(S,R){for(var G in this.map)this.map.hasOwnProperty(G)&&S.call(R,this.map[G],G,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(R,G){S.push(G)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(R){S.push(R)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(R,G){S.push([G,R])}),g(S)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function v(S){return new Promise(function(R,G){S.onload=function(){R(S.result)},S.onerror=function(){G(S.error)}})}function y(S){var R=new FileReader,G=v(R);return R.readAsArrayBuffer(S),G}function b(S){var R=new FileReader,G=v(R);return R.readAsText(S),G}function C(S){for(var R=new Uint8Array(S),G=new Array(R.length),x=0;x<R.length;x++)G[x]=String.fromCharCode(R[x]);return G.join("")}function Q(S){if(S.slice)return S.slice(0);var R=new Uint8Array(S.byteLength);return R.set(new Uint8Array(S)),R.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(S){this.bodyUsed=this.bodyUsed,this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:A.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:A.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():A.arrayBuffer&&A.blob&&l(S)?(this._bodyArrayBuffer=Q(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=Q(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="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(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var S=p(this);if(S)return S;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 S=p(this);return S||(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 S=p(this);if(S)return S;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(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var R=S.toUpperCase();return L.indexOf(R)>-1?R:S}function K(S,R){if(!(this instanceof K))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var G=R.body;if(S instanceof K){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,R.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!G&&S._bodyInit!=null&&(G=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new f(R.headers)),this.method=_(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&G)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(G),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var x=/([?&])_=[^&]*/;if(x.test(this.url))this.url=this.url.replace(x,"$1_="+new Date().getTime());else{var w=/\?/;this.url+=(w.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}K.prototype.clone=function(){return new K(this,{body:this._bodyInit})};function k(S){var R=new FormData;return S.trim().split("&").forEach(function(G){if(G){var x=G.split("="),w=x.shift().replace(/\+/g," "),T=x.join("=").replace(/\+/g," ");R.append(decodeURIComponent(w),decodeURIComponent(T))}}),R}function O(S){var R=new f,G=S.replace(/\r?\n[\t ]+/g," ");return G.split("\r").map(function(x){return x.indexOf(`
|
|
152
|
+
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:1080,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function uf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Xu);return new s.Image}return new Image}const Fl=Kt(async function(e){return e?new Promise((t,i)=>{uf().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{i(n)},r.src=e})}):null});async function Do({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 Fl(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 Fl(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=>Do({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>Do({element:l,meta:e},t,i)))),a}async function en(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Xu),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function ir(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=ir(t==null?void 0:t.elements);if(i)return i}}function df(s,e){return s.reduce((t,i,r)=>[...t,i.map((n,o)=>n.map(({duration:a},A)=>r===s.length-1&&o===i.length-1&&A===n.length-1?a:a-e))],[])}function gf(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 ff(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 tn(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const pf=Kt(()=>El.loadYoga());vo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${ff(s)}"`:gf(s)||Array.isArray(s)?JSON.stringify(s):s);const us=(s,e,t)=>vo.render(s,e,vo.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function ds({data:s,template:e,burnCaptions:t=!1,debug:i=!1},r,n,o){var a,A,l,c;const h=await pf(),u=e??hf;if(!((a=u.templates)!=null&&a.length))throw new Error(`No templates found for template instance: ${u.id}`);let d=u.templates.find(({version:k})=>k===Lo);if(!d){const k=u.templates.map(({version:O})=>`"${O}"`).join(", ");console.warn(`Template renderer expects template version "${Lo}" but got ${k}`),d=u.templates[u.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:k,root:O})=>{const X={...u.options,...s,intro:u.intro,outro:u.outro};async function V(q,S){return Promise.all(k.map(async({layout:R,duration:G,data:x,derived:w,options:T})=>{var $,U,j;const ie={...X,_index:S,_root:q,_derived:await r({data:s,rootData:q,index:S})},he=x?JSON.parse(await us(x,ie)):{},re=w?JSON.parse(await us(w,ie)):{},ve=T?JSON.parse(await us(T,ie)):{},Qe=G?parseFloat(await us(G,ie)):NaN,be=($=d.layouts.find(le=>le.name===R))==null?void 0:$.tree;if(!be)throw new Error(`Layout tree "${R}" not found in template "${d.id}" layouts.`);const ne=JSON.parse(await us(be,{...he,...re,...ve})),fe=await Promise.all(ne.flatMap(le=>Do({element:le,meta:u.meta},n,o))),Ce=ir(fe);return{duration:(isNaN(Qe)?null:Qe)??((U=Ce==null?void 0:Ce.meta)==null?void 0:U.duration)??0,captions:(j=Ce==null?void 0:Ce.meta)==null?void 0:j.captions,elements:fe}}))}if(O){const q=JSON.parse(await us(O,X));return Array.isArray(q)?Promise.all(q.map(async(S,R)=>V(S,R))):Promise.all([V(q,null)])}return Promise.all([V(s,null)])}));if(g.every(k=>k.every(O=>O.every(X=>{const V=ir(X.elements);return!(V!=null&&V.value.src)&&!(V!=null&&V.value.playlist)})))){const k=g.flatMap(O=>O.flatMap(X=>X.map(V=>{const q=ir(V.elements);return!(q!=null&&q.value.src)&&!(q!=null&&q.value.playlist)&&(q==null?void 0:q.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${k} failed to load, video can not be processed`)}if(g.every(k=>k.every(O=>O.every(X=>X.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((k,O)=>{const X=O.reduce((V,q)=>{const S=q.filter(R=>R.duration>0);return S.length>0?[...V,S]:V},[]);return X.length>0?[...k,X]:k},[]),y=((A=u.meta)==null?void 0:A.frameRate)??30,b=((l=u.meta)==null?void 0:l.resolution)??1080,C=((c=u.meta)==null?void 0:c.transitionDuration)??1/3,Q=df(v,C),B=tn(Q),L=await Promise.all(v.map((k,O)=>{const X=tn(Q[O]),V=tn(Q.slice(0,O));return Promise.all(k.map((q,S)=>Promise.all(q.map(async({duration:R,captions:G,elements:x},w)=>{var T,$;const U=await en(),j=await en(),ie=await en(),he=await en(),re=ir(x),ve=tn([...Q.slice(0,O),...Q[O].slice(0,S),...Q[O][S].slice(0,w)]);return{draw:({canvas:be,currentTime:ne})=>{const fe=Math.max(0,ne-V),Ce=Math.max(0,ne-ve);To({yoga:h,debug:i,canvas:be,cropCanvas:U,posterCanvas:he,letterboxCanvas:j,elements:x,currentTime:ne,contentTime:fe,sceneTime:Ce,totalDuration:B,contentDuration:X,sceneDuration:R}),G&&t&&of({canvas:be,dx:0,dy:0,dw:be.width,dh:be.height,vttCaptions:G,sceneTime:Ce+((re==null?void 0:re.meta.start)??0)})},duration:R,transitionCanvas:ie,id:cf(),start:ve,video:re==null?void 0:re.video,videoMeta:re==null?void 0:re.meta,audio:{duration:R,src:(T=re==null?void 0:re.value)==null?void 0:T.src,start:($=re==null?void 0:re.meta)==null?void 0:$.start}}}))))})),_=L.flatMap(k=>k);return{scenes:_.flatMap(k=>k),sections:_,contents:L,frameRate:y,resolution:b,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Lo="3",Ef={name:"@vouchfor/embeds",version:"3.0.2",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.2.1","@vouchfor/media-player":"^4.0.2",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.2.1","@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 If(s){const{publicApiUrl:e}=_r(s),t=_i();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function mf(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:_i()};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=_i();return e||(e=If(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=_i(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=_i(),(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 vf(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:Ef.version,templateVersion:Lo,...i}}const Nl=1;class yf{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}=_r(this.host.env),{client:i,tab:r,request:n,visitor:o}=mf(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":vf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Nl&&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]+Nl&&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 _o={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Pr<"u"&&Pr,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(S){return S&&DataView.prototype.isPrototypeOf(S)}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(S){return S&&c.indexOf(Object.prototype.toString.call(S))>-1};function u(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(S)||S==="")throw new TypeError('Invalid character in header field name: "'+S+'"');return S.toLowerCase()}function d(S){return typeof S!="string"&&(S=String(S)),S}function g(S){var R={next:function(){var G=S.shift();return{done:G===void 0,value:G}}};return A.iterable&&(R[Symbol.iterator]=function(){return R}),R}function f(S){this.map={},S instanceof f?S.forEach(function(R,G){this.append(G,R)},this):Array.isArray(S)?S.forEach(function(R){this.append(R[0],R[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(R){this.append(R,S[R])},this)}f.prototype.append=function(S,R){S=u(S),R=d(R);var G=this.map[S];this.map[S]=G?G+", "+R:R},f.prototype.delete=function(S){delete this.map[u(S)]},f.prototype.get=function(S){return S=u(S),this.has(S)?this.map[S]:null},f.prototype.has=function(S){return this.map.hasOwnProperty(u(S))},f.prototype.set=function(S,R){this.map[u(S)]=d(R)},f.prototype.forEach=function(S,R){for(var G in this.map)this.map.hasOwnProperty(G)&&S.call(R,this.map[G],G,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(R,G){S.push(G)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(R){S.push(R)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(R,G){S.push([G,R])}),g(S)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function v(S){return new Promise(function(R,G){S.onload=function(){R(S.result)},S.onerror=function(){G(S.error)}})}function y(S){var R=new FileReader,G=v(R);return R.readAsArrayBuffer(S),G}function b(S){var R=new FileReader,G=v(R);return R.readAsText(S),G}function C(S){for(var R=new Uint8Array(S),G=new Array(R.length),x=0;x<R.length;x++)G[x]=String.fromCharCode(R[x]);return G.join("")}function Q(S){if(S.slice)return S.slice(0);var R=new Uint8Array(S.byteLength);return R.set(new Uint8Array(S)),R.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(S){this.bodyUsed=this.bodyUsed,this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:A.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:A.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():A.arrayBuffer&&A.blob&&l(S)?(this._bodyArrayBuffer=Q(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=Q(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="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(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var S=p(this);if(S)return S;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 S=p(this);return S||(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 S=p(this);if(S)return S;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(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var R=S.toUpperCase();return L.indexOf(R)>-1?R:S}function K(S,R){if(!(this instanceof K))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var G=R.body;if(S instanceof K){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,R.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!G&&S._bodyInit!=null&&(G=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new f(R.headers)),this.method=_(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&G)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(G),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var x=/([?&])_=[^&]*/;if(x.test(this.url))this.url=this.url.replace(x,"$1_="+new Date().getTime());else{var w=/\?/;this.url+=(w.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}K.prototype.clone=function(){return new K(this,{body:this._bodyInit})};function k(S){var R=new FormData;return S.trim().split("&").forEach(function(G){if(G){var x=G.split("="),w=x.shift().replace(/\+/g," "),T=x.join("=").replace(/\+/g," ");R.append(decodeURIComponent(w),decodeURIComponent(T))}}),R}function O(S){var R=new f,G=S.replace(/\r?\n[\t ]+/g," ");return G.split("\r").map(function(x){return x.indexOf(`
|
|
153
153
|
`)===0?x.substr(1,x.length):x}).forEach(function(x){var w=x.split(":"),T=w.shift().trim();if(T){var $=w.join(":").trim();R.append(T,$)}}),R}B.call(K.prototype);function X(S,R){if(!(this instanceof X))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R||(R={}),this.type="default",this.status=R.status===void 0?200:R.status,this.ok=this.status>=200&&this.status<300,this.statusText=R.statusText===void 0?"":""+R.statusText,this.headers=new f(R.headers),this.url=R.url||"",this._initBody(S)}B.call(X.prototype),X.prototype.clone=function(){return new X(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},X.error=function(){var S=new X(null,{status:0,statusText:""});return S.type="error",S};var V=[301,302,303,307,308];X.redirect=function(S,R){if(V.indexOf(R)===-1)throw new RangeError("Invalid status code");return new X(null,{status:R,headers:{location:S}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(R,G){this.message=R,this.name=G;var x=Error(R);this.stack=x.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function q(S,R){return new Promise(function(G,x){var w=new K(S,R);if(w.signal&&w.signal.aborted)return x(new o.DOMException("Aborted","AbortError"));var T=new XMLHttpRequest;function $(){T.abort()}T.onload=function(){var j={status:T.status,statusText:T.statusText,headers:O(T.getAllResponseHeaders()||"")};j.url="responseURL"in T?T.responseURL:j.headers.get("X-Request-URL");var ie="response"in T?T.response:T.responseText;setTimeout(function(){G(new X(ie,j))},0)},T.onerror=function(){setTimeout(function(){x(new TypeError("Network request failed"))},0)},T.ontimeout=function(){setTimeout(function(){x(new TypeError("Network request failed"))},0)},T.onabort=function(){setTimeout(function(){x(new o.DOMException("Aborted","AbortError"))},0)};function U(j){try{return j===""&&a.location.href?a.location.href:j}catch{return j}}T.open(w.method,U(w.url),!0),w.credentials==="include"?T.withCredentials=!0:w.credentials==="omit"&&(T.withCredentials=!1),"responseType"in T&&(A.blob?T.responseType="blob":A.arrayBuffer&&w.headers.get("Content-Type")&&w.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(T.responseType="arraybuffer")),R&&typeof R.headers=="object"&&!(R.headers instanceof f)?Object.getOwnPropertyNames(R.headers).forEach(function(j){T.setRequestHeader(j,d(R.headers[j]))}):w.headers.forEach(function(j,ie){T.setRequestHeader(ie,j)}),w.signal&&(w.signal.addEventListener("abort",$),T.onreadystatechange=function(){T.readyState===4&&w.signal.removeEventListener("abort",$)}),T.send(typeof w._bodyInit>"u"?null:w._bodyInit)})}return q.polyfill=!0,a.fetch||(a.fetch=q,a.Headers=f,a.Request=K,a.Response=X),o.Headers=f,o.Request=K,o.Response=X,o.fetch=q,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})(_o,_o.exports);var Bf=_o.exports;const Ml=pl(Bf);async function Qf(s){var e;try{if((e=await Ml(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function ko({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=>Qf(o));e=(await Promise.all(n)).find(Boolean)}return e}async function bf(s){try{return(await Ml(s)).text()}catch{return null}}async function Sf(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?bf(s):s}const wf=Kt(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?Sf(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})}),Rf=Kt(async s=>{var e,t,i,r,n,o,a,A,l,c,h;const[u,d,g]=await Promise.all([ko({sources:[(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input]}),ko({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),ko({sources:[((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)]})]);return{src:u,playlist:d,preview:g}},{cacheKey:([s])=>{var e,t,i,r,n,o,a,A,l,c,h;return JSON.stringify({video:(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,input:(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input,playlist:(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist,preview:((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)})}});function xf(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}}const Tf=Kt(async(s,e,t)=>{var i,r,n;const o=(i=e==null?void 0:e.answer)==null?void 0:i.id;return((n=(r=s==null?void 0:s.questions)==null?void 0:r.items)==null?void 0:n.reduce((A,l)=>{var c;return((c=l==null?void 0:l.answer)==null?void 0:c.id)===o?(A??0)+1:A},0))<=1?o:`${o}-${t}`},{cacheKey:([s,e,t])=>{var i;return JSON.stringify({index:t,rootData:e,allQuestions:(i=s==null?void 0:s.questions)==null?void 0:i.items})}});async function Fo({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,h,u,d,g,f,p,v;const[y,b,C]=await Promise.all([Tf(s,e,t),Rf(e),wf({original:((n=(r=e==null?void 0:e.answer)==null?void 0:r.media)==null?void 0:n.captions)??((a=(o=e==null?void 0:e.answer)==null?void 0:o.captions)==null?void 0:a.current),translation:((l=(A=e==null?void 0:e.answer)==null?void 0:A.media)==null?void 0:l.translation)??((h=(c=e==null?void 0:e.answer)==null?void 0:c.captions)==null?void 0:h.translation),originalLanguage:(d=(u=e==null?void 0:e.answer)==null?void 0:u.transcription)==null?void 0:d.language,translationLanguage:(p=(f=(g=e==null?void 0:e.answer)==null?void 0:g.transcription)==null?void 0:f.translation)==null?void 0:p.language},i)]);return{...b,...xf(e),key:y,captions:C,answerLabel:((v=e==null?void 0:e.answer)==null?void 0:v.label)??(e==null?void 0:e.title)}}const sn={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 Df({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&&sn[u]&&!i.find(g=>g.value===u)&&i.push({value:u,label:sn[u]}),d&&sn[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:sn[d]}),i},[]))??[]}/**
|
|
154
154
|
* @license
|
|
155
155
|
* Copyright 2018 Google LLC
|
package/dist/iife/embeds.iife.js
CHANGED
|
@@ -149,7 +149,7 @@ ${e}`,Ug=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Gg=Objec
|
|
|
149
149
|
"playlist": {{ it._derived?.playlist }},
|
|
150
150
|
"preview": {{ it._derived?.preview }},
|
|
151
151
|
"captions": {{ it._derived?.captions }}
|
|
152
|
-
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:1080,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function hf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>ju);return new s.Image}return new Image}const kl=Yt(async function(e){return e?new Promise((t,i)=>{hf().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{i(n)},r.src=e})}):null});async function To({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 kl(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 kl(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=>To({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>To({element:l,meta:e},t,i)))),a}async function Zr(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>ju),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function tr(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=tr(t==null?void 0:t.elements);if(i)return i}}function uf(s,e){return s.reduce((t,i,r)=>[...t,i.map((n,o)=>n.map(({duration:a},A)=>r===s.length-1&&o===i.length-1&&A===n.length-1?a:a-e))],[])}function df(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 gf(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 en(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const ff=Yt(()=>pl.loadYoga());Co.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${gf(s)}"`:df(s)||Array.isArray(s)?JSON.stringify(s):s);const hs=(s,e,t)=>Co.render(s,e,Co.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function us({data:s,template:e,burnCaptions:t=!1,debug:i=!1},r,n,o){var a,A,l,c;const h=await ff(),u=e??cf;if(!((a=u.templates)!=null&&a.length))throw new Error(`No templates found for template instance: ${u.id}`);let d=u.templates.find(({version:k})=>k===Do);if(!d){const k=u.templates.map(({version:P})=>`"${P}"`).join(", ");console.warn(`Template renderer expects template version "${Do}" but got ${k}`),d=u.templates[u.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:k,root:P})=>{const X={...u.options,...s,intro:u.intro,outro:u.outro};async function V(q,S){return Promise.all(k.map(async({layout:R,duration:G,data:x,derived:w,options:T})=>{var $,U,j;const ie={...X,_index:S,_root:q,_derived:await r({data:s,rootData:q,index:S})},he=x?JSON.parse(await hs(x,ie)):{},re=w?JSON.parse(await hs(w,ie)):{},ve=T?JSON.parse(await hs(T,ie)):{},be=G?parseFloat(await hs(G,ie)):NaN,Se=($=d.layouts.find(le=>le.name===R))==null?void 0:$.tree;if(!Se)throw new Error(`Layout tree "${R}" not found in template "${d.id}" layouts.`);const ne=JSON.parse(await hs(Se,{...he,...re,...ve})),fe=await Promise.all(ne.flatMap(le=>To({element:le,meta:u.meta},n,o))),Ce=tr(fe);return{duration:(isNaN(be)?null:be)??((U=Ce==null?void 0:Ce.meta)==null?void 0:U.duration)??0,captions:(j=Ce==null?void 0:Ce.meta)==null?void 0:j.captions,elements:fe}}))}if(P){const q=JSON.parse(await hs(P,X));return Array.isArray(q)?Promise.all(q.map(async(S,R)=>V(S,R))):Promise.all([V(q,null)])}return Promise.all([V(s,null)])}));if(g.every(k=>k.every(P=>P.every(X=>{const V=tr(X.elements);return!(V!=null&&V.value.src)&&!(V!=null&&V.value.playlist)})))){const k=g.flatMap(P=>P.flatMap(X=>X.map(V=>{const q=tr(V.elements);return!(q!=null&&q.value.src)&&!(q!=null&&q.value.playlist)&&(q==null?void 0:q.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${k} failed to load, video can not be processed`)}if(g.every(k=>k.every(P=>P.every(X=>X.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((k,P)=>{const X=P.reduce((V,q)=>{const S=q.filter(R=>R.duration>0);return S.length>0?[...V,S]:V},[]);return X.length>0?[...k,X]:k},[]),y=((A=u.meta)==null?void 0:A.frameRate)??30,b=((l=u.meta)==null?void 0:l.resolution)??1080,C=((c=u.meta)==null?void 0:c.transitionDuration)??1/3,Q=uf(v,C),B=en(Q),L=await Promise.all(v.map((k,P)=>{const X=en(Q[P]),V=en(Q.slice(0,P));return Promise.all(k.map((q,S)=>Promise.all(q.map(async({duration:R,captions:G,elements:x},w)=>{var T,$;const U=await Zr(),j=await Zr(),ie=await Zr(),he=await Zr(),re=tr(x),ve=en([...Q.slice(0,P),...Q[P].slice(0,S),...Q[P][S].slice(0,w)]);return{draw:({canvas:Se,currentTime:ne})=>{const fe=Math.max(0,ne-V),Ce=Math.max(0,ne-ve);xo({yoga:h,debug:i,canvas:Se,cropCanvas:U,posterCanvas:he,letterboxCanvas:j,elements:x,currentTime:ne,contentTime:fe,sceneTime:Ce,totalDuration:B,contentDuration:X,sceneDuration:R}),G&&t&&nf({canvas:Se,dx:0,dy:0,dw:Se.width,dh:Se.height,vttCaptions:G,sceneTime:Ce+((re==null?void 0:re.meta.start)??0)})},duration:R,transitionCanvas:ie,id:lf(),start:ve,video:re==null?void 0:re.video,videoMeta:re==null?void 0:re.meta,audio:{duration:R,src:(T=re==null?void 0:re.value)==null?void 0:T.src,start:($=re==null?void 0:re.meta)==null?void 0:$.start}}}))))})),_=L.flatMap(k=>k);return{scenes:_.flatMap(k=>k),sections:_,contents:L,frameRate:y,resolution:b,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Do="3",pf={name:"@vouchfor/embeds",version:"3.0.0",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.2.0","@vouchfor/media-player":"^4.0.0",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.2.0","@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 Ef(s){const{publicApiUrl:e}=Lr(s),t=Li();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function If(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Li()};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=Li();return e||(e=Ef(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Li(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Li(),(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 mf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function Cf(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:pf.version,templateVersion:Do,...i}}const Fl=1;class vf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=mf(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}=Lr(this.host.env),{client:i,tab:r,request:n,visitor:o}=If(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":Cf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Fl&&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]+Fl&&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 Lo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Pr<"u"&&Pr,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(S){return S&&DataView.prototype.isPrototypeOf(S)}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(S){return S&&c.indexOf(Object.prototype.toString.call(S))>-1};function u(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(S)||S==="")throw new TypeError('Invalid character in header field name: "'+S+'"');return S.toLowerCase()}function d(S){return typeof S!="string"&&(S=String(S)),S}function g(S){var R={next:function(){var G=S.shift();return{done:G===void 0,value:G}}};return A.iterable&&(R[Symbol.iterator]=function(){return R}),R}function f(S){this.map={},S instanceof f?S.forEach(function(R,G){this.append(G,R)},this):Array.isArray(S)?S.forEach(function(R){this.append(R[0],R[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(R){this.append(R,S[R])},this)}f.prototype.append=function(S,R){S=u(S),R=d(R);var G=this.map[S];this.map[S]=G?G+", "+R:R},f.prototype.delete=function(S){delete this.map[u(S)]},f.prototype.get=function(S){return S=u(S),this.has(S)?this.map[S]:null},f.prototype.has=function(S){return this.map.hasOwnProperty(u(S))},f.prototype.set=function(S,R){this.map[u(S)]=d(R)},f.prototype.forEach=function(S,R){for(var G in this.map)this.map.hasOwnProperty(G)&&S.call(R,this.map[G],G,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(R,G){S.push(G)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(R){S.push(R)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(R,G){S.push([G,R])}),g(S)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function v(S){return new Promise(function(R,G){S.onload=function(){R(S.result)},S.onerror=function(){G(S.error)}})}function y(S){var R=new FileReader,G=v(R);return R.readAsArrayBuffer(S),G}function b(S){var R=new FileReader,G=v(R);return R.readAsText(S),G}function C(S){for(var R=new Uint8Array(S),G=new Array(R.length),x=0;x<R.length;x++)G[x]=String.fromCharCode(R[x]);return G.join("")}function Q(S){if(S.slice)return S.slice(0);var R=new Uint8Array(S.byteLength);return R.set(new Uint8Array(S)),R.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(S){this.bodyUsed=this.bodyUsed,this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:A.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:A.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():A.arrayBuffer&&A.blob&&l(S)?(this._bodyArrayBuffer=Q(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=Q(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="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(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var S=p(this);if(S)return S;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 S=p(this);return S||(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 S=p(this);if(S)return S;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(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var R=S.toUpperCase();return L.indexOf(R)>-1?R:S}function K(S,R){if(!(this instanceof K))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var G=R.body;if(S instanceof K){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,R.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!G&&S._bodyInit!=null&&(G=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new f(R.headers)),this.method=_(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&G)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(G),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var x=/([?&])_=[^&]*/;if(x.test(this.url))this.url=this.url.replace(x,"$1_="+new Date().getTime());else{var w=/\?/;this.url+=(w.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}K.prototype.clone=function(){return new K(this,{body:this._bodyInit})};function k(S){var R=new FormData;return S.trim().split("&").forEach(function(G){if(G){var x=G.split("="),w=x.shift().replace(/\+/g," "),T=x.join("=").replace(/\+/g," ");R.append(decodeURIComponent(w),decodeURIComponent(T))}}),R}function P(S){var R=new f,G=S.replace(/\r?\n[\t ]+/g," ");return G.split("\r").map(function(x){return x.indexOf(`
|
|
152
|
+
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:1080,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function hf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>ju);return new s.Image}return new Image}const kl=Yt(async function(e){return e?new Promise((t,i)=>{hf().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{i(n)},r.src=e})}):null});async function To({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 kl(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 kl(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=>To({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>To({element:l,meta:e},t,i)))),a}async function Zr(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>ju),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function tr(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=tr(t==null?void 0:t.elements);if(i)return i}}function uf(s,e){return s.reduce((t,i,r)=>[...t,i.map((n,o)=>n.map(({duration:a},A)=>r===s.length-1&&o===i.length-1&&A===n.length-1?a:a-e))],[])}function df(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 gf(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 en(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const ff=Yt(()=>pl.loadYoga());Co.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${gf(s)}"`:df(s)||Array.isArray(s)?JSON.stringify(s):s);const hs=(s,e,t)=>Co.render(s,e,Co.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function us({data:s,template:e,burnCaptions:t=!1,debug:i=!1},r,n,o){var a,A,l,c;const h=await ff(),u=e??cf;if(!((a=u.templates)!=null&&a.length))throw new Error(`No templates found for template instance: ${u.id}`);let d=u.templates.find(({version:k})=>k===Do);if(!d){const k=u.templates.map(({version:P})=>`"${P}"`).join(", ");console.warn(`Template renderer expects template version "${Do}" but got ${k}`),d=u.templates[u.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:k,root:P})=>{const X={...u.options,...s,intro:u.intro,outro:u.outro};async function V(q,S){return Promise.all(k.map(async({layout:R,duration:G,data:x,derived:w,options:T})=>{var $,U,j;const ie={...X,_index:S,_root:q,_derived:await r({data:s,rootData:q,index:S})},he=x?JSON.parse(await hs(x,ie)):{},re=w?JSON.parse(await hs(w,ie)):{},ve=T?JSON.parse(await hs(T,ie)):{},be=G?parseFloat(await hs(G,ie)):NaN,Se=($=d.layouts.find(le=>le.name===R))==null?void 0:$.tree;if(!Se)throw new Error(`Layout tree "${R}" not found in template "${d.id}" layouts.`);const ne=JSON.parse(await hs(Se,{...he,...re,...ve})),fe=await Promise.all(ne.flatMap(le=>To({element:le,meta:u.meta},n,o))),Ce=tr(fe);return{duration:(isNaN(be)?null:be)??((U=Ce==null?void 0:Ce.meta)==null?void 0:U.duration)??0,captions:(j=Ce==null?void 0:Ce.meta)==null?void 0:j.captions,elements:fe}}))}if(P){const q=JSON.parse(await hs(P,X));return Array.isArray(q)?Promise.all(q.map(async(S,R)=>V(S,R))):Promise.all([V(q,null)])}return Promise.all([V(s,null)])}));if(g.every(k=>k.every(P=>P.every(X=>{const V=tr(X.elements);return!(V!=null&&V.value.src)&&!(V!=null&&V.value.playlist)})))){const k=g.flatMap(P=>P.flatMap(X=>X.map(V=>{const q=tr(V.elements);return!(q!=null&&q.value.src)&&!(q!=null&&q.value.playlist)&&(q==null?void 0:q.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${k} failed to load, video can not be processed`)}if(g.every(k=>k.every(P=>P.every(X=>X.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((k,P)=>{const X=P.reduce((V,q)=>{const S=q.filter(R=>R.duration>0);return S.length>0?[...V,S]:V},[]);return X.length>0?[...k,X]:k},[]),y=((A=u.meta)==null?void 0:A.frameRate)??30,b=((l=u.meta)==null?void 0:l.resolution)??1080,C=((c=u.meta)==null?void 0:c.transitionDuration)??1/3,Q=uf(v,C),B=en(Q),L=await Promise.all(v.map((k,P)=>{const X=en(Q[P]),V=en(Q.slice(0,P));return Promise.all(k.map((q,S)=>Promise.all(q.map(async({duration:R,captions:G,elements:x},w)=>{var T,$;const U=await Zr(),j=await Zr(),ie=await Zr(),he=await Zr(),re=tr(x),ve=en([...Q.slice(0,P),...Q[P].slice(0,S),...Q[P][S].slice(0,w)]);return{draw:({canvas:Se,currentTime:ne})=>{const fe=Math.max(0,ne-V),Ce=Math.max(0,ne-ve);xo({yoga:h,debug:i,canvas:Se,cropCanvas:U,posterCanvas:he,letterboxCanvas:j,elements:x,currentTime:ne,contentTime:fe,sceneTime:Ce,totalDuration:B,contentDuration:X,sceneDuration:R}),G&&t&&nf({canvas:Se,dx:0,dy:0,dw:Se.width,dh:Se.height,vttCaptions:G,sceneTime:Ce+((re==null?void 0:re.meta.start)??0)})},duration:R,transitionCanvas:ie,id:lf(),start:ve,video:re==null?void 0:re.video,videoMeta:re==null?void 0:re.meta,audio:{duration:R,src:(T=re==null?void 0:re.value)==null?void 0:T.src,start:($=re==null?void 0:re.meta)==null?void 0:$.start}}}))))})),_=L.flatMap(k=>k);return{scenes:_.flatMap(k=>k),sections:_,contents:L,frameRate:y,resolution:b,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Do="3",pf={name:"@vouchfor/embeds",version:"3.0.2",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.2.1","@vouchfor/media-player":"^4.0.2",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.2.1","@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 Ef(s){const{publicApiUrl:e}=Lr(s),t=Li();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function If(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Li()};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=Li();return e||(e=Ef(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Li(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Li(),(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 mf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function Cf(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:pf.version,templateVersion:Do,...i}}const Fl=1;class vf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=mf(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}=Lr(this.host.env),{client:i,tab:r,request:n,visitor:o}=If(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":Cf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Fl&&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]+Fl&&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 Lo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Pr<"u"&&Pr,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(S){return S&&DataView.prototype.isPrototypeOf(S)}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(S){return S&&c.indexOf(Object.prototype.toString.call(S))>-1};function u(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(S)||S==="")throw new TypeError('Invalid character in header field name: "'+S+'"');return S.toLowerCase()}function d(S){return typeof S!="string"&&(S=String(S)),S}function g(S){var R={next:function(){var G=S.shift();return{done:G===void 0,value:G}}};return A.iterable&&(R[Symbol.iterator]=function(){return R}),R}function f(S){this.map={},S instanceof f?S.forEach(function(R,G){this.append(G,R)},this):Array.isArray(S)?S.forEach(function(R){this.append(R[0],R[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(R){this.append(R,S[R])},this)}f.prototype.append=function(S,R){S=u(S),R=d(R);var G=this.map[S];this.map[S]=G?G+", "+R:R},f.prototype.delete=function(S){delete this.map[u(S)]},f.prototype.get=function(S){return S=u(S),this.has(S)?this.map[S]:null},f.prototype.has=function(S){return this.map.hasOwnProperty(u(S))},f.prototype.set=function(S,R){this.map[u(S)]=d(R)},f.prototype.forEach=function(S,R){for(var G in this.map)this.map.hasOwnProperty(G)&&S.call(R,this.map[G],G,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(R,G){S.push(G)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(R){S.push(R)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(R,G){S.push([G,R])}),g(S)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function v(S){return new Promise(function(R,G){S.onload=function(){R(S.result)},S.onerror=function(){G(S.error)}})}function y(S){var R=new FileReader,G=v(R);return R.readAsArrayBuffer(S),G}function b(S){var R=new FileReader,G=v(R);return R.readAsText(S),G}function C(S){for(var R=new Uint8Array(S),G=new Array(R.length),x=0;x<R.length;x++)G[x]=String.fromCharCode(R[x]);return G.join("")}function Q(S){if(S.slice)return S.slice(0);var R=new Uint8Array(S.byteLength);return R.set(new Uint8Array(S)),R.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(S){this.bodyUsed=this.bodyUsed,this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:A.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:A.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():A.arrayBuffer&&A.blob&&l(S)?(this._bodyArrayBuffer=Q(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=Q(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="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(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var S=p(this);if(S)return S;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 S=p(this);return S||(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 S=p(this);if(S)return S;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(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var R=S.toUpperCase();return L.indexOf(R)>-1?R:S}function K(S,R){if(!(this instanceof K))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var G=R.body;if(S instanceof K){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,R.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!G&&S._bodyInit!=null&&(G=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new f(R.headers)),this.method=_(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&G)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(G),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var x=/([?&])_=[^&]*/;if(x.test(this.url))this.url=this.url.replace(x,"$1_="+new Date().getTime());else{var w=/\?/;this.url+=(w.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}K.prototype.clone=function(){return new K(this,{body:this._bodyInit})};function k(S){var R=new FormData;return S.trim().split("&").forEach(function(G){if(G){var x=G.split("="),w=x.shift().replace(/\+/g," "),T=x.join("=").replace(/\+/g," ");R.append(decodeURIComponent(w),decodeURIComponent(T))}}),R}function P(S){var R=new f,G=S.replace(/\r?\n[\t ]+/g," ");return G.split("\r").map(function(x){return x.indexOf(`
|
|
153
153
|
`)===0?x.substr(1,x.length):x}).forEach(function(x){var w=x.split(":"),T=w.shift().trim();if(T){var $=w.join(":").trim();R.append(T,$)}}),R}B.call(K.prototype);function X(S,R){if(!(this instanceof X))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R||(R={}),this.type="default",this.status=R.status===void 0?200:R.status,this.ok=this.status>=200&&this.status<300,this.statusText=R.statusText===void 0?"":""+R.statusText,this.headers=new f(R.headers),this.url=R.url||"",this._initBody(S)}B.call(X.prototype),X.prototype.clone=function(){return new X(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},X.error=function(){var S=new X(null,{status:0,statusText:""});return S.type="error",S};var V=[301,302,303,307,308];X.redirect=function(S,R){if(V.indexOf(R)===-1)throw new RangeError("Invalid status code");return new X(null,{status:R,headers:{location:S}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(R,G){this.message=R,this.name=G;var x=Error(R);this.stack=x.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function q(S,R){return new Promise(function(G,x){var w=new K(S,R);if(w.signal&&w.signal.aborted)return x(new o.DOMException("Aborted","AbortError"));var T=new XMLHttpRequest;function $(){T.abort()}T.onload=function(){var j={status:T.status,statusText:T.statusText,headers:P(T.getAllResponseHeaders()||"")};j.url="responseURL"in T?T.responseURL:j.headers.get("X-Request-URL");var ie="response"in T?T.response:T.responseText;setTimeout(function(){G(new X(ie,j))},0)},T.onerror=function(){setTimeout(function(){x(new TypeError("Network request failed"))},0)},T.ontimeout=function(){setTimeout(function(){x(new TypeError("Network request failed"))},0)},T.onabort=function(){setTimeout(function(){x(new o.DOMException("Aborted","AbortError"))},0)};function U(j){try{return j===""&&a.location.href?a.location.href:j}catch{return j}}T.open(w.method,U(w.url),!0),w.credentials==="include"?T.withCredentials=!0:w.credentials==="omit"&&(T.withCredentials=!1),"responseType"in T&&(A.blob?T.responseType="blob":A.arrayBuffer&&w.headers.get("Content-Type")&&w.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(T.responseType="arraybuffer")),R&&typeof R.headers=="object"&&!(R.headers instanceof f)?Object.getOwnPropertyNames(R.headers).forEach(function(j){T.setRequestHeader(j,d(R.headers[j]))}):w.headers.forEach(function(j,ie){T.setRequestHeader(ie,j)}),w.signal&&(w.signal.addEventListener("abort",$),T.onreadystatechange=function(){T.readyState===4&&w.signal.removeEventListener("abort",$)}),T.send(typeof w._bodyInit>"u"?null:w._bodyInit)})}return q.polyfill=!0,a.fetch||(a.fetch=q,a.Headers=f,a.Request=K,a.Response=X),o.Headers=f,o.Request=K,o.Response=X,o.fetch=q,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})(Lo,Lo.exports);var yf=Lo.exports;const Nl=fl(yf);async function Bf(s){var e;try{if((e=await Nl(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function _o({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=>Bf(o));e=(await Promise.all(n)).find(Boolean)}return e}async function Qf(s){try{return(await Nl(s)).text()}catch{return null}}async function bf(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?Qf(s):s}const Sf=Yt(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?bf(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})}),wf=Yt(async s=>{var e,t,i,r,n,o,a,A,l,c,h;const[u,d,g]=await Promise.all([_o({sources:[(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input]}),_o({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),_o({sources:[((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)]})]);return{src:u,playlist:d,preview:g}},{cacheKey:([s])=>{var e,t,i,r,n,o,a,A,l,c,h;return JSON.stringify({video:(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,input:(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input,playlist:(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist,preview:((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)})}});function Rf(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}}const xf=Yt(async(s,e,t)=>{var i,r,n;const o=(i=e==null?void 0:e.answer)==null?void 0:i.id;return((n=(r=s==null?void 0:s.questions)==null?void 0:r.items)==null?void 0:n.reduce((A,l)=>{var c;return((c=l==null?void 0:l.answer)==null?void 0:c.id)===o?(A??0)+1:A},0))<=1?o:`${o}-${t}`},{cacheKey:([s,e,t])=>{var i;return JSON.stringify({index:t,rootData:e,allQuestions:(i=s==null?void 0:s.questions)==null?void 0:i.items})}});async function ko({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,h,u,d,g,f,p,v;const[y,b,C]=await Promise.all([xf(s,e,t),wf(e),Sf({original:((n=(r=e==null?void 0:e.answer)==null?void 0:r.media)==null?void 0:n.captions)??((a=(o=e==null?void 0:e.answer)==null?void 0:o.captions)==null?void 0:a.current),translation:((l=(A=e==null?void 0:e.answer)==null?void 0:A.media)==null?void 0:l.translation)??((h=(c=e==null?void 0:e.answer)==null?void 0:c.captions)==null?void 0:h.translation),originalLanguage:(d=(u=e==null?void 0:e.answer)==null?void 0:u.transcription)==null?void 0:d.language,translationLanguage:(p=(f=(g=e==null?void 0:e.answer)==null?void 0:g.transcription)==null?void 0:f.translation)==null?void 0:p.language},i)]);return{...b,...Rf(e),key:y,captions:C,answerLabel:((v=e==null?void 0:e.answer)==null?void 0:v.label)??(e==null?void 0:e.title)}}const tn={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 Tf({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&&tn[u]&&!i.find(g=>g.value===u)&&i.push({value:u,label:tn[u]}),d&&tn[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:tn[d]}),i},[]))??[]}/**
|
|
154
154
|
* @license
|
|
155
155
|
* Copyright 2018 Google LLC
|
|
@@ -149,7 +149,7 @@ ${e}`,Dg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Lg=Objec
|
|
|
149
149
|
"playlist": {{ it._derived?.playlist }},
|
|
150
150
|
"preview": {{ it._derived?.preview }},
|
|
151
151
|
"captions": {{ it._derived?.captions }}
|
|
152
|
-
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:1080,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function tf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Uu);return new s.Image}return new Image}const bl=Ut(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 Bo({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 bl(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 bl(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=>Bo({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>Bo({element:l,meta:e},t,i)))),a}async function Jr(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Uu),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function zs(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=zs(t==null?void 0:t.elements);if(i)return i}}function sf(s,e){return s.reduce((t,i,r)=>[...t,i.map((n,o)=>n.map(({duration:a},A)=>r===s.length-1&&o===i.length-1&&A===n.length-1?a:a-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 Wr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const of=Ut(()=>Al.loadYoga());uo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${nf(s)}"`:rf(s)||Array.isArray(s)?JSON.stringify(s):s);const As=(s,e,t)=>uo.render(s,e,uo.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function ls({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:k})=>k===Qo);if(!d){const k=u.templates.map(({version:P})=>`"${P}"`).join(", ");console.warn(`Template renderer expects template version "${Qo}" but got ${k}`),d=u.templates[u.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:k,root:P})=>{const j={...u.options,...s,intro:u.intro,outro:u.outro};async function V(W,b){return Promise.all(k.map(async({layout:R,duration:G,data:x,derived:w,options:T})=>{var $,U,q;const ie={...j,_index:b,_root:W,_derived:await r({data:s,rootData:W,index:b})},he=x?JSON.parse(await As(x,ie)):{},re=w?JSON.parse(await As(w,ie)):{},ve=T?JSON.parse(await As(T,ie)):{},Qe=G?parseFloat(await As(G,ie)):NaN,Se=($=d.layouts.find(le=>le.name===R))==null?void 0:$.tree;if(!Se)throw new Error(`Layout tree "${R}" not found in template "${d.id}" layouts.`);const ne=JSON.parse(await As(Se,{...he,...re,...ve})),fe=await Promise.all(ne.flatMap(le=>Bo({element:le,meta:u.meta},n,o))),me=zs(fe);return{duration:(isNaN(Qe)?null:Qe)??((U=me==null?void 0:me.meta)==null?void 0:U.duration)??0,captions:(q=me==null?void 0:me.meta)==null?void 0:q.captions,elements:fe}}))}if(P){const W=JSON.parse(await As(P,j));return Array.isArray(W)?Promise.all(W.map(async(b,R)=>V(b,R))):Promise.all([V(W,null)])}return Promise.all([V(s,null)])}));if(g.every(k=>k.every(P=>P.every(j=>{const V=zs(j.elements);return!(V!=null&&V.value.src)&&!(V!=null&&V.value.playlist)})))){const k=g.flatMap(P=>P.flatMap(j=>j.map(V=>{const W=zs(V.elements);return!(W!=null&&W.value.src)&&!(W!=null&&W.value.playlist)&&(W==null?void 0:W.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${k} failed to load, video can not be processed`)}if(g.every(k=>k.every(P=>P.every(j=>j.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((k,P)=>{const j=P.reduce((V,W)=>{const b=W.filter(R=>R.duration>0);return b.length>0?[...V,b]:V},[]);return j.length>0?[...k,j]:k},[]),y=((A=u.meta)==null?void 0:A.frameRate)??30,S=((l=u.meta)==null?void 0:l.resolution)??1080,C=((c=u.meta)==null?void 0:c.transitionDuration)??1/3,Q=sf(v,C),B=Wr(Q),L=await Promise.all(v.map((k,P)=>{const j=Wr(Q[P]),V=Wr(Q.slice(0,P));return Promise.all(k.map((W,b)=>Promise.all(W.map(async({duration:R,captions:G,elements:x},w)=>{var T,$;const U=await Jr(),q=await Jr(),ie=await Jr(),he=await Jr(),re=zs(x),ve=Wr([...Q.slice(0,P),...Q[P].slice(0,b),...Q[P][b].slice(0,w)]);return{draw:({canvas:Se,currentTime:ne})=>{const fe=Math.max(0,ne-V),me=Math.max(0,ne-ve);yo({yoga:h,debug:i,canvas:Se,cropCanvas:U,posterCanvas:he,letterboxCanvas:q,elements:x,currentTime:ne,contentTime:fe,sceneTime:me,totalDuration:B,contentDuration:j,sceneDuration:R}),G&&t&&qg({canvas:Se,dx:0,dy:0,dw:Se.width,dh:Se.height,vttCaptions:G,sceneTime:me+((re==null?void 0:re.meta.start)??0)})},duration:R,transitionCanvas:ie,id:Zg(),start:ve,video:re==null?void 0:re.video,videoMeta:re==null?void 0:re.meta,audio:{duration:R,src:(T=re==null?void 0:re.value)==null?void 0:T.src,start:($=re==null?void 0:re.meta)==null?void 0:$.start}}}))))})),_=L.flatMap(k=>k);return{scenes:_.flatMap(k=>k),sections:_,contents:L,frameRate:y,resolution:S,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Qo="3",af={name:"@vouchfor/embeds",version:"3.0.0",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.2.0","@vouchfor/media-player":"^4.0.0",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.2.0","@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}=br(s),t=Gi();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:Gi()};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=Gi();return e||(e=Af(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Gi(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Gi(),(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:Qo,...i}}const wl=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}=br(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]+wl&&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]+wl&&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 So={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Lr<"u"&&Lr,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(b){return b&&DataView.prototype.isPrototypeOf(b)}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(b){return b&&c.indexOf(Object.prototype.toString.call(b))>-1};function u(b){if(typeof b!="string"&&(b=String(b)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(b)||b==="")throw new TypeError('Invalid character in header field name: "'+b+'"');return b.toLowerCase()}function d(b){return typeof b!="string"&&(b=String(b)),b}function g(b){var R={next:function(){var G=b.shift();return{done:G===void 0,value:G}}};return A.iterable&&(R[Symbol.iterator]=function(){return R}),R}function f(b){this.map={},b instanceof f?b.forEach(function(R,G){this.append(G,R)},this):Array.isArray(b)?b.forEach(function(R){this.append(R[0],R[1])},this):b&&Object.getOwnPropertyNames(b).forEach(function(R){this.append(R,b[R])},this)}f.prototype.append=function(b,R){b=u(b),R=d(R);var G=this.map[b];this.map[b]=G?G+", "+R:R},f.prototype.delete=function(b){delete this.map[u(b)]},f.prototype.get=function(b){return b=u(b),this.has(b)?this.map[b]:null},f.prototype.has=function(b){return this.map.hasOwnProperty(u(b))},f.prototype.set=function(b,R){this.map[u(b)]=d(R)},f.prototype.forEach=function(b,R){for(var G in this.map)this.map.hasOwnProperty(G)&&b.call(R,this.map[G],G,this)},f.prototype.keys=function(){var b=[];return this.forEach(function(R,G){b.push(G)}),g(b)},f.prototype.values=function(){var b=[];return this.forEach(function(R){b.push(R)}),g(b)},f.prototype.entries=function(){var b=[];return this.forEach(function(R,G){b.push([G,R])}),g(b)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(b){if(b.bodyUsed)return Promise.reject(new TypeError("Already read"));b.bodyUsed=!0}function v(b){return new Promise(function(R,G){b.onload=function(){R(b.result)},b.onerror=function(){G(b.error)}})}function y(b){var R=new FileReader,G=v(R);return R.readAsArrayBuffer(b),G}function S(b){var R=new FileReader,G=v(R);return R.readAsText(b),G}function C(b){for(var R=new Uint8Array(b),G=new Array(R.length),x=0;x<R.length;x++)G[x]=String.fromCharCode(R[x]);return G.join("")}function Q(b){if(b.slice)return b.slice(0);var R=new Uint8Array(b.byteLength);return R.set(new Uint8Array(b)),R.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(b){this.bodyUsed=this.bodyUsed,this._bodyInit=b,b?typeof b=="string"?this._bodyText=b:A.blob&&Blob.prototype.isPrototypeOf(b)?this._bodyBlob=b:A.formData&&FormData.prototype.isPrototypeOf(b)?this._bodyFormData=b:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(b)?this._bodyText=b.toString():A.arrayBuffer&&A.blob&&l(b)?(this._bodyArrayBuffer=Q(b.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(b)||h(b))?this._bodyArrayBuffer=Q(b):this._bodyText=b=Object.prototype.toString.call(b):this._bodyText="",this.headers.get("content-type")||(typeof b=="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(b)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var b=p(this);if(b)return b;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 b=p(this);return b||(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 b=p(this);if(b)return b;if(this._bodyBlob)return S(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(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(b){var R=b.toUpperCase();return L.indexOf(R)>-1?R:b}function K(b,R){if(!(this instanceof K))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var G=R.body;if(b instanceof K){if(b.bodyUsed)throw new TypeError("Already read");this.url=b.url,this.credentials=b.credentials,R.headers||(this.headers=new f(b.headers)),this.method=b.method,this.mode=b.mode,this.signal=b.signal,!G&&b._bodyInit!=null&&(G=b._bodyInit,b.bodyUsed=!0)}else this.url=String(b);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new f(R.headers)),this.method=_(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&G)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(G),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var x=/([?&])_=[^&]*/;if(x.test(this.url))this.url=this.url.replace(x,"$1_="+new Date().getTime());else{var w=/\?/;this.url+=(w.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}K.prototype.clone=function(){return new K(this,{body:this._bodyInit})};function k(b){var R=new FormData;return b.trim().split("&").forEach(function(G){if(G){var x=G.split("="),w=x.shift().replace(/\+/g," "),T=x.join("=").replace(/\+/g," ");R.append(decodeURIComponent(w),decodeURIComponent(T))}}),R}function P(b){var R=new f,G=b.replace(/\r?\n[\t ]+/g," ");return G.split("\r").map(function(x){return x.indexOf(`
|
|
152
|
+
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:1080,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function tf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Uu);return new s.Image}return new Image}const bl=Ut(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 Bo({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 bl(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 bl(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=>Bo({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>Bo({element:l,meta:e},t,i)))),a}async function Jr(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Uu),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function zs(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=zs(t==null?void 0:t.elements);if(i)return i}}function sf(s,e){return s.reduce((t,i,r)=>[...t,i.map((n,o)=>n.map(({duration:a},A)=>r===s.length-1&&o===i.length-1&&A===n.length-1?a:a-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 Wr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const of=Ut(()=>Al.loadYoga());uo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${nf(s)}"`:rf(s)||Array.isArray(s)?JSON.stringify(s):s);const As=(s,e,t)=>uo.render(s,e,uo.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function ls({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:k})=>k===Qo);if(!d){const k=u.templates.map(({version:P})=>`"${P}"`).join(", ");console.warn(`Template renderer expects template version "${Qo}" but got ${k}`),d=u.templates[u.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:k,root:P})=>{const j={...u.options,...s,intro:u.intro,outro:u.outro};async function V(W,b){return Promise.all(k.map(async({layout:R,duration:G,data:x,derived:w,options:T})=>{var $,U,q;const ie={...j,_index:b,_root:W,_derived:await r({data:s,rootData:W,index:b})},he=x?JSON.parse(await As(x,ie)):{},re=w?JSON.parse(await As(w,ie)):{},ve=T?JSON.parse(await As(T,ie)):{},Qe=G?parseFloat(await As(G,ie)):NaN,Se=($=d.layouts.find(le=>le.name===R))==null?void 0:$.tree;if(!Se)throw new Error(`Layout tree "${R}" not found in template "${d.id}" layouts.`);const ne=JSON.parse(await As(Se,{...he,...re,...ve})),fe=await Promise.all(ne.flatMap(le=>Bo({element:le,meta:u.meta},n,o))),me=zs(fe);return{duration:(isNaN(Qe)?null:Qe)??((U=me==null?void 0:me.meta)==null?void 0:U.duration)??0,captions:(q=me==null?void 0:me.meta)==null?void 0:q.captions,elements:fe}}))}if(P){const W=JSON.parse(await As(P,j));return Array.isArray(W)?Promise.all(W.map(async(b,R)=>V(b,R))):Promise.all([V(W,null)])}return Promise.all([V(s,null)])}));if(g.every(k=>k.every(P=>P.every(j=>{const V=zs(j.elements);return!(V!=null&&V.value.src)&&!(V!=null&&V.value.playlist)})))){const k=g.flatMap(P=>P.flatMap(j=>j.map(V=>{const W=zs(V.elements);return!(W!=null&&W.value.src)&&!(W!=null&&W.value.playlist)&&(W==null?void 0:W.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${k} failed to load, video can not be processed`)}if(g.every(k=>k.every(P=>P.every(j=>j.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((k,P)=>{const j=P.reduce((V,W)=>{const b=W.filter(R=>R.duration>0);return b.length>0?[...V,b]:V},[]);return j.length>0?[...k,j]:k},[]),y=((A=u.meta)==null?void 0:A.frameRate)??30,S=((l=u.meta)==null?void 0:l.resolution)??1080,C=((c=u.meta)==null?void 0:c.transitionDuration)??1/3,Q=sf(v,C),B=Wr(Q),L=await Promise.all(v.map((k,P)=>{const j=Wr(Q[P]),V=Wr(Q.slice(0,P));return Promise.all(k.map((W,b)=>Promise.all(W.map(async({duration:R,captions:G,elements:x},w)=>{var T,$;const U=await Jr(),q=await Jr(),ie=await Jr(),he=await Jr(),re=zs(x),ve=Wr([...Q.slice(0,P),...Q[P].slice(0,b),...Q[P][b].slice(0,w)]);return{draw:({canvas:Se,currentTime:ne})=>{const fe=Math.max(0,ne-V),me=Math.max(0,ne-ve);yo({yoga:h,debug:i,canvas:Se,cropCanvas:U,posterCanvas:he,letterboxCanvas:q,elements:x,currentTime:ne,contentTime:fe,sceneTime:me,totalDuration:B,contentDuration:j,sceneDuration:R}),G&&t&&qg({canvas:Se,dx:0,dy:0,dw:Se.width,dh:Se.height,vttCaptions:G,sceneTime:me+((re==null?void 0:re.meta.start)??0)})},duration:R,transitionCanvas:ie,id:Zg(),start:ve,video:re==null?void 0:re.video,videoMeta:re==null?void 0:re.meta,audio:{duration:R,src:(T=re==null?void 0:re.value)==null?void 0:T.src,start:($=re==null?void 0:re.meta)==null?void 0:$.start}}}))))})),_=L.flatMap(k=>k);return{scenes:_.flatMap(k=>k),sections:_,contents:L,frameRate:y,resolution:S,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Qo="3",af={name:"@vouchfor/embeds",version:"3.0.2",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.2.1","@vouchfor/media-player":"^4.0.2",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.2.1","@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}=br(s),t=Gi();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:Gi()};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=Gi();return e||(e=Af(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Gi(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Gi(),(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:Qo,...i}}const wl=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}=br(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]+wl&&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]+wl&&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 So={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Lr<"u"&&Lr,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(b){return b&&DataView.prototype.isPrototypeOf(b)}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(b){return b&&c.indexOf(Object.prototype.toString.call(b))>-1};function u(b){if(typeof b!="string"&&(b=String(b)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(b)||b==="")throw new TypeError('Invalid character in header field name: "'+b+'"');return b.toLowerCase()}function d(b){return typeof b!="string"&&(b=String(b)),b}function g(b){var R={next:function(){var G=b.shift();return{done:G===void 0,value:G}}};return A.iterable&&(R[Symbol.iterator]=function(){return R}),R}function f(b){this.map={},b instanceof f?b.forEach(function(R,G){this.append(G,R)},this):Array.isArray(b)?b.forEach(function(R){this.append(R[0],R[1])},this):b&&Object.getOwnPropertyNames(b).forEach(function(R){this.append(R,b[R])},this)}f.prototype.append=function(b,R){b=u(b),R=d(R);var G=this.map[b];this.map[b]=G?G+", "+R:R},f.prototype.delete=function(b){delete this.map[u(b)]},f.prototype.get=function(b){return b=u(b),this.has(b)?this.map[b]:null},f.prototype.has=function(b){return this.map.hasOwnProperty(u(b))},f.prototype.set=function(b,R){this.map[u(b)]=d(R)},f.prototype.forEach=function(b,R){for(var G in this.map)this.map.hasOwnProperty(G)&&b.call(R,this.map[G],G,this)},f.prototype.keys=function(){var b=[];return this.forEach(function(R,G){b.push(G)}),g(b)},f.prototype.values=function(){var b=[];return this.forEach(function(R){b.push(R)}),g(b)},f.prototype.entries=function(){var b=[];return this.forEach(function(R,G){b.push([G,R])}),g(b)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(b){if(b.bodyUsed)return Promise.reject(new TypeError("Already read"));b.bodyUsed=!0}function v(b){return new Promise(function(R,G){b.onload=function(){R(b.result)},b.onerror=function(){G(b.error)}})}function y(b){var R=new FileReader,G=v(R);return R.readAsArrayBuffer(b),G}function S(b){var R=new FileReader,G=v(R);return R.readAsText(b),G}function C(b){for(var R=new Uint8Array(b),G=new Array(R.length),x=0;x<R.length;x++)G[x]=String.fromCharCode(R[x]);return G.join("")}function Q(b){if(b.slice)return b.slice(0);var R=new Uint8Array(b.byteLength);return R.set(new Uint8Array(b)),R.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(b){this.bodyUsed=this.bodyUsed,this._bodyInit=b,b?typeof b=="string"?this._bodyText=b:A.blob&&Blob.prototype.isPrototypeOf(b)?this._bodyBlob=b:A.formData&&FormData.prototype.isPrototypeOf(b)?this._bodyFormData=b:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(b)?this._bodyText=b.toString():A.arrayBuffer&&A.blob&&l(b)?(this._bodyArrayBuffer=Q(b.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(b)||h(b))?this._bodyArrayBuffer=Q(b):this._bodyText=b=Object.prototype.toString.call(b):this._bodyText="",this.headers.get("content-type")||(typeof b=="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(b)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var b=p(this);if(b)return b;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 b=p(this);return b||(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 b=p(this);if(b)return b;if(this._bodyBlob)return S(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(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(b){var R=b.toUpperCase();return L.indexOf(R)>-1?R:b}function K(b,R){if(!(this instanceof K))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var G=R.body;if(b instanceof K){if(b.bodyUsed)throw new TypeError("Already read");this.url=b.url,this.credentials=b.credentials,R.headers||(this.headers=new f(b.headers)),this.method=b.method,this.mode=b.mode,this.signal=b.signal,!G&&b._bodyInit!=null&&(G=b._bodyInit,b.bodyUsed=!0)}else this.url=String(b);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new f(R.headers)),this.method=_(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&G)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(G),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var x=/([?&])_=[^&]*/;if(x.test(this.url))this.url=this.url.replace(x,"$1_="+new Date().getTime());else{var w=/\?/;this.url+=(w.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}K.prototype.clone=function(){return new K(this,{body:this._bodyInit})};function k(b){var R=new FormData;return b.trim().split("&").forEach(function(G){if(G){var x=G.split("="),w=x.shift().replace(/\+/g," "),T=x.join("=").replace(/\+/g," ");R.append(decodeURIComponent(w),decodeURIComponent(T))}}),R}function P(b){var R=new f,G=b.replace(/\r?\n[\t ]+/g," ");return G.split("\r").map(function(x){return x.indexOf(`
|
|
153
153
|
`)===0?x.substr(1,x.length):x}).forEach(function(x){var w=x.split(":"),T=w.shift().trim();if(T){var $=w.join(":").trim();R.append(T,$)}}),R}B.call(K.prototype);function j(b,R){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R||(R={}),this.type="default",this.status=R.status===void 0?200:R.status,this.ok=this.status>=200&&this.status<300,this.statusText=R.statusText===void 0?"":""+R.statusText,this.headers=new f(R.headers),this.url=R.url||"",this._initBody(b)}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 b=new j(null,{status:0,statusText:""});return b.type="error",b};var V=[301,302,303,307,308];j.redirect=function(b,R){if(V.indexOf(R)===-1)throw new RangeError("Invalid status code");return new j(null,{status:R,headers:{location:b}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(R,G){this.message=R,this.name=G;var x=Error(R);this.stack=x.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function W(b,R){return new Promise(function(G,x){var w=new K(b,R);if(w.signal&&w.signal.aborted)return x(new o.DOMException("Aborted","AbortError"));var T=new XMLHttpRequest;function $(){T.abort()}T.onload=function(){var q={status:T.status,statusText:T.statusText,headers:P(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(){G(new j(ie,q))},0)},T.onerror=function(){setTimeout(function(){x(new TypeError("Network request failed"))},0)},T.ontimeout=function(){setTimeout(function(){x(new TypeError("Network request failed"))},0)},T.onabort=function(){setTimeout(function(){x(new o.DOMException("Aborted","AbortError"))},0)};function U(q){try{return q===""&&a.location.href?a.location.href:q}catch{return q}}T.open(w.method,U(w.url),!0),w.credentials==="include"?T.withCredentials=!0:w.credentials==="omit"&&(T.withCredentials=!1),"responseType"in T&&(A.blob?T.responseType="blob":A.arrayBuffer&&w.headers.get("Content-Type")&&w.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(T.responseType="arraybuffer")),R&&typeof R.headers=="object"&&!(R.headers instanceof f)?Object.getOwnPropertyNames(R.headers).forEach(function(q){T.setRequestHeader(q,d(R.headers[q]))}):w.headers.forEach(function(q,ie){T.setRequestHeader(ie,q)}),w.signal&&(w.signal.addEventListener("abort",$),T.onreadystatechange=function(){T.readyState===4&&w.signal.removeEventListener("abort",$)}),T.send(typeof w._bodyInit>"u"?null:w._bodyInit)})}return W.polyfill=!0,a.fetch||(a.fetch=W,a.Headers=f,a.Request=K,a.Response=j),o.Headers=f,o.Request=K,o.Response=j,o.fetch=W,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})(So,So.exports);var df=So.exports;const Rl=al(df);async function gf(s){var e;try{if((e=await Rl(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function bo({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 Rl(s)).text()}catch{return null}}async function pf(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?ff(s):s}const Ef=Ut(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})}),If=Ut(async s=>{var e,t,i,r,n,o,a,A,l,c,h;const[u,d,g]=await Promise.all([bo({sources:[(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input]}),bo({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),bo({sources:[((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)]})]);return{src:u,playlist:d,preview:g}},{cacheKey:([s])=>{var e,t,i,r,n,o,a,A,l,c,h;return JSON.stringify({video:(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,input:(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input,playlist:(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist,preview:((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)})}});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}}const Cf=Ut(async(s,e,t)=>{var i,r,n;const o=(i=e==null?void 0:e.answer)==null?void 0:i.id;return((n=(r=s==null?void 0:s.questions)==null?void 0:r.items)==null?void 0:n.reduce((A,l)=>{var c;return((c=l==null?void 0:l.answer)==null?void 0:c.id)===o?(A??0)+1:A},0))<=1?o:`${o}-${t}`},{cacheKey:([s,e,t])=>{var i;return JSON.stringify({index:t,rootData:e,allQuestions:(i=s==null?void 0:s.questions)==null?void 0:i.items})}});async function wo({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,h,u,d,g,f,p,v;const[y,S,C]=await Promise.all([Cf(s,e,t),If(e),Ef({original:((n=(r=e==null?void 0:e.answer)==null?void 0:r.media)==null?void 0:n.captions)??((a=(o=e==null?void 0:e.answer)==null?void 0:o.captions)==null?void 0:a.current),translation:((l=(A=e==null?void 0:e.answer)==null?void 0:A.media)==null?void 0:l.translation)??((h=(c=e==null?void 0:e.answer)==null?void 0:c.captions)==null?void 0:h.translation),originalLanguage:(d=(u=e==null?void 0:e.answer)==null?void 0:u.transcription)==null?void 0:d.language,translationLanguage:(p=(f=(g=e==null?void 0:e.answer)==null?void 0:g.transcription)==null?void 0:f.translation)==null?void 0:p.language},i)]);return{...S,...mf(e),key:y,captions:C,answerLabel:((v=e==null?void 0:e.answer)==null?void 0:v.label)??(e==null?void 0:e.title)}}const qr={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 vf({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&&qr[u]&&!i.find(g=>g.value===u)&&i.push({value:u,label:qr[u]}),d&&qr[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:qr[d]}),i},[]))??[]}/**
|
|
154
154
|
* @license
|
|
155
155
|
* Copyright 2018 Google LLC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vouchfor/embeds",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Aaron Williams",
|
|
6
6
|
"main": "dist/es/embeds.js",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@a11y/focus-trap": "^1.0.5",
|
|
48
48
|
"@lit/task": "^1.0.0",
|
|
49
|
-
"@vouchfor/canvas-video": "^8.2.
|
|
50
|
-
"@vouchfor/media-player": "^4.0.
|
|
49
|
+
"@vouchfor/canvas-video": "^8.2.1",
|
|
50
|
+
"@vouchfor/media-player": "^4.0.2",
|
|
51
51
|
"uuid": "^9.0.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@types/mocha": "^10.0.6",
|
|
67
67
|
"@vouchfor/eslint-config": "^1.0.1",
|
|
68
68
|
"@vouchfor/prettier-config": "^1.0.1",
|
|
69
|
-
"@vouchfor/video-utils": "^1.2.
|
|
69
|
+
"@vouchfor/video-utils": "^1.2.1",
|
|
70
70
|
"@web/dev-server-esbuild": "^1.0.2",
|
|
71
71
|
"@web/test-runner": "^0.18.1",
|
|
72
72
|
"@web/test-runner-browserstack": "^0.7.1",
|
|
@@ -56,6 +56,13 @@ describe('Embeds', () => {
|
|
|
56
56
|
expect(sendTrackingSpy.callCount).to.be.eq(0);
|
|
57
57
|
// Destroy node because events are sent when node is removed from the document
|
|
58
58
|
player.remove();
|
|
59
|
+
await waitUntil(
|
|
60
|
+
() => {
|
|
61
|
+
return createTrackingSpy.args[2];
|
|
62
|
+
},
|
|
63
|
+
'Cleanup event has not fired',
|
|
64
|
+
{ timeout: 5000 }
|
|
65
|
+
);
|
|
59
66
|
expect(sendTrackingSpy.callCount).to.be.eq(1);
|
|
60
67
|
expect(createTrackingSpy.args[0]).to.eql([
|
|
61
68
|
'VIDEO_PLAYED',
|
|
@@ -1,67 +1,82 @@
|
|
|
1
1
|
import type { Vouch } from '@vouchfor/video-utils';
|
|
2
2
|
|
|
3
|
+
import { VIDEOA, VIDEOB, VIDEOC } from './media-data';
|
|
4
|
+
|
|
3
5
|
/* eslint-disable max-lines */
|
|
4
|
-
const data = {
|
|
6
|
+
const data: Vouch = {
|
|
5
7
|
id: '85a7f7fb-897c-41a4-be7b-2636cf991f2c',
|
|
6
8
|
hashId: '6JQEIPeStt',
|
|
9
|
+
settings: {
|
|
10
|
+
branding: {
|
|
11
|
+
base: {
|
|
12
|
+
primary: {
|
|
13
|
+
color: '#48aff7',
|
|
14
|
+
text: '#def2ff'
|
|
15
|
+
},
|
|
16
|
+
secondary: {
|
|
17
|
+
color: '#fdbdfa',
|
|
18
|
+
text: '#8b26bf'
|
|
19
|
+
},
|
|
20
|
+
radius: '8px'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
7
24
|
questions: {
|
|
8
25
|
items: [
|
|
9
26
|
{
|
|
10
27
|
id: '5c66bb3a-ed68-41a0-a601-a49865104418',
|
|
11
|
-
title:
|
|
12
|
-
Arabic: خَرَجَ الوَلَدُ.
|
|
13
|
-
Chinese: 简化字不讲理
|
|
14
|
-
Hebrew: עִבְרִית
|
|
15
|
-
Japanese Kanji: 漢字
|
|
16
|
-
Japanese Hiragana: 平仮名
|
|
17
|
-
Japanese Katakana: 片仮名
|
|
18
|
-
Devangari Hindi: ॳॴॶॷऎऒऔ
|
|
19
|
-
Korean Hangul: 정음/正音
|
|
20
|
-
Cyrillic: АБВГДЕЖЗИКЛМН
|
|
21
|
-
Greek: αβγδ`,
|
|
28
|
+
title: "What is the business problem you're trying to solve?",
|
|
22
29
|
answer: {
|
|
23
30
|
id: '5c66bb3a-ed68-41a0-a601-a49865104418',
|
|
24
31
|
label: null,
|
|
25
32
|
metadata: {
|
|
26
|
-
duration:
|
|
33
|
+
duration: VIDEOA.duration
|
|
27
34
|
},
|
|
28
35
|
settings: {
|
|
29
36
|
endOffset: 0,
|
|
30
37
|
startOffset: 0
|
|
31
38
|
},
|
|
32
39
|
media: {
|
|
33
|
-
input:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'https://d2rxhdlm2q91uk.cloudfront.net/TVik9uTMgE/6JQEIPeStt/5c66bb3a-ed68-41a0-a601-a49865104418/5c66bb3a-ed68-41a0-a601-a49865104418_poster.0000001.jpg?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kMnJ4aGRsbTJxOTF1ay5jbG91ZGZyb250Lm5ldC9UVmlrOXVUTWdFLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjIwMTYzMjM0Mjl9fX1dfQ__&Key-Pair-Id=K2SWKOH0FA5F6M&Signature=SGA54MFpy4jaqKJHKEuxRfjk-~NBFAh1tdW9Y6uYJwc0LFjDDgX1sraerSyohmVhj~-QVIrglY5BvglDIhrFcLJWGTkgj4vhyLprk1a7EDckv0HBgp-k1ZKvoDtt3wBOzrL4GicfXBkuMpIu5jv5MY3xemlJj2a6V~h65XJuLO4u-xS~McH6rS3mRxoNl4GcYUVm4upre1DGQx-5Suy6Ateoxl6xxoF8kg5EL02KxkIGiRpwXJTvVmUuVF0rpBj-IE40MfmhLBQ1NNSXiqb3-HjpkKwhYPvB5APVh23mzGmqJ0P3jbr2F1cU4Jvlqsjb6GVP61wGOz9ITeWPZkOy8A__'
|
|
40
|
+
input: VIDEOA.mp4,
|
|
41
|
+
video: VIDEOA.mp4,
|
|
42
|
+
playlist: VIDEOA.m3u8,
|
|
43
|
+
thumbnail: VIDEOA.jpg,
|
|
44
|
+
videos: {
|
|
45
|
+
xs: VIDEOA.mp4
|
|
46
|
+
}
|
|
41
47
|
},
|
|
42
48
|
contact: {
|
|
43
49
|
id: 'b62f62a3-0cd4-4512-9b52-121cb2f3e72f',
|
|
44
50
|
name: 'Aaron Williams',
|
|
51
|
+
roleTitle: 'Software Engineer',
|
|
45
52
|
client: {
|
|
46
53
|
id: '03540d70-1c75-4867-a235-bac842ed6ce4',
|
|
47
54
|
name: 'Not Supplied',
|
|
48
|
-
logoSrc: 'https://
|
|
55
|
+
logoSrc: 'https://vouch-clients.s3.ap-southeast-2.amazonaws.com/vouch/logos/vouch-logotype-teal.png'
|
|
49
56
|
}
|
|
50
57
|
},
|
|
51
58
|
captions: {
|
|
52
59
|
current:
|
|
60
|
+
"WEBVTT\r\n\r\n1\r\n00:00:01.710 --> 00:00:05.250\r\nwe are trying to solve, uh, world hunger.\r\n\r\n2\r\n00:00:05.420 --> 00:00:08.369\r\nI think it's an important goal. Uh, we\r\n\r\n3\r\n00:00:08.380 --> 00:00:09.489\r\nalso would like to get rid of\r\n\r\n4\r\n00:00:09.500 --> 00:00:12.050\r\ntuberculosis. Um, in general. And\r\n\r\n5\r\n00:00:12.060 --> 00:00:15.329\r\nprobably malaria, too. Uh, it's gonna be\r\n\r\n6\r\n00:00:15.340 --> 00:00:17.180\r\na couple of weeks, but I think we can do\r\n\r\n7\r\n00:00:17.190 --> 00:00:17.319\r\nit.\r\n",
|
|
61
|
+
translation:
|
|
53
62
|
'WEBVTT\n\n1\n00:00:01.549 --> 00:00:05.920\n🇯🇵 🙏 こんにちは 藤森 章 です 。 え ? 今 日本 の え ? 東京 に 住ん で\n\n2\n00:00:05.929 --> 00:00:11.359\nいる 高校 三 年 生 です 。 えっと 父親 が 日本 人 で 母親 が は\n\n3\n00:00:11.619 --> 00:00:13.130\nえー 中国 人 な ん です けれど も 。\n\n4\n00:00:13.939 --> 00:00:17.889\nえ ? 上海 に 行っ た 時 に 国際 学校 に 通っ て い た の で 。\n\n5\n00:00:17.899 --> 00:00:20.389\nえー 英語 を 日本 語 、 中国 語 、 三 語 を しゃ ます\n\n6\n00:00:21.030 --> 00:00:23.549\nえー で 、 その 中 で 経験 し た こと な ん です けれど も 、\n\n7\n00:00:24.040 --> 00:00:26.700\n日本 語 の 素晴らしい ところ って いう の は 、\n\n8\n00:00:27.260 --> 00:00:27.809\nやっぱり\n\n9\n00:00:28.489 --> 00:00:31.540\n和歌 に も 見 られる よう な 多彩 な 表現 力 と\n\n10\n00:00:32.349 --> 00:00:33.819\nえ 奥深い\n\n11\n00:00:34.770 --> 00:00:38.520\nえー 、 感情 表現 など に ある と 思い ます 。 えー これ を 見 て\n\n12\n00:00:38.759 --> 00:00:41.599\n日本 語 に 興味 を 持っ た 方 は 、 是非 その\n\n13\n00:00:43.180 --> 00:00:43.770\n奥深い\n\n14\n00:00:44.299 --> 00:00:45.630\n表現 など を え 、\n\n15\n00:00:46.299 --> 00:00:49.209\n見 て 、 感じ て えー 、 触れ て み て ください 。 ありがとう\n\n16\n00:00:49.220 --> 00:00:49.599\nござい まし た 。\n'
|
|
63
|
+
},
|
|
64
|
+
transcription: {
|
|
65
|
+
language: 'en',
|
|
66
|
+
translation: {
|
|
67
|
+
language: 'ja'
|
|
68
|
+
}
|
|
54
69
|
}
|
|
55
70
|
}
|
|
56
71
|
},
|
|
57
72
|
{
|
|
58
73
|
id: '5c66bb3a-ed68-41a0-a601-a49865104418',
|
|
59
|
-
|
|
74
|
+
title: "What is the business problem you're trying to solve?",
|
|
60
75
|
answer: {
|
|
61
76
|
id: '5c66bb3a-ed68-41a0-a601-a49865104418',
|
|
62
|
-
label:
|
|
77
|
+
label: null,
|
|
63
78
|
metadata: {
|
|
64
|
-
duration:
|
|
79
|
+
duration: VIDEOA.duration
|
|
65
80
|
},
|
|
66
81
|
settings: {
|
|
67
82
|
endOffset: 0.385945945945946,
|
|
@@ -74,14 +89,13 @@ const data = {
|
|
|
74
89
|
}
|
|
75
90
|
},
|
|
76
91
|
media: {
|
|
77
|
-
input:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'https://d2rxhdlm2q91uk.cloudfront.net/TVik9uTMgE/6JQEIPeStt/5c66bb3a-ed68-41a0-a601-a49865104418/5c66bb3a-ed68-41a0-a601-a49865104418_poster.0000001.jpg?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kMnJ4aGRsbTJxOTF1ay5jbG91ZGZyb250Lm5ldC9UVmlrOXVUTWdFLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjIwMTYzMjM0Mjl9fX1dfQ__&Key-Pair-Id=K2SWKOH0FA5F6M&Signature=SGA54MFpy4jaqKJHKEuxRfjk-~NBFAh1tdW9Y6uYJwc0LFjDDgX1sraerSyohmVhj~-QVIrglY5BvglDIhrFcLJWGTkgj4vhyLprk1a7EDckv0HBgp-k1ZKvoDtt3wBOzrL4GicfXBkuMpIu5jv5MY3xemlJj2a6V~h65XJuLO4u-xS~McH6rS3mRxoNl4GcYUVm4upre1DGQx-5Suy6Ateoxl6xxoF8kg5EL02KxkIGiRpwXJTvVmUuVF0rpBj-IE40MfmhLBQ1NNSXiqb3-HjpkKwhYPvB5APVh23mzGmqJ0P3jbr2F1cU4Jvlqsjb6GVP61wGOz9ITeWPZkOy8A__'
|
|
92
|
+
input: VIDEOA.mp4,
|
|
93
|
+
video: VIDEOA.mp4,
|
|
94
|
+
playlist: VIDEOA.m3u8,
|
|
95
|
+
thumbnail: VIDEOA.jpg,
|
|
96
|
+
videos: {
|
|
97
|
+
xs: VIDEOA.mp4
|
|
98
|
+
}
|
|
85
99
|
},
|
|
86
100
|
contact: {
|
|
87
101
|
id: 'b62f62a3-0cd4-4512-9b52-121cb2f3e72f',
|
|
@@ -89,12 +103,18 @@ const data = {
|
|
|
89
103
|
roleTitle: 'Software Engineer',
|
|
90
104
|
client: {
|
|
91
105
|
id: '03540d70-1c75-4867-a235-bac842ed6ce4',
|
|
92
|
-
logoSrc: 'https://
|
|
106
|
+
logoSrc: 'https://vouch-clients.s3.ap-southeast-2.amazonaws.com/vouch/logos/vouch-logotype-teal.png'
|
|
93
107
|
}
|
|
94
108
|
},
|
|
95
109
|
captions: {
|
|
96
110
|
current:
|
|
97
111
|
"WEBVTT\r\n\r\n1\r\n00:00:01.710 --> 00:00:05.250\r\nwe are trying to solve, uh, world hunger.\r\n\r\n2\r\n00:00:05.420 --> 00:00:08.369\r\nI think it's an important goal. Uh, we\r\n\r\n3\r\n00:00:08.380 --> 00:00:09.489\r\nalso would like to get rid of\r\n\r\n4\r\n00:00:09.500 --> 00:00:12.050\r\ntuberculosis. Um, in general. And\r\n\r\n5\r\n00:00:12.060 --> 00:00:15.329\r\nprobably malaria, too. Uh, it's gonna be\r\n\r\n6\r\n00:00:15.340 --> 00:00:17.180\r\na couple of weeks, but I think we can do\r\n\r\n7\r\n00:00:17.190 --> 00:00:17.319\r\nit.\r\n"
|
|
112
|
+
},
|
|
113
|
+
transcription: {
|
|
114
|
+
language: 'en',
|
|
115
|
+
translation: {
|
|
116
|
+
language: 'fr'
|
|
117
|
+
}
|
|
98
118
|
}
|
|
99
119
|
}
|
|
100
120
|
},
|
|
@@ -103,23 +123,22 @@ const data = {
|
|
|
103
123
|
title: 'What are the priorities for your business/team this quarter?',
|
|
104
124
|
answer: {
|
|
105
125
|
id: 'e77c81a7-f6ef-4eae-91fc-b620d092d8d6',
|
|
106
|
-
label:
|
|
126
|
+
label: 'Hello this label is overridden',
|
|
107
127
|
metadata: {
|
|
108
|
-
duration:
|
|
128
|
+
duration: VIDEOB.duration
|
|
109
129
|
},
|
|
110
130
|
settings: {
|
|
111
131
|
endOffset: 0,
|
|
112
132
|
startOffset: 0
|
|
113
133
|
},
|
|
114
134
|
media: {
|
|
115
|
-
input:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
'https://d2rxhdlm2q91uk.cloudfront.net/TVik9uTMgE/6JQEIPeStt/e77c81a7-f6ef-4eae-91fc-b620d092d8d6/e77c81a7-f6ef-4eae-91fc-b620d092d8d6_poster.0000001.jpg?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kMnJ4aGRsbTJxOTF1ay5jbG91ZGZyb250Lm5ldC9UVmlrOXVUTWdFLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjIwMTYzMjM0Mjl9fX1dfQ__&Key-Pair-Id=K2SWKOH0FA5F6M&Signature=SGA54MFpy4jaqKJHKEuxRfjk-~NBFAh1tdW9Y6uYJwc0LFjDDgX1sraerSyohmVhj~-QVIrglY5BvglDIhrFcLJWGTkgj4vhyLprk1a7EDckv0HBgp-k1ZKvoDtt3wBOzrL4GicfXBkuMpIu5jv5MY3xemlJj2a6V~h65XJuLO4u-xS~McH6rS3mRxoNl4GcYUVm4upre1DGQx-5Suy6Ateoxl6xxoF8kg5EL02KxkIGiRpwXJTvVmUuVF0rpBj-IE40MfmhLBQ1NNSXiqb3-HjpkKwhYPvB5APVh23mzGmqJ0P3jbr2F1cU4Jvlqsjb6GVP61wGOz9ITeWPZkOy8A__'
|
|
135
|
+
input: VIDEOB.mp4,
|
|
136
|
+
video: VIDEOB.mp4,
|
|
137
|
+
playlist: VIDEOB.m3u8,
|
|
138
|
+
thumbnail: VIDEOB.jpg,
|
|
139
|
+
videos: {
|
|
140
|
+
xs: VIDEOB.mp4
|
|
141
|
+
}
|
|
123
142
|
},
|
|
124
143
|
contact: {
|
|
125
144
|
id: 'b62f62a3-0cd4-4512-9b52-121cb2f3e72f',
|
|
@@ -128,46 +147,61 @@ const data = {
|
|
|
128
147
|
client: {
|
|
129
148
|
id: '03540d70-1c75-4867-a235-bac842ed6ce4',
|
|
130
149
|
name: 'Vouch',
|
|
131
|
-
logoSrc: 'https://
|
|
150
|
+
logoSrc: 'https://vouch-clients.s3.ap-southeast-2.amazonaws.com/vouch/logos/vouch-logotype-teal.png'
|
|
132
151
|
}
|
|
133
152
|
},
|
|
134
153
|
captions: {
|
|
135
154
|
current:
|
|
136
155
|
'WEBVTT\r\n\r\n1\r\n00:00:00.709 --> 00:00:03.059\r\npriorities for this business. Uh, for\r\n\r\n2\r\n00:00:03.069 --> 00:00:06.010\r\nthis quarter, uh, to make more money,\r\n\r\n3\r\n00:00:06.019 --> 00:00:09.050\r\nmore profits, Uh, get everything, uh,\r\n\r\n4\r\n00:00:09.069 --> 00:00:13.439\r\nswept away. All our heuristics should be\r\n\r\n5\r\n00:00:13.529 --> 00:00:15.119\r\ntop of the line.\r\n'
|
|
156
|
+
},
|
|
157
|
+
transcription: {
|
|
158
|
+
language: 'en',
|
|
159
|
+
translation: {
|
|
160
|
+
language: 'de'
|
|
161
|
+
}
|
|
137
162
|
}
|
|
138
163
|
}
|
|
139
164
|
},
|
|
140
165
|
{
|
|
141
166
|
id: '39fd188d-a4dc-43b9-bac8-32fd71bfbc90',
|
|
142
|
-
title:
|
|
167
|
+
title: `"Emoji": 🇯🇵 🙏
|
|
168
|
+
\t\t'Arabic': خَرَجَ الوَلَدُ.
|
|
169
|
+
Chinese: 简化字不讲理\f
|
|
170
|
+
Hebrew: עִבְרִית\r\r
|
|
171
|
+
Japanese Kanji: 漢字\n
|
|
172
|
+
\\\\\\///
|
|
173
|
+
Japanese Hiragana: 平仮名
|
|
174
|
+
Japanese Katakana: 片仮名
|
|
175
|
+
Devangari Hindi: ॳॴॶॷऎऒऔ
|
|
176
|
+
Korean Hangul: 정음/正音
|
|
177
|
+
Cyrillic: АБВГДЕЖЗИКЛМН
|
|
178
|
+
Greek: αβγδ`,
|
|
143
179
|
answer: {
|
|
144
180
|
id: '39fd188d-a4dc-43b9-bac8-32fd71bfbc90',
|
|
145
181
|
label: null,
|
|
146
182
|
metadata: {
|
|
147
|
-
duration:
|
|
183
|
+
duration: VIDEOC.duration
|
|
148
184
|
},
|
|
149
185
|
settings: {
|
|
150
186
|
endOffset: 0,
|
|
151
187
|
startOffset: 0
|
|
152
188
|
},
|
|
153
189
|
media: {
|
|
154
|
-
input:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
'https://d2rxhdlm2q91uk.cloudfront.net/TVik9uTMgE/6JQEIPeStt/39fd188d-a4dc-43b9-bac8-32fd71bfbc90/39fd188d-a4dc-43b9-bac8-32fd71bfbc90_poster.0000001.jpg?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kMnJ4aGRsbTJxOTF1ay5jbG91ZGZyb250Lm5ldC9UVmlrOXVUTWdFLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjIwMTYzMjM0Mjl9fX1dfQ__&Key-Pair-Id=K2SWKOH0FA5F6M&Signature=SGA54MFpy4jaqKJHKEuxRfjk-~NBFAh1tdW9Y6uYJwc0LFjDDgX1sraerSyohmVhj~-QVIrglY5BvglDIhrFcLJWGTkgj4vhyLprk1a7EDckv0HBgp-k1ZKvoDtt3wBOzrL4GicfXBkuMpIu5jv5MY3xemlJj2a6V~h65XJuLO4u-xS~McH6rS3mRxoNl4GcYUVm4upre1DGQx-5Suy6Ateoxl6xxoF8kg5EL02KxkIGiRpwXJTvVmUuVF0rpBj-IE40MfmhLBQ1NNSXiqb3-HjpkKwhYPvB5APVh23mzGmqJ0P3jbr2F1cU4Jvlqsjb6GVP61wGOz9ITeWPZkOy8A__'
|
|
190
|
+
input: VIDEOC.mp4,
|
|
191
|
+
video: VIDEOC.mp4,
|
|
192
|
+
playlist: VIDEOC.m3u8,
|
|
193
|
+
thumbnail: VIDEOC.jpg,
|
|
194
|
+
videos: {
|
|
195
|
+
xs: VIDEOC.mp4
|
|
196
|
+
}
|
|
162
197
|
},
|
|
163
198
|
contact: {
|
|
164
199
|
id: 'b62f62a3-0cd4-4512-9b52-121cb2f3e72f',
|
|
165
200
|
name: 'Aaron Williams',
|
|
166
|
-
roleTitle: 'Software Engineer',
|
|
167
201
|
client: {
|
|
168
202
|
id: '03540d70-1c75-4867-a235-bac842ed6ce4',
|
|
169
203
|
name: 'Vouch',
|
|
170
|
-
logoSrc: 'https://
|
|
204
|
+
logoSrc: 'https://vouch-clients.s3.ap-southeast-2.amazonaws.com/vouch/logos/vouch-logotype-teal.png'
|
|
171
205
|
}
|
|
172
206
|
},
|
|
173
207
|
captions: {
|
|
@@ -178,6 +212,13 @@ const data = {
|
|
|
178
212
|
}
|
|
179
213
|
]
|
|
180
214
|
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const withNullAnswer = {
|
|
218
|
+
...data,
|
|
219
|
+
questions: {
|
|
220
|
+
items: [...data.questions.items, { id: 'null', answer: null }]
|
|
221
|
+
}
|
|
181
222
|
} as Vouch;
|
|
182
223
|
|
|
183
|
-
export { data };
|
|
224
|
+
export { data, withNullAnswer };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const VIDEOA = {
|
|
2
|
+
mp4: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/01/output.mp4',
|
|
3
|
+
m3u8: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/01/master.m3u8',
|
|
4
|
+
jpg: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/01/output.jpg',
|
|
5
|
+
duration: 7.29
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const VIDEOB = {
|
|
9
|
+
mp4: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/02/output.mp4',
|
|
10
|
+
m3u8: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/02/master.m3u8',
|
|
11
|
+
jpg: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/02/output.jpg',
|
|
12
|
+
duration: 40.4
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const VIDEOC = {
|
|
16
|
+
mp4: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/03/output.mp4',
|
|
17
|
+
m3u8: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/03/master.m3u8',
|
|
18
|
+
jpg: 'https://media-player-test-videos.s3.ap-southeast-2.amazonaws.com/03/output.jpg',
|
|
19
|
+
duration: 30.33
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { VIDEOA, VIDEOB, VIDEOC };
|