"use strict";(globalThis.webpackChunk_flippingbook_publication=globalThis.webpackChunk_flippingbook_publication||[]).push([[21],{4358:(t,e,a)=>{a.r(e),a.d(e,{GoogleCastLoader:()=>i});var r=a(3607),o=a(5731),n=a(1853),s=a(7895);class i{name="google-cast";target;#t;get cast(){return(0,n.N9)()}mediaType(){return"video"}canPlay(t){return r.G9&&!r.cj&&(0,r.Ew)(t)}async prompt(t){let e,a,r;try{e=await this.#e(t),this.#t||(this.#t=new cast.framework.RemotePlayer,new cast.framework.RemotePlayerController(this.#t)),a=t.player.createEvent("google-cast-prompt-open",{trigger:e}),t.player.dispatchEvent(a),this.#a(t,"connecting",a),await this.#r((0,s.fj)(t.$props.googleCast)),t.$state.remotePlaybackInfo.set({deviceName:(0,n.Aj)()?.getCastDevice().friendlyName}),(0,n.t0)()&&this.#a(t,"connected",a)}catch(o){const s=o instanceof Error?o:this.#o((o+"").toUpperCase(),"Prompt failed.");throw r=t.player.createEvent("google-cast-prompt-error",{detail:s,trigger:a??e,cancelable:!0}),t.player.dispatch(r),this.#a(t,(0,n.t0)()?"connected":"disconnected",r),s}finally{t.player.dispatch("google-cast-prompt-close",{trigger:r??a??e})}}async load(t){if(!this.#t)throw Error("[vidstack] google cast player was not initialized");return new((await a.e(29).then(a.bind(a,4299))).GoogleCastProvider)(this.#t,t)}async#e(t){if((0,n.x5)())return;const e=t.player.createEvent("google-cast-load-start");t.player.dispatch(e),await(0,o.ve)((0,n.qh)()),await customElements.whenDefined("google-cast-launcher");const a=t.player.createEvent("google-cast-loaded",{trigger:e});if(t.player.dispatch(a),!(0,n.KE)())throw this.#o("CAST_NOT_AVAILABLE","Google Cast not available on this platform.");return a}async#r(t){this.#n(t);const e=await this.cast.requestSession();if(e)throw this.#o(e.toUpperCase(),(0,n.VF)(e))}#n(t){this.cast?.setOptions({...(0,n.W7)(),...t})}#a(t,e,a){const r={type:"google-cast",state:e};t.notify("remote-playback-change",r,a)}#o(t,e){const a=Error(e);return a.code=t,a}}},1853:(t,e,a)=>{a.d(e,{Aj:()=>l,KE:()=>s,KH:()=>g,N9:()=>c,VF:()=>d,W7:()=>h,XU:()=>u,Zl:()=>p,qh:()=>o,t0:()=>i,x5:()=>n});var r=a(7895);function o(){return"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"}function n(){return!!window.cast?.framework}function s(){return!!window.chrome?.cast?.isAvailable}function i(){return c().getCastState()===cast.framework.CastState.CONNECTED}function c(){return window.cast.framework.CastContext.getInstance()}function l(){return c().getCurrentSession()}function p(){return l()?.getSessionObj().media[0]}function g(t){const e=p()?.media.contentId;return e===t?.src}function h(){return{language:"en-US",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,resumeSavedSession:!0,androidReceiverCompatible:!0}}function d(t){return`Google Cast Error Code: ${t}`}function u(t,e){return(0,r.yl)(c(),t,e)}}}]);