@vouchfor/embeds-legacy 0.0.0-experiment.f9584c3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -149,7 +149,7 @@ ${e}`,vg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Bg=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 Vg(){return new Image}const vl=Yt(async function(e,t=Vg){return e?new Promise((i,r)=>{t().then(n=>{n.onload=()=>{i(n)},n.onerror=o=>{r(o)},n.src=e})}):null});async function bo({element:s,meta:e,imageFactory:t},i,r){var n,o,a;let A={...s};const{node:l}=s;if((l==null?void 0:l.type)==="video"&&((n=l==null?void 0:l.value)!=null&&n.src||(o=l==null?void 0:l.value)!=null&&o.playlist)){const c=await i(l.value,e);let h;try{h=await vl(l.value.poster,t)}catch{h=null}A={...A,node:{...l,video:c,poster:h,meta:await r(l.value,c.node,e)}}}if((l==null?void 0:l.type)==="image"&&l.value){let c;try{c=await vl(l.value,t)}catch{c=null}A={...A,node:{...l,image:c}}}return A.node&&((a=s.node)!=null&&a.elements)&&(A.node.elements=await Promise.all(s.node.elements.map(c=>bo({element:c,meta:e,imageFactory:t},i,r)))),s.elements&&(A.elements=await Promise.all(s.elements.map(c=>bo({element:c,meta:e,imageFactory:t},i,r)))),A}async function Jg(){return document.createElement("canvas")}function Xs(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=Xs(t==null?void 0:t.elements);if(i)return i}}function Wg(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 qg(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 jg(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 jr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const Xg=Yt(()=>rl.loadYoga());fo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${jg(s)}"`:qg(s)||Array.isArray(s)?JSON.stringify(s):s);const As=(s,e,t)=>fo.render(s,e,fo.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function ls({data:s,template:e,burnCaptions:t=!1,debug:i=!1,imageFactory:r,canvasFactory:n=Jg},o,a,A){var l,c,h,u;const d=await Xg(),g=e??Kg;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let f=g.templates.find(({version:q})=>q===So);if(!f){const q=g.templates.map(({version:Y})=>`"${Y}"`).join(", ");console.warn(`Template renderer expects template version "${So}" but got ${q}`),f=g.templates[g.templates.length-1]}const p=await Promise.all(f.content.map(async({scenes:q,root:Y})=>{const z={...g.options,...s,intro:g.intro,outro:g.outro};async function S(T,U){return Promise.all(q.map(async({layout:b,duration:R,data:x,derived:V,options:O})=>{var j,se,ce;const Ae={...z,_index:U,_root:T,_derived:await o({data:s,rootData:T,index:U})},ye=x?JSON.parse(await As(x,Ae)):{},Ee=V?JSON.parse(await As(V,Ae)):{},Re=O?JSON.parse(await As(O,Ae)):{},ne=R?parseFloat(await As(R,Ae)):NaN,ue=(j=f.layouts.find(Be=>Be.name===b))==null?void 0:j.tree;if(!ue)throw new Error(`Layout tree "${b}" not found in template "${f.id}" layouts.`);const Se=JSON.parse(await As(ue,{...ye,...Ee,...Re})),Ce=await Promise.all(Se.flatMap(Be=>bo({element:Be,meta:g.meta,imageFactory:r},a,A))),he=Xs(Ce);return{duration:(isNaN(ne)?null:ne)??((se=he==null?void 0:he.meta)==null?void 0:se.duration)??0,captions:(ce=he==null?void 0:he.meta)==null?void 0:ce.captions,elements:Ce}}))}if(Y){const T=JSON.parse(await As(Y,z));return Array.isArray(T)?Promise.all(T.map(async(U,b)=>S(U,b))):Promise.all([S(T,null)])}return Promise.all([S(s,null)])}));if(p.every(q=>q.every(Y=>Y.every(z=>{const S=Xs(z.elements);return!(S!=null&&S.value.src)&&!(S!=null&&S.value.playlist)})))){const q=p.flatMap(Y=>Y.flatMap(z=>z.map(S=>{const T=Xs(S.elements);return!(T!=null&&T.value.src)&&!(T!=null&&T.value.playlist)&&(T==null?void 0:T.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${q} failed to load, video can not be processed`)}if(p.every(q=>q.every(Y=>Y.every(z=>z.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const Q=p.reduce((q,Y)=>{const z=Y.reduce((S,T)=>{const U=T.filter(b=>b.duration>0);return U.length>0?[...S,U]:S},[]);return z.length>0?[...q,z]:q},[]),C=((c=g.meta)==null?void 0:c.frameRate)??30,w=((h=g.meta)==null?void 0:h.resolution)??1080,B=((u=g.meta)==null?void 0:u.transitionDuration)??1/3,L=Wg(Q,B),_=jr(L),$=await Promise.all(Q.map((q,Y)=>{const z=jr(L[Y]),S=jr(L.slice(0,Y));return Promise.all(q.map((T,U)=>Promise.all(T.map(async({duration:b,captions:R,elements:x},V)=>{var O,j;const se=await n(),ce=await n(),Ae=await n(),ye=await n(),Ee=Xs(x),Re=jr([...L.slice(0,Y),...L[Y].slice(0,U),...L[Y][U].slice(0,V)]);return{draw:async({canvas:ue,currentTime:Se})=>{const Ce=Math.max(0,Se-S),he=Math.max(0,Se-Re);await Qo({yoga:d,debug:i,canvas:ue,cropCanvas:se,posterCanvas:ye,letterboxCanvas:ce,elements:x,currentTime:Se,contentTime:Ce,sceneTime:he,totalDuration:_,contentDuration:z,sceneDuration:b}),R&&t&&Ug({canvas:ue,dx:0,dy:0,dw:ue.width,dh:ue.height,vttCaptions:R,sceneTime:he+((Ee==null?void 0:Ee.meta.start)??0)})},duration:b,transitionCanvas:Ae,id:Yg(),start:Re,video:Ee==null?void 0:Ee.video,videoMeta:Ee==null?void 0:Ee.meta,audio:{duration:b,src:(O=Ee==null?void 0:Ee.value)==null?void 0:O.src,start:(j=Ee==null?void 0:Ee.meta)==null?void 0:j.start}}}))))})),F=$.flatMap(q=>q);return{scenes:F.flatMap(q=>q),sections:F,contents:$,frameRate:C,resolution:w,transitionDuration:B,fonts:f.fonts??[],duration:_}}const So="3",zg={name:"@vouchfor/embeds-legacy",version:"0.0.0-experiment.f9584c3",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds-legacy.js",module:"dist/es/embeds-legacy.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds-legacy.js"},files:["dist","src"],publishConfig:{tag:"experiment",access:"public"},engines:{node:">=18.18.0"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player-legacy 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-legacy":"^8.2.2","@vouchfor/media-player-legacy":"0.0.0-experiment.f9584c3",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-legacy":"0.0.0-experiment.f9584c3","@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 Zg(s){const{publicApiUrl:e}=xr(s),t=Ti();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function ef(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Ti()};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=Ti();return e||(e=Zg(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Ti(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Ti(),(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 tf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function sf(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:zg.version,templateVersion:So,...i}}const Bl=1;class rf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=tf(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}=xr(this.host.env),{client:i,tab:r,request:n,visitor:o}=ef(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":sf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Bl&&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]+Bl&&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 wo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof uo<"u"&&uo,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 T={next:function(){var U=S.shift();return{done:U===void 0,value:U}}};return A.iterable&&(T[Symbol.iterator]=function(){return T}),T}function f(S){this.map={},S instanceof f?S.forEach(function(T,U){this.append(U,T)},this):Array.isArray(S)?S.forEach(function(T){this.append(T[0],T[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(T){this.append(T,S[T])},this)}f.prototype.append=function(S,T){S=u(S),T=d(T);var U=this.map[S];this.map[S]=U?U+", "+T:T},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,T){this.map[u(S)]=d(T)},f.prototype.forEach=function(S,T){for(var U in this.map)this.map.hasOwnProperty(U)&&S.call(T,this.map[U],U,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(T,U){S.push(U)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(T){S.push(T)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(T,U){S.push([U,T])}),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 y(S){return new Promise(function(T,U){S.onload=function(){T(S.result)},S.onerror=function(){U(S.error)}})}function v(S){var T=new FileReader,U=y(T);return T.readAsArrayBuffer(S),U}function Q(S){var T=new FileReader,U=y(T);return T.readAsText(S),U}function C(S){for(var T=new Uint8Array(S),U=new Array(T.length),b=0;b<T.length;b++)U[b]=String.fromCharCode(T[b]);return U.join("")}function w(S){if(S.slice)return S.slice(0);var T=new Uint8Array(S.byteLength);return T.set(new Uint8Array(S)),T.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=w(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=w(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(v)}),this.text=function(){var S=p(this);if(S)return S;if(this._bodyBlob)return Q(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(C(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},A.formData&&(this.formData=function(){return this.text().then(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var T=S.toUpperCase();return L.indexOf(T)>-1?T:S}function $(S,T){if(!(this instanceof $))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');T=T||{};var U=T.body;if(S instanceof $){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,T.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!U&&S._bodyInit!=null&&(U=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=T.credentials||this.credentials||"same-origin",(T.headers||!this.headers)&&(this.headers=new f(T.headers)),this.method=_(T.method||this.method||"GET"),this.mode=T.mode||this.mode||null,this.signal=T.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(this.method==="GET"||this.method==="HEAD")&&(T.cache==="no-store"||T.cache==="no-cache")){var b=/([?&])_=[^&]*/;if(b.test(this.url))this.url=this.url.replace(b,"$1_="+new Date().getTime());else{var R=/\?/;this.url+=(R.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function F(S){var T=new FormData;return S.trim().split("&").forEach(function(U){if(U){var b=U.split("="),R=b.shift().replace(/\+/g," "),x=b.join("=").replace(/\+/g," ");T.append(decodeURIComponent(R),decodeURIComponent(x))}}),T}function H(S){var T=new f,U=S.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(b){return b.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 Vg(){return new Image}const vl=Yt(async function(e,t=Vg){return e?new Promise((i,r)=>{t().then(n=>{n.onload=()=>{i(n)},n.onerror=o=>{r(o)},n.src=e})}):null});async function bo({element:s,meta:e,imageFactory:t},i,r){var n,o,a;let A={...s};const{node:l}=s;if((l==null?void 0:l.type)==="video"&&((n=l==null?void 0:l.value)!=null&&n.src||(o=l==null?void 0:l.value)!=null&&o.playlist)){const c=await i(l.value,e);let h;try{h=await vl(l.value.poster,t)}catch{h=null}A={...A,node:{...l,video:c,poster:h,meta:await r(l.value,c.node,e)}}}if((l==null?void 0:l.type)==="image"&&l.value){let c;try{c=await vl(l.value,t)}catch{c=null}A={...A,node:{...l,image:c}}}return A.node&&((a=s.node)!=null&&a.elements)&&(A.node.elements=await Promise.all(s.node.elements.map(c=>bo({element:c,meta:e,imageFactory:t},i,r)))),s.elements&&(A.elements=await Promise.all(s.elements.map(c=>bo({element:c,meta:e,imageFactory:t},i,r)))),A}async function Jg(){return document.createElement("canvas")}function Xs(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=Xs(t==null?void 0:t.elements);if(i)return i}}function Wg(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 qg(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 jg(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 jr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const Xg=Yt(()=>rl.loadYoga());fo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${jg(s)}"`:qg(s)||Array.isArray(s)?JSON.stringify(s):s);const As=(s,e,t)=>fo.render(s,e,fo.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function ls({data:s,template:e,burnCaptions:t=!1,debug:i=!1,imageFactory:r,canvasFactory:n=Jg},o,a,A){var l,c,h,u;const d=await Xg(),g=e??Kg;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let f=g.templates.find(({version:q})=>q===So);if(!f){const q=g.templates.map(({version:Y})=>`"${Y}"`).join(", ");console.warn(`Template renderer expects template version "${So}" but got ${q}`),f=g.templates[g.templates.length-1]}const p=await Promise.all(f.content.map(async({scenes:q,root:Y})=>{const z={...g.options,...s,intro:g.intro,outro:g.outro};async function S(T,U){return Promise.all(q.map(async({layout:b,duration:R,data:x,derived:V,options:O})=>{var j,se,ce;const Ae={...z,_index:U,_root:T,_derived:await o({data:s,rootData:T,index:U})},ye=x?JSON.parse(await As(x,Ae)):{},Ee=V?JSON.parse(await As(V,Ae)):{},Re=O?JSON.parse(await As(O,Ae)):{},ne=R?parseFloat(await As(R,Ae)):NaN,ue=(j=f.layouts.find(Be=>Be.name===b))==null?void 0:j.tree;if(!ue)throw new Error(`Layout tree "${b}" not found in template "${f.id}" layouts.`);const Se=JSON.parse(await As(ue,{...ye,...Ee,...Re})),Ce=await Promise.all(Se.flatMap(Be=>bo({element:Be,meta:g.meta,imageFactory:r},a,A))),he=Xs(Ce);return{duration:(isNaN(ne)?null:ne)??((se=he==null?void 0:he.meta)==null?void 0:se.duration)??0,captions:(ce=he==null?void 0:he.meta)==null?void 0:ce.captions,elements:Ce}}))}if(Y){const T=JSON.parse(await As(Y,z));return Array.isArray(T)?Promise.all(T.map(async(U,b)=>S(U,b))):Promise.all([S(T,null)])}return Promise.all([S(s,null)])}));if(p.every(q=>q.every(Y=>Y.every(z=>{const S=Xs(z.elements);return!(S!=null&&S.value.src)&&!(S!=null&&S.value.playlist)})))){const q=p.flatMap(Y=>Y.flatMap(z=>z.map(S=>{const T=Xs(S.elements);return!(T!=null&&T.value.src)&&!(T!=null&&T.value.playlist)&&(T==null?void 0:T.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${q} failed to load, video can not be processed`)}if(p.every(q=>q.every(Y=>Y.every(z=>z.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const Q=p.reduce((q,Y)=>{const z=Y.reduce((S,T)=>{const U=T.filter(b=>b.duration>0);return U.length>0?[...S,U]:S},[]);return z.length>0?[...q,z]:q},[]),C=((c=g.meta)==null?void 0:c.frameRate)??30,w=((h=g.meta)==null?void 0:h.resolution)??1080,B=((u=g.meta)==null?void 0:u.transitionDuration)??1/3,L=Wg(Q,B),_=jr(L),$=await Promise.all(Q.map((q,Y)=>{const z=jr(L[Y]),S=jr(L.slice(0,Y));return Promise.all(q.map((T,U)=>Promise.all(T.map(async({duration:b,captions:R,elements:x},V)=>{var O,j;const se=await n(),ce=await n(),Ae=await n(),ye=await n(),Ee=Xs(x),Re=jr([...L.slice(0,Y),...L[Y].slice(0,U),...L[Y][U].slice(0,V)]);return{draw:async({canvas:ue,currentTime:Se})=>{const Ce=Math.max(0,Se-S),he=Math.max(0,Se-Re);await Qo({yoga:d,debug:i,canvas:ue,cropCanvas:se,posterCanvas:ye,letterboxCanvas:ce,elements:x,currentTime:Se,contentTime:Ce,sceneTime:he,totalDuration:_,contentDuration:z,sceneDuration:b}),R&&t&&Ug({canvas:ue,dx:0,dy:0,dw:ue.width,dh:ue.height,vttCaptions:R,sceneTime:he+((Ee==null?void 0:Ee.meta.start)??0)})},duration:b,transitionCanvas:Ae,id:Yg(),start:Re,video:Ee==null?void 0:Ee.video,videoMeta:Ee==null?void 0:Ee.meta,audio:{duration:b,src:(O=Ee==null?void 0:Ee.value)==null?void 0:O.src,start:(j=Ee==null?void 0:Ee.meta)==null?void 0:j.start}}}))))})),F=$.flatMap(q=>q);return{scenes:F.flatMap(q=>q),sections:F,contents:$,frameRate:C,resolution:w,transitionDuration:B,fonts:f.fonts??[],duration:_}}const So="3",zg={name:"@vouchfor/embeds-legacy",version:"4.0.0",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds-legacy.js",module:"dist/es/embeds-legacy.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds-legacy.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-legacy 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-legacy":"^9.0.0","@vouchfor/media-player-legacy":"^5.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-legacy":"^2.0.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 Zg(s){const{publicApiUrl:e}=xr(s),t=Ti();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function ef(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Ti()};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=Ti();return e||(e=Zg(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Ti(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Ti(),(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 tf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function sf(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:zg.version,templateVersion:So,...i}}const Bl=1;class rf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=tf(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}=xr(this.host.env),{client:i,tab:r,request:n,visitor:o}=ef(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":sf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Bl&&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]+Bl&&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 wo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof uo<"u"&&uo,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 T={next:function(){var U=S.shift();return{done:U===void 0,value:U}}};return A.iterable&&(T[Symbol.iterator]=function(){return T}),T}function f(S){this.map={},S instanceof f?S.forEach(function(T,U){this.append(U,T)},this):Array.isArray(S)?S.forEach(function(T){this.append(T[0],T[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(T){this.append(T,S[T])},this)}f.prototype.append=function(S,T){S=u(S),T=d(T);var U=this.map[S];this.map[S]=U?U+", "+T:T},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,T){this.map[u(S)]=d(T)},f.prototype.forEach=function(S,T){for(var U in this.map)this.map.hasOwnProperty(U)&&S.call(T,this.map[U],U,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(T,U){S.push(U)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(T){S.push(T)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(T,U){S.push([U,T])}),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 y(S){return new Promise(function(T,U){S.onload=function(){T(S.result)},S.onerror=function(){U(S.error)}})}function v(S){var T=new FileReader,U=y(T);return T.readAsArrayBuffer(S),U}function Q(S){var T=new FileReader,U=y(T);return T.readAsText(S),U}function C(S){for(var T=new Uint8Array(S),U=new Array(T.length),b=0;b<T.length;b++)U[b]=String.fromCharCode(T[b]);return U.join("")}function w(S){if(S.slice)return S.slice(0);var T=new Uint8Array(S.byteLength);return T.set(new Uint8Array(S)),T.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=w(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=w(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(v)}),this.text=function(){var S=p(this);if(S)return S;if(this._bodyBlob)return Q(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(C(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},A.formData&&(this.formData=function(){return this.text().then(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var T=S.toUpperCase();return L.indexOf(T)>-1?T:S}function $(S,T){if(!(this instanceof $))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');T=T||{};var U=T.body;if(S instanceof $){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,T.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!U&&S._bodyInit!=null&&(U=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=T.credentials||this.credentials||"same-origin",(T.headers||!this.headers)&&(this.headers=new f(T.headers)),this.method=_(T.method||this.method||"GET"),this.mode=T.mode||this.mode||null,this.signal=T.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(this.method==="GET"||this.method==="HEAD")&&(T.cache==="no-store"||T.cache==="no-cache")){var b=/([?&])_=[^&]*/;if(b.test(this.url))this.url=this.url.replace(b,"$1_="+new Date().getTime());else{var R=/\?/;this.url+=(R.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function F(S){var T=new FormData;return S.trim().split("&").forEach(function(U){if(U){var b=U.split("="),R=b.shift().replace(/\+/g," "),x=b.join("=").replace(/\+/g," ");T.append(decodeURIComponent(R),decodeURIComponent(x))}}),T}function H(S){var T=new f,U=S.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(b){return b.indexOf(`
153
153
  `)===0?b.substr(1,b.length):b}).forEach(function(b){var R=b.split(":"),x=R.shift().trim();if(x){var V=R.join(":").trim();T.append(x,V)}}),T}B.call($.prototype);function q(S,T){if(!(this instanceof q))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');T||(T={}),this.type="default",this.status=T.status===void 0?200:T.status,this.ok=this.status>=200&&this.status<300,this.statusText=T.statusText===void 0?"":""+T.statusText,this.headers=new f(T.headers),this.url=T.url||"",this._initBody(S)}B.call(q.prototype),q.prototype.clone=function(){return new q(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},q.error=function(){var S=new q(null,{status:0,statusText:""});return S.type="error",S};var Y=[301,302,303,307,308];q.redirect=function(S,T){if(Y.indexOf(T)===-1)throw new RangeError("Invalid status code");return new q(null,{status:T,headers:{location:S}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(T,U){this.message=T,this.name=U;var b=Error(T);this.stack=b.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function z(S,T){return new Promise(function(U,b){var R=new $(S,T);if(R.signal&&R.signal.aborted)return b(new o.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function V(){x.abort()}x.onload=function(){var j={status:x.status,statusText:x.statusText,headers:H(x.getAllResponseHeaders()||"")};j.url="responseURL"in x?x.responseURL:j.headers.get("X-Request-URL");var se="response"in x?x.response:x.responseText;setTimeout(function(){U(new q(se,j))},0)},x.onerror=function(){setTimeout(function(){b(new TypeError("Network request failed"))},0)},x.ontimeout=function(){setTimeout(function(){b(new TypeError("Network request failed"))},0)},x.onabort=function(){setTimeout(function(){b(new o.DOMException("Aborted","AbortError"))},0)};function O(j){try{return j===""&&a.location.href?a.location.href:j}catch{return j}}x.open(R.method,O(R.url),!0),R.credentials==="include"?x.withCredentials=!0:R.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&(A.blob?x.responseType="blob":A.arrayBuffer&&R.headers.get("Content-Type")&&R.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(x.responseType="arraybuffer")),T&&typeof T.headers=="object"&&!(T.headers instanceof f)?Object.getOwnPropertyNames(T.headers).forEach(function(j){x.setRequestHeader(j,d(T.headers[j]))}):R.headers.forEach(function(j,se){x.setRequestHeader(se,j)}),R.signal&&(R.signal.addEventListener("abort",V),x.onreadystatechange=function(){x.readyState===4&&R.signal.removeEventListener("abort",V)}),x.send(typeof R._bodyInit>"u"?null:R._bodyInit)})}return z.polyfill=!0,a.fetch||(a.fetch=z,a.Headers=f,a.Request=$,a.Response=q),o.Headers=f,o.Request=$,o.Response=q,o.fetch=z,o})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var r=t.fetch?t:i;e=r.fetch,e.default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,s.exports=e})(wo,wo.exports);var nf=wo.exports;const Ql=Eg(nf);async function of(s){var e;try{if((e=await Ql(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function Ro({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=>of(o));e=(await Promise.all(n)).find(Boolean)}return e}async function af(s){try{return(await Ql(s)).text()}catch{return null}}async function Af(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?af(s):s}const lf=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?Af(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})}),cf=Yt(async s=>{var e,t,i,r,n,o,a,A,l,c,h;const[u,d,g]=await Promise.all([Ro({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]}),Ro({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),Ro({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 bl(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 hf=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 To({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,h,u,d,g,f,p,y,v,Q,C,w,B,L,_,$,F;const[H,q,Y]=await Promise.all([hf(s,e,t),cf(e),lf({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)]),z=bl(e);return{...q,...z,key:H,captions:Y,answerLabel:((y=e==null?void 0:e.answer)==null?void 0:y.label)??(e==null?void 0:e.title),prevAnswerLabel:t?((w=(C=(Q=(v=s==null?void 0:s.questions)==null?void 0:v.items)==null?void 0:Q[t-1])==null?void 0:C.answer)==null?void 0:w.label)??((_=(L=(B=s==null?void 0:s.questions)==null?void 0:B.items)==null?void 0:L[t-1])==null?void 0:_.title)??null:null,isFirstInstanceOfName:t?((F=($=s==null?void 0:s.questions)==null?void 0:$.items)==null?void 0:F.findIndex(S=>bl(S).name===z.name))===t:!0}}const Xr={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 uf({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&&Xr[u]&&!i.find(g=>g.value===u)&&i.push({value:u,label:Xr[u]}),d&&Xr[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:Xr[d]}),i},[]))??[]}/**
154
154
  * @license
155
155
  * Copyright 2018 Google LLC