bloom-player 2.16.0-alpha.4 → 2.16.0-alpha.5

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.
@@ -23,7 +23,7 @@ object-assign
23
23
  `,e.firstChild},WC=t=>{const e=document.createElement("div");return e.innerHTML=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
24
24
  <path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z" fill="${t}"/>
25
25
  </svg>
26
- `,e.firstChild},hi=class hi{constructor(){this.currentVideoStartTime=0,this.isPlayingSingleVideo=!1,this.handlePlayClick=e=>{var a,i;e.stopPropagation(),e.preventDefault();const n=(i=(a=e.target)==null?void 0:a.closest(".bloom-videoContainer"))==null?void 0:i.getElementsByTagName("video")[0];n&&(n===this.currentVideoElement?this.play():this.replaySingleVideo(n))},this.handleVideoClick=e=>{e.currentTarget.paused?this.handlePlayClick(e):this.handlePauseClick(e)},this.handleReplayClick=e=>{var a,i;e.stopPropagation(),e.preventDefault();const n=(i=(a=e.target)==null?void 0:a.closest(".bloom-videoContainer"))==null?void 0:i.getElementsByTagName("video")[0];n&&this.replaySingleVideo(n)},this.handlePauseClick=e=>{e.stopPropagation(),e.preventDefault(),this.pause()}}static pageHasVideo(e){return!!hi.getVideoElements(e).length}wrapVideoIcon(e,n,a){var r;const i=document.createElement("div");return i.classList.add("videoControlContainer"),i.appendChild(n),i.classList.add(a),n.classList.add("videoControl"),(r=e.parentElement)==null||r.appendChild(i),n}static setAllVideoPostersTo1x1TransparentPNG(e){const n=e.getElementsByTagName("video");for(let a=0;a<n.length;a++)n[a].setAttribute("poster",hi.onePixelTransparentPoster)}HandlePageBeforeVisible(e){if(this.currentPage=e,!hi.pageHasVideo(this.currentPage)){this.currentVideoElement=void 0;return}this.getVideoElements().forEach(n=>{n.removeAttribute("controls"),n.addEventListener("click",this.handleVideoClick),this.wrapVideoIcon(n,HC("#ffffff"),"videoPlayIcon").addEventListener("click",this.handlePlayClick),this.wrapVideoIcon(n,FC("#ffffff"),"videoPauseIcon").addEventListener("click",this.handlePauseClick),this.wrapVideoIcon(n,WC("#ffffff"),"videoReplayIcon").addEventListener("click",this.handleReplayClick),n.currentTime!==0&&(n.currentTime=0)})}HandlePageVisible(e){var n;if(this.currentPage=e,!hi.pageHasVideo(this.currentPage)){this.currentVideoElement=void 0;return}if(yn===Ge.VideoPaused)(n=this.currentVideoElement)==null||n.pause();else{const a=this.getVideoElements();if(a.length>0){const i=a[0];let r=!0;i.addEventListener("playing",()=>{r&&a[0].pause()},{once:!0}),i.play(),window.setTimeout(()=>{r=!1,this.playAllVideo(a)},1e3)}}}static getVideoElements(e){return Array.from(e.getElementsByClassName("bloom-videoContainer")).map(n=>n.getElementsByTagName("video")[0]).filter(n=>n!==void 0)}getVideoElements(){return hi.getVideoElements(this.currentPage)}play(){yn!==Ge.VideoPlaying&&(Mn(Ge.VideoPlaying),this.isPlayingSingleVideo?this.playAllVideo([this.currentVideoElement]):this.resumePlayAllVideo())}resumePlayAllVideo(){const e=this.getVideoElements();let n=e;if(this.currentVideoElement){const a=e.indexOf(this.currentVideoElement);n=e.slice(a)}this.playAllVideo(n)}pause(){yn!=Ge.VideoPaused&&(this.pauseCurrentVideo(),Mn(Ge.VideoPaused))}pauseCurrentVideo(){var n;this.currentPage&&Array.from(this.currentPage.getElementsByClassName("playing")).forEach(a=>a.classList.remove("playing"));const e=this.currentVideoElement;e&&(e.currentTime>0&&!e.paused&&!e.ended&&this.reportVideoPlayed(e.currentTime-this.currentVideoStartTime),(n=e==null?void 0:e.closest(".bloom-videoContainer"))==null||n.classList.add("paused"),e.pause())}reportVideoPlayed(e){Se.storeVideoAnalytics(e)}hidingPage(){this.pauseCurrentVideo()}replaySingleVideo(e){e.currentTime=0,this.isPlayingSingleVideo=!0,this.playAllVideo([e])}playAllVideo(e){var i;if(Array.from(this.currentPage.getElementsByClassName("playing")).forEach(r=>r.classList.remove("playing")),e.length===0){this.currentVideoElement=void 0,this.isPlayingSingleVideo=!1,this.PageVideoComplete&&this.PageVideoComplete.raise({page:this.currentPage,videos:this.getVideoElements()});return}Array.from(this.currentPage.getElementsByClassName("paused")).forEach(r=>r.classList.remove("paused"));const n=e[0],a=n.closest(".bloom-page");if(this.currentPage!==a){this.currentVideoElement=void 0;return}this.currentVideoElement=n,n.networkState===HTMLMediaElement.NETWORK_NO_SOURCE&&n.readyState===HTMLMediaElement.HAVE_NOTHING?(ql(n),this.playAllVideo(e.slice(1))):(Vy(n),Mn(Ge.VideoPlaying),this.currentVideoStartTime=n.currentTime||0,(i=n.closest(".bloom-videoContainer"))==null||i.classList.add("playing"),n.play().then(()=>{n.addEventListener("ended",()=>{this.reportVideoPlayed(n.currentTime-this.currentVideoStartTime),n.currentTime=0,this.playAllVideo(e.slice(1))},{once:!0})}).catch(s=>{console.error("Video play failed",s),ql(n),this.playAllVideo(e.slice(1))}))}};hi.onePixelTransparentPoster="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=";let Uo=hi,Qa=[];function Gy(t,e){const n=Qa.length;return Qa.push({src:t,volume:e,startTime:new Date().toISOString()}),n}function _C(t){t>=0&&t<Qa.length&&(Qa[t].endTime=new Date().toISOString())}function VC(){Qa=[]}function GC(t){const e=Qa.length;return Qa.push({...Qa[t],startTime:new Date().toISOString()}),e}function UC(){Yy("publish/av/soundLog",Qa,"application/json; charset=utf-8")}function Uy(t,e){return Yy(t,e,"text/plain")}function Yy(t,e,n){return Ja.post("/bloom/api/"+t,e,{headers:{"Content-Type":n}})}class YC{constructor(){this.pageIdToSelectionMap=new Map,this.musicLogIndex=-1}pageHasMusic(e){return this.pageIdToSelectionMap.has(this.getPageId(e))}HandlePageVisible(e){this.currentPage=e,this.currentPage&&(this.pageHasMusic(this.currentPage)?this.listen():this.getPlayer().pause())}hidingPage(){}listen(){this.setMusicSourceAndVolume(),yn===Ge.AudioPaused?this.getPlayer().pause():this.playerPlay()}play(){this.currentPage&&this.playerPlay()}pause(){this.currentPage&&(this.getPlayer().pause(),_C(this.musicLogIndex))}processAllMusicForBook(e){this.pageIdToSelectionMap=new Map;let n=-1,a;for(let i=0;i<e.length;i++){const r=e[i],s=r.getAttribute("data-backgroundaudio");s!==null&&s!==""?(a={id:++n,src:s,volume:this.getMusicVolume(r)},this.pageIdToSelectionMap.set(this.getPageId(r),a)):s===null?a&&this.pageIdToSelectionMap.set(this.getPageId(r),a):a=void 0}}getPageId(e){return e.getAttribute("id")||""}getPlayer(){let e=document.querySelector("#music-player");return e||(e=document.createElement("audio"),e.setAttribute("id","music-player"),document.body.appendChild(e),e.addEventListener("ended",()=>this.playEnded())),e}setMusicSourceAndVolume(){const e=this.pageIdToSelectionMap.get(this.getPageId(this.currentPage));if(e===void 0){this.selectionPlaying=void 0;return}if(e===this.selectionPlaying)return;this.selectionPlaying=e;const n=e.src,a=e.volume,i=this.currentMusicUrl(n+"?nocache="+new Date().getTime()),r=this.getPlayer();r.setAttribute("src",n?i:""),a.length&&(r.volume=Number(a)),n&&(this.musicLogIndex=Gy(i,a.length?Number(a):1))}getMusicVolume(e){if(!e)return"";const n=e.getAttribute("data-backgroundaudiovolume");return n||""}currentMusicUrl(e){return this.urlPrefix+"/audio/"+e}playEnded(){this.getPlayer().currentTime=0,this.play(),this.musicLogIndex=GC(this.musicLogIndex)}playerPlay(){const e=this.getPlayer().play();e&&e.catch&&e.catch(n=>{console.log("could not play music: "+n),this.getPlayer().pause(),n.name==="NotAllowedError"&&this.PlayFailed&&this.PlayFailed.raise()})}}const XC={"Button.Back":{message:"رجوع",description:"tooltip for the button to go back to the main display"}},ZC={"Audio.Pause":{message:"Fasilə etmək",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Gəri",description:"tooltip for the button to go back to the main display"}},JC={"Quiz.CheckYourUnderstanding":{message:"আপনাদের বোধশক্তির পরীক্ষা করুন",description:"the heading on (some) quiz pages"},"Button.Back":{message:"পিছনে",description:"tooltip for the button to go back to the main display"}},QC={"Quiz.CheckYourUnderstanding":{message:"Compruebe su comprensión",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"Reproducir",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Leer en voz alta",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Pausar",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Regresar",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Más",description:"tooltip for the button to go show detail view of book"},"Button.FullScreen":{message:"Pantalla completa",description:"tooltip for the display on full screen button"},"Button.ExitFullScreen":{message:"Salir de pantalla completa",description:"tooltip for the exit full screen button"},"Button.ChooseLanguage":{message:"Elija el idioma",description:"tooltip for the language menu button"},"Button.Next":{message:"Página siguiente",description:"tooltip for the next page button"},"Button.Prev":{message:"Página previa",description:"tooltip for the previous page button"},"Button.ReadImageDescriptions":{message:"Leer las descripciones de las imágenes",description:"tooltip for the button to enable reading image descriptions"},"Button.IgnoreImageDescriptions":{message:"Ignorar las descripciones de las imágenes",description:"tooltip for the button to disable reading image descriptions"}},tT={"Quiz.CheckYourUnderstanding":{message:"Contrôlez Votre Compréhension",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"Lecture",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Lecture Livre Audio",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Pause",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Retour",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Plus d’infos",description:"tooltip for the button to go show detail view of book"},"Button.FullScreen":{message:"Plein Écran",description:"tooltip for the display on full screen button"},"Button.ExitFullScreen":{message:"Sortir du mode Plein Ecran",description:"tooltip for the exit full screen button"},"Button.ChooseLanguage":{message:"Choisir Langue",description:"tooltip for the language menu button"},"Button.Next":{message:"Page Suivante",description:"tooltip for the next page button"},"Button.Prev":{message:"Page Précédente",description:"tooltip for the previous page button"},"Button.ReadImageDescriptions":{message:"Lire la Description des Images",description:"tooltip for the button to enable reading image descriptions"},"Button.IgnoreImageDescriptions":{message:"Ignorer la Description des Images",description:"tooltip for the button to disable reading image descriptions"},"Version.Problem.Web":{message:"Ce livre utilise la fonctionnalité {feature}. Malheureusement, {hostname} n'est pas encore prêt à afficher ce livre. Veuillez revenir plus tard ou bien écrivez à issues@bloomlibrary.org si vous pensez que c'est une réponse inattendue.",description:"Please make sure that your translation contains {feature} and {hostname} as placeholders; they will be replaced with actual data. Do not translate those words."},"Version.Problem.NoHost":{message:"Ce livre utilise la fonctionnalité {feature} et nécessite une version plus récente du programme que vous utilisez pour le lire. Veuillez faire une mise à jour pour la dernière version.",description:"Please make sure that your translation contains {feature} as a placeholder; it will be replaced with actual data. Do not translate that word."},"Version.Problem.Host":{message:"Ce livre utilise la fonctionnalité {feature} et nécessite une version plus récente de {host} pour le lire. Veuillez faire une mise à jour pour la dernière version.",description:"Please make sure that your translation contains {feature} and {host} as placeholders; they will be replaced with actual data. Do not translate those words. Host is the name of the app that should be upgraded, e.g., Bloom Reader."}},eT={"Button.Back":{message:"Baya",description:"tooltip for the button to go back to the main display"}},nT={"Quiz.CheckYourUnderstanding":{message:"अपनी समझ की जांचें",description:"the heading on (some) quiz pages"},"Button.Back":{message:"पीछे जाएं",description:"tooltip for the button to go back to the main display"}},aT={"Button.Back":{message:"Kembali",description:"tooltip for the button to go back to the main display"}},iT={"Button.Back":{message:"War-dhelergh",description:"tooltip for the button to go back to the main display"}},rT={"Button.Back":{message:"ຄືນ",description:"tooltip for the button to go back to the main display"}},oT={"Quiz.CheckYourUnderstanding":{message:"Ka'yinxa qa in ex toj twi'ya",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"B'inxa",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Ok jawil u'jit kyuw",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Maqonxa",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Tanjtz ti'ja",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Txqantl",description:"tooltip for the button to go show detail view of book"}},sT={"Quiz.CheckYourUnderstanding":{message:"သင်မည်မျှနားလည်ကို စစ်ဆေးရန်",description:"the heading on (some) quiz pages"}},lT={"Button.Back":{message:"पछाडि",description:"tooltip for the button to go back to the main display"}},uT={"Quiz.CheckYourUnderstanding":{message:"خپله پوهه وګوره",description:"the heading on (some) quiz pages"},"Button.Back":{message:"شاته",description:"tooltip for the button to go back to the main display"}},cT={"Quiz.CheckYourUnderstanding":{message:"درک خود را بررسی کنید",description:"the heading on (some) quiz pages"},"Button.Back":{message:"عقب",description:"tooltip for the button to go back to the main display"}},dT={"Quiz.CheckYourUnderstanding":{message:"Verifique seu entendimento",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"Tocar",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Ler em voz alta",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Pausar",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Voltar",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Mais",description:"tooltip for the button to go show detail view of book"},"Button.FullScreen":{message:"Tela Inteira",description:"tooltip for the display on full screen button"},"Button.ExitFullScreen":{message:"Sair da tela inteira",description:"tooltip for the exit full screen button"},"Button.ChooseLanguage":{message:"Selecionar o idioma",description:"tooltip for the language menu button"},"Button.Next":{message:"Próxima página",description:"tooltip for the next page button"},"Button.Prev":{message:"Página anterior",description:"tooltip for the previous page button"},"Button.ReadImageDescriptions":{message:"Ler descrições da imagem",description:"tooltip for the button to enable reading image descriptions"},"Button.IgnoreImageDescriptions":{message:"Ignorar Descrições da Imagem",description:"tooltip for the button to disable reading image descriptions"},"Version.Problem.Web":{message:"Este livro usa o recurso {feature}. Infelizmente, {hostname} ainda não está pronto para exibir este livro. Por favor, volte mais tarde ou escreva para issues@bloomlibrary.org se achar que isto é inesperado.",description:"Please make sure that your translation contains {feature} and {hostname} as placeholders; they will be replaced with actual data. Do not translate those words."},"Version.Problem.NoHost":{message:"Este livro usa o recurso {feature} e requer uma versão mais recente do programa que você usa para lê-lo. Por favor, atualize para a versão mais recente.",description:"Please make sure that your translation contains {feature} as a placeholder; it will be replaced with actual data. Do not translate that word."},"Version.Problem.Host":{message:"Este livro utiliza o recurso {feature} e requer uma versão mais recente do {host} para ser lido. Atualize para a versão mais recente.",description:"Please make sure that your translation contains {feature} and {host} as placeholders; they will be replaced with actual data. Do not translate those words. Host is the name of the app that should be upgraded, e.g., Bloom Reader."}},fT={"Quiz.CheckYourUnderstanding":{message:"Chawila le aweta'mab'al",description:"the heading on (some) quiz pages"},"Button.Back":{message:"Utzalixik",description:"tooltip for the button to go back to the main display"}},hT={"Quiz.CheckYourUnderstanding":{message:"Проверьте ваше понимание",description:"the heading on (some) quiz pages"},"Button.Back":{message:"Назад",description:"tooltip for the button to go back to the main display"}},pT={"Quiz.CheckYourUnderstanding":{message:"Angalia Uelewa Wako",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"Cheza",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Soma kwa sauti",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Sitisha",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Nyuma",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Zaidi",description:"tooltip for the button to go show detail view of book"},"Button.FullScreen":{message:"Skrini kamili",description:"tooltip for the display on full screen button"},"Button.ExitFullScreen":{message:"Toka skrini kamili",description:"tooltip for the exit full screen button"},"Button.ChooseLanguage":{message:"Chagua lugha",description:"tooltip for the language menu button"},"Button.Next":{message:"Ukurasa unaofuata",description:"tooltip for the next page button"},"Button.Prev":{message:"Ukurasa uliopita",description:"tooltip for the previous page button"},"Button.ReadImageDescriptions":{message:"Soma Maelezo ya Picha",description:"tooltip for the button to enable reading image descriptions"},"Button.IgnoreImageDescriptions":{message:"Puuza Maelezo ya Picha",description:"tooltip for the button to disable reading image descriptions"}},gT={"Button.Back":{message:"பின்",description:"tooltip for the button to go back to the main display"}},mT={"Button.Back":{message:"తిరిగి",description:"tooltip for the button to go back to the main display"}},vT={"Button.Back":{message:"กลับ",description:"tooltip for the button to go back to the main display"}},yT={"Button.Back":{message:"Bumalik",description:"tooltip for the button to go back to the main display"}},bT={"Button.Back":{message:"Geri",description:"tooltip for the button to go back to the main display"}},wT={"Audio.Pause":{message:"Tạm dừng",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Quay Lại",description:"tooltip for the button to go back to the main display"}},kT={"Quiz.CheckYourUnderstanding":{message:"检查理解",description:"the heading on (some) quiz pages"},"Button.Back":{message:"后退",description:"tooltip for the button to go back to the main display"}},xT={ar:XC,az:ZC,bn:JC,es:QC,fr:tT,ha:eT,hi:nT,id:aT,kw:iT,lo:rT,mam:oT,my:sT,ne:lT,pbu:uT,prs:cT,pt:dT,quc:fT,ru:hT,sw:pT,ta:gT,te:mT,th:vT,tl:yT,tr:bT,vi:wT,zh:kT};class ST{constructor(){this.l10nDictionary=new Map,this.isSetup=!1}setUp(e){if(this.isSetup)return;this.isSetup=!0;const n=e||xT;Object.keys(n).forEach(a=>{const i=n[a];Object.keys(i).forEach(r=>{let s=this.l10nDictionary.get(r);s||(s=new Map,this.l10nDictionary.set(r,s)),s.set(a,i[r].message)})})}localizePages(e,n){const a=e.querySelectorAll(".bloom-page [data-i18n]");a&&Array.from(a).forEach(i=>{this.localizeElement(i,n)})}localizeElement(e,n){const a=e.dataset.i18n;if(!a)return;const[i,r]=this.getTranslationAndLanguage(a,n);i&&r&&(e.innerText=i,e.setAttribute("lang",r))}getTranslationAndLanguage(e,n){const a=this.l10nDictionary.get(e);if(!a||!n)return[void 0,void 0];for(let r=0;r<n.length;r++){const s=n[r],u=a.get(s);if(u)return[u,s]}const i=a.get("en");return i?[i,"en"]:[void 0,void 0]}getTranslation(e,n,a){const[i]=this.getTranslationAndLanguage(e,n);return i||a}getBloomUiLanguage(){const e=navigator.language;return this.removeRegionCode(e)}removeRegionCode(e){const n=e.indexOf("-");return n<0?e:e.substring(0,n)}}const He=new ST;class CT{constructor(){this.data={}}getData(){return this.data}setData(e){this.data=e}}const Mh=new CT;function ga(t,e){return TT(t,e)}function TT(t,e){return Ah(t,n=>n,e)}function Ah(t,e,n){const a=ET(window.location.search);return n!==void 0&&(a[t]===void 0||a[t]===null)?n:e(a[t])}function ET(t){return t.substring(1).replace(/\+/g," ").split("&").filter(Boolean).reduce((n,a)=>{const i=a.split("="),r=decodeURIComponent(i[0]||""),s=decodeURIComponent(i[1]||"");return n[r]=s,n},{})}function Vn(t,e){return Ah(t,a=>a.toLowerCase()==="true",e)}function Qg(t,e){return Ah(t,Number.parseFloat,e)}var jr=(t=>(t[t.Dev=0]="Dev",t[t.Prod=1]="Prod",t[t.Test=2]="Test",t))(jr||{});(function(){var t=window.analytics=window.analytics||[];if(!t.initialize)if(t.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{t.invoked=!0,t.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"],t.factory=function(a){return function(){var i=Array.prototype.slice.call(arguments);return i.unshift(a),t.push(i),t}};for(var e=0;e<t.methods.length;e++){var n=t.methods[e];t[n]=t.factory(n)}t.load=function(a,i){var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=NT();var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(r,s),t._loadOptions=i},t.SNIPPET_VERSION="4.1.0"}})();window.location.search.includes("independent=false")||(window.analytics.load(),window.onbeforeunload=PT);const Hl="bloom-player-read-duration",tm="bloom-player-book-url";function PT(){const t=Fl.entries();let e=t.next();for(;!e.done;){const n=e.value[0],a=e.value[1];Nh(n,a),e=t.next()}return Fl.clear(),localStorage.removeItem(Hl),null}function Nh(t,e){window.analytics.track(t,e)}const Fl=new Map;let Gc=!1;function MT(t,e){!Gc&&e.lastNumberedPageRead&&(Nh(t,e),Gc=!0,Fl.delete(t),localStorage.removeItem(Hl)),!Gc&&Fl.set(t,e)}function AT(){return window.location.hostname==="dev.bloomlibrary.org"||window.location.search.includes("dev.bloomlibrary.org")?jr.Dev:window.location.hostname==="localhost"||window.location.search.includes("localhost")?jr.Test:jr.Prod}function NT(){switch(AT()){case jr.Prod:return"https://bloomlibrary.org/analytics.min.js";case jr.Dev:return"https://bloomlibrary.org/analytics.dev.min.js";default:return"https://bloomlibrary.org/analytics.test.min.js"}}function ja(t){var a,i,r;const e=JSON.stringify(t);if(window.ParentProxy){window.ParentProxy.receiveMessage(e);return}const n=(r=(i=(a=window.webkit)==null?void 0:a.messageHandlers)==null?void 0:i.receiveMessage)==null?void 0:r.postMessage;if(n){n(e);return}window.parent&&window.parent.postMessage(e,"*")}function LT(t,e){ja({messageType:"storePageData",key:t,value:e})}let fs={};function zT(t){fs=t}function Xy(t,e){Vn("independent",!0)?Nh(t,{...fs,...e}):ja({messageType:"sendAnalytics",event:t,params:{...fs,...e}})}function BT(t){ja({messageType:"reportBookProperties",params:{...t}})}function DT(t){ja({messageType:"playbackComplete",params:{...t}})}function IT(t,e){Vn("independent",!0)?MT(t,{...fs,...e}):(ga("host","")!=="bloomlibrary"&&delete e.readDuration,ja({messageType:"updateBookProgressReport",event:t,params:{...fs,...e}}))}function jT(){ja({messageType:"backButtonClicked"})}function RT(){ja({messageType:"showNavBar"})}function OT(){ja({messageType:"hideNavBar"})}function KT(t){ja({messageType:"logError",message:t})}let tf=null;function $T(t){tf=t}let em=null;function qT(t){let e=null;try{e=JSON.parse(t)}catch(a){console.log("receiveMessage failed to parse json: "+t+" with error "+a.message);return}const n=e.messageType;n==="restorePageData"&&Mh.setData(e.pageData),n==="capabilities"&&em&&em(e),n==="control"&&tf&&tf(e)}window.addEventListener("message",t=>{!t||!t.data||t.data.length===0||qT(t.data)});const HT=`tag3 tag1 name autonym
26
+ `,e.firstChild},hi=class hi{constructor(){this.currentVideoStartTime=0,this.isPlayingSingleVideo=!1,this.handlePlayClick=e=>{var a,i;e.stopPropagation(),e.preventDefault();const n=(i=(a=e.target)==null?void 0:a.closest(".bloom-videoContainer"))==null?void 0:i.getElementsByTagName("video")[0];n&&(n===this.currentVideoElement?this.play():this.replaySingleVideo(n))},this.handleVideoClick=e=>{e.currentTarget.paused?this.handlePlayClick(e):this.handlePauseClick(e)},this.handleReplayClick=e=>{var a,i;e.stopPropagation(),e.preventDefault();const n=(i=(a=e.target)==null?void 0:a.closest(".bloom-videoContainer"))==null?void 0:i.getElementsByTagName("video")[0];n&&this.replaySingleVideo(n)},this.handlePauseClick=e=>{e.stopPropagation(),e.preventDefault(),this.pause()}}static pageHasVideo(e){return!!hi.getVideoElements(e).length}wrapVideoIcon(e,n,a){var r;const i=document.createElement("div");return i.classList.add("videoControlContainer"),i.appendChild(n),i.classList.add(a),n.classList.add("videoControl"),(r=e.parentElement)==null||r.appendChild(i),n}static setAllVideoPostersTo1x1TransparentPNG(e){const n=e.getElementsByTagName("video");for(let a=0;a<n.length;a++)n[a].setAttribute("poster",hi.onePixelTransparentPoster)}HandlePageBeforeVisible(e){if(this.currentPage=e,!hi.pageHasVideo(this.currentPage)){this.currentVideoElement=void 0;return}this.getVideoElements().forEach(n=>{n.removeAttribute("controls"),n.addEventListener("click",this.handleVideoClick),this.wrapVideoIcon(n,HC("#ffffff"),"videoPlayIcon").addEventListener("click",this.handlePlayClick),this.wrapVideoIcon(n,FC("#ffffff"),"videoPauseIcon").addEventListener("click",this.handlePauseClick),this.wrapVideoIcon(n,WC("#ffffff"),"videoReplayIcon").addEventListener("click",this.handleReplayClick),n.currentTime!==0&&(n.currentTime=0)})}HandlePageVisible(e,n){var i;if(this.currentPage=e,!hi.pageHasVideo(this.currentPage)){this.currentVideoElement=void 0;return}yn===Ge.VideoPaused&&((i=this.currentVideoElement)==null||i.pause());const a=this.getVideoElements();if(a.length>0){const r=a[0];let s=!0;r.addEventListener("playing",()=>{(s||n())&&r.pause()},{once:!0}),r.play(),window.setTimeout(()=>{s=!1,n()||this.playAllVideo(a)},1e3)}}static getVideoElements(e){return Array.from(e.getElementsByClassName("bloom-videoContainer")).map(n=>n.getElementsByTagName("video")[0]).filter(n=>n!==void 0)}getVideoElements(){return hi.getVideoElements(this.currentPage)}play(){yn!==Ge.VideoPlaying&&(Mn(Ge.VideoPlaying),this.isPlayingSingleVideo?this.playAllVideo([this.currentVideoElement]):this.resumePlayAllVideo())}resumePlayAllVideo(){const e=this.getVideoElements();let n=e;if(this.currentVideoElement){const a=e.indexOf(this.currentVideoElement);n=e.slice(a)}this.playAllVideo(n)}pause(){yn!=Ge.VideoPaused&&(this.pauseCurrentVideo(),Mn(Ge.VideoPaused))}pauseCurrentVideo(){var n;this.currentPage&&Array.from(this.currentPage.getElementsByClassName("playing")).forEach(a=>a.classList.remove("playing"));const e=this.currentVideoElement;e&&(e.currentTime>0&&!e.paused&&!e.ended&&this.reportVideoPlayed(e.currentTime-this.currentVideoStartTime),(n=e==null?void 0:e.closest(".bloom-videoContainer"))==null||n.classList.add("paused"),e.pause())}reportVideoPlayed(e){Se.storeVideoAnalytics(e)}hidingPage(){this.pauseCurrentVideo()}replaySingleVideo(e){e.currentTime=0,this.isPlayingSingleVideo=!0,this.playAllVideo([e])}playAllVideo(e){var i;if(Array.from(this.currentPage.getElementsByClassName("playing")).forEach(r=>r.classList.remove("playing")),e.length===0){this.currentVideoElement=void 0,this.isPlayingSingleVideo=!1,this.PageVideoComplete&&this.PageVideoComplete.raise({page:this.currentPage,videos:this.getVideoElements()});return}Array.from(this.currentPage.getElementsByClassName("paused")).forEach(r=>r.classList.remove("paused"));const n=e[0],a=n.closest(".bloom-page");if(this.currentPage!==a){this.currentVideoElement=void 0;return}this.currentVideoElement=n,n.networkState===HTMLMediaElement.NETWORK_NO_SOURCE&&n.readyState===HTMLMediaElement.HAVE_NOTHING?(ql(n),this.playAllVideo(e.slice(1))):(Vy(n),Mn(Ge.VideoPlaying),this.currentVideoStartTime=n.currentTime||0,(i=n.closest(".bloom-videoContainer"))==null||i.classList.add("playing"),n.play().then(()=>{n.addEventListener("ended",()=>{this.reportVideoPlayed(n.currentTime-this.currentVideoStartTime),n.currentTime=0,this.playAllVideo(e.slice(1))},{once:!0})}).catch(s=>{console.error("Video play failed",s),ql(n),this.playAllVideo(e.slice(1))}))}};hi.onePixelTransparentPoster="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=";let Uo=hi,Qa=[];function Gy(t,e){const n=Qa.length;return Qa.push({src:t,volume:e,startTime:new Date().toISOString()}),n}function _C(t){t>=0&&t<Qa.length&&(Qa[t].endTime=new Date().toISOString())}function VC(){Qa=[]}function GC(t){const e=Qa.length;return Qa.push({...Qa[t],startTime:new Date().toISOString()}),e}function UC(){Yy("publish/av/soundLog",Qa,"application/json; charset=utf-8")}function Uy(t,e){return Yy(t,e,"text/plain")}function Yy(t,e,n){return Ja.post("/bloom/api/"+t,e,{headers:{"Content-Type":n}})}class YC{constructor(){this.pageIdToSelectionMap=new Map,this.musicLogIndex=-1}pageHasMusic(e){return this.pageIdToSelectionMap.has(this.getPageId(e))}HandlePageVisible(e){this.currentPage=e,this.currentPage&&(this.pageHasMusic(this.currentPage)?this.listen():this.getPlayer().pause())}hidingPage(){}listen(){this.setMusicSourceAndVolume(),yn===Ge.AudioPaused?this.getPlayer().pause():this.playerPlay()}play(){this.currentPage&&this.playerPlay()}pause(){this.currentPage&&(this.getPlayer().pause(),_C(this.musicLogIndex))}processAllMusicForBook(e){this.pageIdToSelectionMap=new Map;let n=-1,a;for(let i=0;i<e.length;i++){const r=e[i],s=r.getAttribute("data-backgroundaudio");s!==null&&s!==""?(a={id:++n,src:s,volume:this.getMusicVolume(r)},this.pageIdToSelectionMap.set(this.getPageId(r),a)):s===null?a&&this.pageIdToSelectionMap.set(this.getPageId(r),a):a=void 0}}getPageId(e){return e.getAttribute("id")||""}getPlayer(){let e=document.querySelector("#music-player");return e||(e=document.createElement("audio"),e.setAttribute("id","music-player"),document.body.appendChild(e),e.addEventListener("ended",()=>this.playEnded())),e}setMusicSourceAndVolume(){const e=this.pageIdToSelectionMap.get(this.getPageId(this.currentPage));if(e===void 0){this.selectionPlaying=void 0;return}if(e===this.selectionPlaying)return;this.selectionPlaying=e;const n=e.src,a=e.volume,i=this.currentMusicUrl(n+"?nocache="+new Date().getTime()),r=this.getPlayer();r.setAttribute("src",n?i:""),a.length&&(r.volume=Number(a)),n&&(this.musicLogIndex=Gy(i,a.length?Number(a):1))}getMusicVolume(e){if(!e)return"";const n=e.getAttribute("data-backgroundaudiovolume");return n||""}currentMusicUrl(e){return this.urlPrefix+"/audio/"+e}playEnded(){this.getPlayer().currentTime=0,this.play(),this.musicLogIndex=GC(this.musicLogIndex)}playerPlay(){const e=this.getPlayer().play();e&&e.catch&&e.catch(n=>{console.log("could not play music: "+n),this.getPlayer().pause(),n.name==="NotAllowedError"&&this.PlayFailed&&this.PlayFailed.raise()})}}const XC={"Button.Back":{message:"رجوع",description:"tooltip for the button to go back to the main display"}},ZC={"Audio.Pause":{message:"Fasilə etmək",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Gəri",description:"tooltip for the button to go back to the main display"}},JC={"Quiz.CheckYourUnderstanding":{message:"আপনাদের বোধশক্তির পরীক্ষা করুন",description:"the heading on (some) quiz pages"},"Button.Back":{message:"পিছনে",description:"tooltip for the button to go back to the main display"}},QC={"Quiz.CheckYourUnderstanding":{message:"Compruebe su comprensión",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"Reproducir",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Leer en voz alta",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Pausar",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Regresar",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Más",description:"tooltip for the button to go show detail view of book"},"Button.FullScreen":{message:"Pantalla completa",description:"tooltip for the display on full screen button"},"Button.ExitFullScreen":{message:"Salir de pantalla completa",description:"tooltip for the exit full screen button"},"Button.ChooseLanguage":{message:"Elija el idioma",description:"tooltip for the language menu button"},"Button.Next":{message:"Página siguiente",description:"tooltip for the next page button"},"Button.Prev":{message:"Página previa",description:"tooltip for the previous page button"},"Button.ReadImageDescriptions":{message:"Leer las descripciones de las imágenes",description:"tooltip for the button to enable reading image descriptions"},"Button.IgnoreImageDescriptions":{message:"Ignorar las descripciones de las imágenes",description:"tooltip for the button to disable reading image descriptions"}},tT={"Quiz.CheckYourUnderstanding":{message:"Contrôlez Votre Compréhension",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"Lecture",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Lecture Livre Audio",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Pause",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Retour",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Plus d’infos",description:"tooltip for the button to go show detail view of book"},"Button.FullScreen":{message:"Plein Écran",description:"tooltip for the display on full screen button"},"Button.ExitFullScreen":{message:"Sortir du mode Plein Ecran",description:"tooltip for the exit full screen button"},"Button.ChooseLanguage":{message:"Choisir Langue",description:"tooltip for the language menu button"},"Button.Next":{message:"Page Suivante",description:"tooltip for the next page button"},"Button.Prev":{message:"Page Précédente",description:"tooltip for the previous page button"},"Button.ReadImageDescriptions":{message:"Lire la Description des Images",description:"tooltip for the button to enable reading image descriptions"},"Button.IgnoreImageDescriptions":{message:"Ignorer la Description des Images",description:"tooltip for the button to disable reading image descriptions"},"Version.Problem.Web":{message:"Ce livre utilise la fonctionnalité {feature}. Malheureusement, {hostname} n'est pas encore prêt à afficher ce livre. Veuillez revenir plus tard ou bien écrivez à issues@bloomlibrary.org si vous pensez que c'est une réponse inattendue.",description:"Please make sure that your translation contains {feature} and {hostname} as placeholders; they will be replaced with actual data. Do not translate those words."},"Version.Problem.NoHost":{message:"Ce livre utilise la fonctionnalité {feature} et nécessite une version plus récente du programme que vous utilisez pour le lire. Veuillez faire une mise à jour pour la dernière version.",description:"Please make sure that your translation contains {feature} as a placeholder; it will be replaced with actual data. Do not translate that word."},"Version.Problem.Host":{message:"Ce livre utilise la fonctionnalité {feature} et nécessite une version plus récente de {host} pour le lire. Veuillez faire une mise à jour pour la dernière version.",description:"Please make sure that your translation contains {feature} and {host} as placeholders; they will be replaced with actual data. Do not translate those words. Host is the name of the app that should be upgraded, e.g., Bloom Reader."}},eT={"Button.Back":{message:"Baya",description:"tooltip for the button to go back to the main display"}},nT={"Quiz.CheckYourUnderstanding":{message:"अपनी समझ की जांचें",description:"the heading on (some) quiz pages"},"Button.Back":{message:"पीछे जाएं",description:"tooltip for the button to go back to the main display"}},aT={"Button.Back":{message:"Kembali",description:"tooltip for the button to go back to the main display"}},iT={"Button.Back":{message:"War-dhelergh",description:"tooltip for the button to go back to the main display"}},rT={"Button.Back":{message:"ຄືນ",description:"tooltip for the button to go back to the main display"}},oT={"Quiz.CheckYourUnderstanding":{message:"Ka'yinxa qa in ex toj twi'ya",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"B'inxa",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Ok jawil u'jit kyuw",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Maqonxa",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Tanjtz ti'ja",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Txqantl",description:"tooltip for the button to go show detail view of book"}},sT={"Quiz.CheckYourUnderstanding":{message:"သင်မည်မျှနားလည်ကို စစ်ဆေးရန်",description:"the heading on (some) quiz pages"}},lT={"Button.Back":{message:"पछाडि",description:"tooltip for the button to go back to the main display"}},uT={"Quiz.CheckYourUnderstanding":{message:"خپله پوهه وګوره",description:"the heading on (some) quiz pages"},"Button.Back":{message:"شاته",description:"tooltip for the button to go back to the main display"}},cT={"Quiz.CheckYourUnderstanding":{message:"درک خود را بررسی کنید",description:"the heading on (some) quiz pages"},"Button.Back":{message:"عقب",description:"tooltip for the button to go back to the main display"}},dT={"Quiz.CheckYourUnderstanding":{message:"Verifique a sua compreensão",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"Tocar",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Ler em voz alta",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Pausar",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Voltar",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Mais",description:"tooltip for the button to go show detail view of book"},"Button.FullScreen":{message:"Tela Cheia (Ecrã inteiro)",description:"tooltip for the display on full screen button"},"Button.ExitFullScreen":{message:"Sair da tela cheia (ecrã inteiro)",description:"tooltip for the exit full screen button"},"Button.ChooseLanguage":{message:"Selecionar a língua",description:"tooltip for the language menu button"},"Button.Next":{message:"Próxima página",description:"tooltip for the next page button"},"Button.Prev":{message:"Página anterior",description:"tooltip for the previous page button"},"Button.ReadImageDescriptions":{message:"Ler descrições da imagem",description:"tooltip for the button to enable reading image descriptions"},"Button.IgnoreImageDescriptions":{message:"Ignorar Descrições da Imagem",description:"tooltip for the button to disable reading image descriptions"},"Version.Problem.Web":{message:"Este livro usa o recurso {feature}. Infelizmente, {hostname} ainda não está pronto para exibir este livro. Por favor, volte mais tarde ou escreva para issues@bloomlibrary.org se isto for inesperado.",description:"Please make sure that your translation contains {feature} and {hostname} as placeholders; they will be replaced with actual data. Do not translate those words."},"Version.Problem.NoHost":{message:"Este livro utiliza o recurso {feature} e requer uma versão mais recente do programa que você usa para lê-lo. Por favor, atualize para a versão mais recente.",description:"Please make sure that your translation contains {feature} as a placeholder; it will be replaced with actual data. Do not translate that word."},"Version.Problem.Host":{message:"Este livro utiliza o recurso {feature} e requer uma versão mais recente do {host} para ser lido. Atualize para a versão mais recente.",description:"Please make sure that your translation contains {feature} and {host} as placeholders; they will be replaced with actual data. Do not translate those words. Host is the name of the app that should be upgraded, e.g., Bloom Reader."}},fT={"Quiz.CheckYourUnderstanding":{message:"Chawila le aweta'mab'al",description:"the heading on (some) quiz pages"},"Button.Back":{message:"Utzalixik",description:"tooltip for the button to go back to the main display"}},hT={"Quiz.CheckYourUnderstanding":{message:"Проверьте ваше понимание",description:"the heading on (some) quiz pages"},"Button.Back":{message:"Назад",description:"tooltip for the button to go back to the main display"}},pT={"Quiz.CheckYourUnderstanding":{message:"Angalia Uelewa Wako",description:"the heading on (some) quiz pages"},"Audio.Play":{message:"Cheza",description:"tooltip for the button to play a motion book"},"Audio.ReadAloud":{message:"Soma kwa sauti",description:"tooltip for the audio play button for talking books"},"Audio.Pause":{message:"Sitisha",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Nyuma",description:"tooltip for the button to go back to the main display"},"Button.More":{message:"Zaidi",description:"tooltip for the button to go show detail view of book"},"Button.FullScreen":{message:"Skrini kamili",description:"tooltip for the display on full screen button"},"Button.ExitFullScreen":{message:"Toka skrini kamili",description:"tooltip for the exit full screen button"},"Button.ChooseLanguage":{message:"Chagua lugha",description:"tooltip for the language menu button"},"Button.Next":{message:"Ukurasa unaofuata",description:"tooltip for the next page button"},"Button.Prev":{message:"Ukurasa uliopita",description:"tooltip for the previous page button"},"Button.ReadImageDescriptions":{message:"Soma Maelezo ya Picha",description:"tooltip for the button to enable reading image descriptions"},"Button.IgnoreImageDescriptions":{message:"Puuza Maelezo ya Picha",description:"tooltip for the button to disable reading image descriptions"}},gT={"Button.Back":{message:"பின்",description:"tooltip for the button to go back to the main display"}},mT={"Button.Back":{message:"తిరిగి",description:"tooltip for the button to go back to the main display"}},vT={"Button.Back":{message:"กลับ",description:"tooltip for the button to go back to the main display"}},yT={"Button.Back":{message:"Bumalik",description:"tooltip for the button to go back to the main display"}},bT={"Button.Back":{message:"Geri",description:"tooltip for the button to go back to the main display"}},wT={"Audio.Pause":{message:"Tạm dừng",description:"tooltip for the audio (or motion) pause button"},"Button.Back":{message:"Quay Lại",description:"tooltip for the button to go back to the main display"}},kT={"Quiz.CheckYourUnderstanding":{message:"检查理解",description:"the heading on (some) quiz pages"},"Button.Back":{message:"后退",description:"tooltip for the button to go back to the main display"}},xT={ar:XC,az:ZC,bn:JC,es:QC,fr:tT,ha:eT,hi:nT,id:aT,kw:iT,lo:rT,mam:oT,my:sT,ne:lT,pbu:uT,prs:cT,pt:dT,quc:fT,ru:hT,sw:pT,ta:gT,te:mT,th:vT,tl:yT,tr:bT,vi:wT,zh:kT};class ST{constructor(){this.l10nDictionary=new Map,this.isSetup=!1}setUp(e){if(this.isSetup)return;this.isSetup=!0;const n=e||xT;Object.keys(n).forEach(a=>{const i=n[a];Object.keys(i).forEach(r=>{let s=this.l10nDictionary.get(r);s||(s=new Map,this.l10nDictionary.set(r,s)),s.set(a,i[r].message)})})}localizePages(e,n){const a=e.querySelectorAll(".bloom-page [data-i18n]");a&&Array.from(a).forEach(i=>{this.localizeElement(i,n)})}localizeElement(e,n){const a=e.dataset.i18n;if(!a)return;const[i,r]=this.getTranslationAndLanguage(a,n);i&&r&&(e.innerText=i,e.setAttribute("lang",r))}getTranslationAndLanguage(e,n){const a=this.l10nDictionary.get(e);if(!a||!n)return[void 0,void 0];for(let r=0;r<n.length;r++){const s=n[r],u=a.get(s);if(u)return[u,s]}const i=a.get("en");return i?[i,"en"]:[void 0,void 0]}getTranslation(e,n,a){const[i]=this.getTranslationAndLanguage(e,n);return i||a}getBloomUiLanguage(){const e=navigator.language;return this.removeRegionCode(e)}removeRegionCode(e){const n=e.indexOf("-");return n<0?e:e.substring(0,n)}}const He=new ST;class CT{constructor(){this.data={}}getData(){return this.data}setData(e){this.data=e}}const Mh=new CT;function ga(t,e){return TT(t,e)}function TT(t,e){return Ah(t,n=>n,e)}function Ah(t,e,n){const a=ET(window.location.search);return n!==void 0&&(a[t]===void 0||a[t]===null)?n:e(a[t])}function ET(t){return t.substring(1).replace(/\+/g," ").split("&").filter(Boolean).reduce((n,a)=>{const i=a.split("="),r=decodeURIComponent(i[0]||""),s=decodeURIComponent(i[1]||"");return n[r]=s,n},{})}function Vn(t,e){return Ah(t,a=>a.toLowerCase()==="true",e)}function Qg(t,e){return Ah(t,Number.parseFloat,e)}var jr=(t=>(t[t.Dev=0]="Dev",t[t.Prod=1]="Prod",t[t.Test=2]="Test",t))(jr||{});(function(){var t=window.analytics=window.analytics||[];if(!t.initialize)if(t.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{t.invoked=!0,t.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"],t.factory=function(a){return function(){var i=Array.prototype.slice.call(arguments);return i.unshift(a),t.push(i),t}};for(var e=0;e<t.methods.length;e++){var n=t.methods[e];t[n]=t.factory(n)}t.load=function(a,i){var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=NT();var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(r,s),t._loadOptions=i},t.SNIPPET_VERSION="4.1.0"}})();window.location.search.includes("independent=false")||(window.analytics.load(),window.onbeforeunload=PT);const Hl="bloom-player-read-duration",tm="bloom-player-book-url";function PT(){const t=Fl.entries();let e=t.next();for(;!e.done;){const n=e.value[0],a=e.value[1];Nh(n,a),e=t.next()}return Fl.clear(),localStorage.removeItem(Hl),null}function Nh(t,e){window.analytics.track(t,e)}const Fl=new Map;let Gc=!1;function MT(t,e){!Gc&&e.lastNumberedPageRead&&(Nh(t,e),Gc=!0,Fl.delete(t),localStorage.removeItem(Hl)),!Gc&&Fl.set(t,e)}function AT(){return window.location.hostname==="dev.bloomlibrary.org"||window.location.search.includes("dev.bloomlibrary.org")?jr.Dev:window.location.hostname==="localhost"||window.location.search.includes("localhost")?jr.Test:jr.Prod}function NT(){switch(AT()){case jr.Prod:return"https://bloomlibrary.org/analytics.min.js";case jr.Dev:return"https://bloomlibrary.org/analytics.dev.min.js";default:return"https://bloomlibrary.org/analytics.test.min.js"}}function ja(t){var a,i,r;const e=JSON.stringify(t);if(window.ParentProxy){window.ParentProxy.receiveMessage(e);return}const n=(r=(i=(a=window.webkit)==null?void 0:a.messageHandlers)==null?void 0:i.receiveMessage)==null?void 0:r.postMessage;if(n){n(e);return}window.parent&&window.parent.postMessage(e,"*")}function LT(t,e){ja({messageType:"storePageData",key:t,value:e})}let fs={};function zT(t){fs=t}function Xy(t,e){Vn("independent",!0)?Nh(t,{...fs,...e}):ja({messageType:"sendAnalytics",event:t,params:{...fs,...e}})}function BT(t){ja({messageType:"reportBookProperties",params:{...t}})}function DT(t){ja({messageType:"playbackComplete",params:{...t}})}function IT(t,e){Vn("independent",!0)?MT(t,{...fs,...e}):(ga("host","")!=="bloomlibrary"&&delete e.readDuration,ja({messageType:"updateBookProgressReport",event:t,params:{...fs,...e}}))}function jT(){ja({messageType:"backButtonClicked"})}function RT(){ja({messageType:"showNavBar"})}function OT(){ja({messageType:"hideNavBar"})}function KT(t){ja({messageType:"logError",message:t})}let tf=null;function $T(t){tf=t}let em=null;function qT(t){let e=null;try{e=JSON.parse(t)}catch(a){console.log("receiveMessage failed to parse json: "+t+" with error "+a.message);return}const n=e.messageType;n==="restorePageData"&&Mh.setData(e.pageData),n==="capabilities"&&em&&em(e),n==="control"&&tf&&tf(e)}window.addEventListener("message",t=>{!t||!t.data||t.data.length===0||qT(t.data)});const HT=`tag3 tag1 name autonym
27
27
  kap Bezhta
28
28
  aar aa Afar Qafar
29
29
  aaq Eastern Abnaki
@@ -8047,7 +8047,7 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
8047
8047
  display:none !important;
8048
8048
  }
8049
8049
  `.replace(`
8050
- `,"").replace("\r","")}const oc=[];function BB(){return oc.length>0}function DB(t){const e=oc.pop();if(e)return{bookUrl:t===e.bookId?void 0:ch(e.bookId),pageId:e.pageId}}function IB(t,e,n){const a=t.target.closest("[href], [data-href]");if(!a)return;t.preventDefault(),t.stopPropagation();const i=(a.getAttribute("href")||a.getAttribute("data-href"))??void 0;if(!i)return;if(i.startsWith("http://")||i.startsWith("https://")){window.open(i,"_blank","noreferrer");return}let r,s;if(i==="back"){const c=oc.pop();return c?{bookUrl:e===c.bookId?void 0:ch(c.bookId),pageId:c.pageId}:void 0}else if(i.startsWith("/book/")){const c=jB(i);r=c.bookId,s=c.pageId,c.bookId===e&&(r=void 0)}else i.startsWith("#")&&(s=i.substring(1));const u=n();if(r)return oy(e,u),{bookUrl:ch(r),pageId:s};if(s)return oy(e,u),{pageId:s}}function oy(t,e,n){oc.push({bookId:t,pageId:e})}function ch(t){return`/book/${t}/index.htm`}function jB(t){try{const e=new URL(t,window.location.origin);if(!e.pathname.startsWith("/book/"))throw new Error("Invalid book URL format");const n=e.pathname.replace("/book/",""),a=e.hash.replace("#","");return{bookId:n,pageId:a}}catch(e){return console.error("Error parsing book URL:",e),{bookId:void 0,pageId:void 0}}}const RB="bloom-player",OB="A library for displaying Bloom books in iframes or WebViews",KB="SIL Global",$B="MIT",qB="2.16.0-alpha.4",HB=!1,FB={type:"git",url:"https://github.com/BloomBooks/bloom-player.git"},WB="module",_B="lib/shared.es.js",VB="lib/index.d.ts",GB={".":{types:"./lib/index.d.ts",import:"./lib/shared.es.js",default:"./lib/shared.es.js"}},UB={"// COMMENTS: make the action a space rather than empty string so `yarn run` can list the scripts":" ","//":" ","// 'yarn dev' will build, watch, start a server, and open the player in a brower":" ","// You can edit index-for-developing.html to point to different books":" ","// Or just use 'yarn storybook' and skip this dev approach entirely":" ",dev:"vite","build:standalone":"vite build","build:sharedlib":"vite build --mode lib",test:"vitest","// blame.ignoreRevsFile - This allows blame to see through commits that are only there to format code.":" ",prepare:"husky install && git config blame.ignoreRevsFile .git-blame-ignore-revs",storybook:"storybook dev -p 6006","// run this when working with stories that use an iframe and bloomplayer.htm instead of the raw react components":" ",watchForStorybook:"yarn vite build --watch --mode development","strings:download":"crowdin download --config src/l10n/crowdin.yml && yarn strings:compile","strings:upload":"crowdin upload --config src/l10n/crowdin.yml","strings:compile":"yarn tsx ./src/l10n/compileL10Strings.ts","strings:sync":"yarn strings:upload && yarn strings:download"},YB={"@material-ui/core":"^4.12.3","@material-ui/icons":"^4.11.2",axios:"^0.18.0","compare-versions":"^6.1.1","dynamic-import-polyfill":"^0.1.1","jquery.nicescroll":"^3.7.6",react:"^17.0.2","react-dom":"^17.0.2","react-id-swiper":"2.3.2","style-scoped":"^0.2.1",swiper:"^4.5.0"},XB={"@crowdin/cli":"^4.2.0","@storybook/addon-essentials":"8.4.6","@storybook/addon-interactions":"^8.4.6","@storybook/addon-links":"8.4.6","@storybook/blocks":"8.4.6","@storybook/react":"8.4.6","@storybook/react-vite":"8.4.6","@storybook/test":"8.4.6","@types/jquery":"^3.5.5","@types/jquery.nicescroll":"^3.7.1","@types/node":"^22.7.6","@types/react":"^17.0.2","@types/react-dom":"^17.0.2",editorconfig:"^2.0.0",eslint:"^9.12.0","eslint-plugin-storybook":"^0.11.1",husky:"8.0.3",jsdom:"^25.0.1",less:"^4.2.0",prettier:"^3.3.3","semantic-release":"24.1.2",storybook:"8.4.6",tsx:"^4.19.1",typescript:"*",vite:"^5.4.9","vite-plugin-dts":"^4.5.3","vite-plugin-html":"^3.2.2","vite-plugin-static-copy":"^2.0.0",vitest:"^2.1.3"},ZB=["dist/*.js","dist/bloomplayer.htm","dist/*.mp3","lib/*.js","lib/*.d.ts","lib/*.js.map","src/shared/event.ts","src/shared/narration.ts","src/shared/dragActivityRuntime.ts","src/shared/scrolling.ts","src/shared/index.ts","dist/*.css","dist/*.tsv"],JB={node:"20.15.1",yarn:"1.22.19"},QB={name:RB,description:OB,author:KB,license:$B,version:qB,private:!1,"// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working":"",sideEffects:HB,repository:FB,type:WB,module:_B,types:VB,exports:GB,scripts:UB,dependencies:YB,devDependencies:XB,"// The four src/ files are directly exported so BloomDesktop can consume them as shared code.":"",files:ZB,volta:JB},gi="#d65649",tD="#2e2e2e",eD="#febf00",Uk=gs({palette:{primary:{main:tD,contrastText:gi},secondary:{main:gi}}});function Yk(){var t=QB.version;return t}const nD=()=>{const[t,e]=B.useState(!1),n=Yk(),a=new Date("2025-09-25T20:54:52.463Z").toLocaleDateString();return B.useEffect(()=>{const i=s=>{s.key==="Control"&&e(!0)},r=s=>{s.key==="Control"&&e(!1)};return window.addEventListener("keydown",i),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",r)}},[]),t?kt.createElement("div",{className:"version-control",style:{color:gi,fontFamily:"sans-serif",padding:"5px",zIndex:1e3}},"Bloom Player v",n," (built ",a,")"):null},aD=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,sy=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");const e=t.match(aD);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},ly=t=>t==="*"||t==="x"||t==="X",uy=t=>{const e=parseInt(t,10);return isNaN(e)?t:e},iD=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],rD=(t,e)=>{if(ly(t)||ly(e))return 0;const[n,a]=iD(uy(t),uy(e));return n>a?1:n<a?-1:0},cy=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){const a=rD(t[n]||"0",e[n]||"0");if(a!==0)return a}return 0},dy=(t,e)=>{const n=sy(t),a=sy(e),i=n.pop(),r=a.pop(),s=cy(n,a);return s!==0?s:i&&r?cy(i.split("."),r.split(".")):i||r?i?-1:1:0};class Se extends B.Component{constructor(e,n){super(e,n),this.activityManager=new ez,this.initialPages=["loading..."],this.initialStyleRules="",this.originalPageClass="Device16x9Portrait",this.bookInfo=new uh,this.bookInteraction=new AB,this.mustUseOriginalPageSize=!1,this.indicesOfPagesWhereWeShouldPreserveDOMState={},this.startingUpSwiper=!0,this.state={pages:this.initialPages,pageIdToIndexMap:{},styleRules:this.initialStyleRules,importedBodyAttributes:{},currentSwiperIndex:0,isLoading:!0,loadFailed:!1,loadErrorHtml:"",ignorePhonyClick:!1,isFinishUpForNewBookComplete:!1,inPauseForced:!1,bookUrl:""},this.isPagesLocalized=!1,this.currentPageHidesNavigationButtons=!1,this.handleDocumentLevelKeyDown=i=>{i.key==="Home"&&(this.goToFirstPage(),i.preventDefault()),i.key==="End"&&(this.goToLastPage(),i.preventDefault())},this.distributionSource="",this.finishUpCalled=!1,this.hasImageDescriptions=!1,this.handlePageVideoComplete=i=>{i.page===Se.currentPage&&this.playAudioAndAnimation(i.page)},this.handlePlayFailed=()=>{this.setState({inPauseForced:!0}),this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!0)},this.handlePlayCompleted=()=>{Mn(Ge.MediaFinished),this.props.imageDescriptionCallback(!1)},this.handleToggleImageDescription=i=>{this.props.imageDescriptionCallback(i)},this.handlePageNarrationComplete=i=>{if(i&&(Mn(Ge.MediaFinished),this.shouldAutoPlay())){const r=this.props.autoplayCount??0,s=this.state.startPageIndex??0,u=this.swiperInstance.slides.length-1;let c=this.props.autoplayCount?Math.min(s+r-1,u):u;this.swiperInstance.activeIndex>=c?(this.music.pause(),this.props.shouldReportSoundLog&&UC(),VC(),DT({})):this.swiperInstance.slideNext()}},this.skipAutoPlay=!1,this.sentBloomNotification=!1;const a=e.url.startsWith("http")?new URL(e.url):new URL(e.url,window.location.origin);a.hash?(this.state.startPageId=a.hash.substring(1),a.hash=""):this.state.startPageIndex=e.startPageIndex,this.state.bookUrl=a.href,Se.currentPagePlayer=this,this.legacyQuestionHandler=new az(e.locationOfDistFolder)}componentDidMount(){He.setUp(),window.addEventListener("focus",()=>this.handleWindowFocus()),window.addEventListener("blur",()=>this.handleWindowBlur()),document.addEventListener("keydown",e=>this.handleDocumentLevelKeyDown(e)),document.addEventListener("pointerdown",e=>{(e.target.closest("[href], [data-href]")||e.target.closest(".bloom-videoContainer")&&!e.target.closest("[data-draggable-id]"))&&(e.stopPropagation(),e.preventDefault())},{capture:!0}),document.addEventListener("dragstart",e=>{this.activityManager.getActivityAbsorbsDragging()||e.preventDefault()},{capture:!0}),this.componentDidUpdate(this.props,this.state)}CanGoBack(){return BB()}HandleBackButtonClickedIfHavePlayerHistory(){const e=DB(this.bookInfo.bookInstanceId);return e?(this.navigate(e.bookUrl,e.pageId),!0):!1}navigate(e,n){if(e){const a=new URL(e,this.state.bookUrl);this.setState({bookUrl:a.href,startPageId:n,startPageIndex:void 0})}else if(n!==void 0){const a=this.state.pageIdToIndexMap[n];this.swiperInstance.slideTo(a)}}handleWindowFocus(){const e=localStorage.getItem(Hl),n=localStorage.getItem(tm);e&&n==this.sourceUrl&&(this.bookInteraction.beginReadTime=Date.now()-parseInt(e,10))}handleWindowBlur(){const e=Date.now()-this.bookInteraction.beginReadTime;localStorage.setItem(Hl,e.toString()),localStorage.setItem(tm,this.sourceUrl)}getRequiredVersionMessage(e){var c;const n=(c=e.querySelector('meta[name="FeatureRequirement"]'))==null?void 0:c.getAttribute("content");if(!n)return"";const a=/BloomPlayerMinVersion":"(.*?)".*?"FeatureId":"(.*?)"/g;let i,r=null,s=null;for(;(i=a.exec(n))!==null;){const h=i[1];(!r||dy(h,r)>0)&&(r=h,s=i[2])}if(!r||!s)return"";const u=Yk();if(dy(u,r)>=0)return"";if(window.location.hostname.toLowerCase().indexOf("bloomlibrary.org")>=0)return He.getTranslation("Version.Problem.Web",this.props.preferredUiLanguages,"This book uses the feature {feature}. Unfortunately, {hostname} is not ready to display this book yet. Please check back again later or write to issues@bloomlibrary.org if you think this is unexpected.").replace("{feature}",s).replace("{hostname}",window.location.hostname);{let h=ga("host","");switch(h){case"bloomreader":h="Bloom Reader";break;case"bloompubviewer":h="BloomPUB Viewer";break;case"readerapp":h="";break}return h?He.getTranslation("Version.Problem.Host",this.props.preferredUiLanguages,"This book uses the feature {feature} and requires a newer version of {host} to read it. Please upgrade to the latest version.").replace("{feature}",s).replace("{host}",h):He.getTranslation("Version.Problem.NoHost",this.props.preferredUiLanguages,"This book uses the feature {feature} and requires a newer version of the program you are using to read it. Please upgrade to the latest version.").replace("{feature}",s)}}componentDidUpdate(e,n){var a;try{if(!this.props.url||this.state.loadFailed)return;this.initializeMedia();const i=this.preprocessUrl();if(i&&i!=="/working"&&i!==this.sourceUrl){this.finishUpCalled=!1,this.setState({isLoading:!0,loadFailed:!1}),this.metaDataObject=void 0,this.htmlElement=void 0,this.sourceUrl=i;const r=this.sourceUrl.lastIndexOf("/"),s=this.sourceUrl.lastIndexOf("%2f");let u;r>s?u=this.sourceUrl.substring(r+1,this.sourceUrl.length):u=this.sourceUrl.substring(s+3,this.sourceUrl.length);const c=u.endsWith(".htm"),h=c?this.sourceUrl:this.sourceUrl+"/"+u+".htm";this.urlPrefix=c?this.sourceUrl.substring(0,Math.max(r,s)):this.sourceUrl,this.music.urlPrefix=this.urlPrefix,dC(this.music.urlPrefix);const m=Ja.get(this.fullUrl(".distribution")).then(P=>P,P=>({data:""})),x=Ja.get(h),w=Ja.get(this.fullUrl("meta.json"));Promise.all([x,w,m]).then(P=>{const[E,z,A]=P;this.metaDataObject=z==null?void 0:z.data,this.distributionSource=A.data;const S=new DOMParser().parseFromString(E==null?void 0:E.data,"text/html"),N=S.documentElement,L=this.getRequiredVersionMessage(S);this.setState({requiredVersion:L});const j=N.getElementsByTagName("body")[0];this.mustUseOriginalPageSize=this.computeMustUseOriginalPageSize(j),this.bookInfo.setSomeBookInfoFromBody(j),this.localizeOnce(),this.props.shouldReportSoundLog&&(this.videoList=this.getVideoList(S)),this.animation.PlayAnimations=this.bookInfo.playAnimations,this.collectBodyAttributes(j),this.makeNonEditable(j),this.htmlElement=N;const f=N.getElementsByClassName("bloom-page")[0];this.originalPageClass="Device16x9Portrait",f&&(this.originalPageClass=Se.getPageSizeClass(f)),this.legacyQuestionHandler.generateQuizPagesFromLegacyJSON(this.urlPrefix,j,this.originalPageClass,()=>{this.finishUp()})}).catch(P=>this.HandleLoadingError(P))}else if(e.landscape!==this.props.landscape||e.useOriginalPageSize!==this.props.useOriginalPageSize||e.autoplay!==this.props.autoplay){const r=document.getElementsByClassName("bloom-page");for(let s=0;s<r.length;s++){const u=r[s];this.setPageSizeClass(u)}}!this.state.isLoading&&(n.isLoading||e.activeLanguageCode!==this.props.activeLanguageCode)&&(this.updateDivVisibilityByLangCode(n.isLoading),this.updateOverlayPositionsByLangCode(),this.finishUpCalled&&this.finishUp(!1)),this.state.currentSwiperIndex!=n.currentSwiperIndex&&((a=this.rootDiv)==null||a.querySelectorAll(_p).forEach(r=>{const s=zs(r).getNiceScroll();s&&s.length>0&&s.remove()})),!this.state.isLoading&&(n.isLoading||e.shouldReadImageDescriptions!==this.props.shouldReadImageDescriptions)&&this.finishUpCalled&&(this.setIndex(this.state.currentSwiperIndex),this.showingPage(this.state.currentSwiperIndex)),this.state.isFinishUpForNewBookComplete&&e.landscape!==this.props.landscape&&(this.setIndex(this.state.currentSwiperIndex),this.showingPage(this.state.currentSwiperIndex)),e.paused!==this.props.paused&&this.handlePausePlay(),this.swiperInstance&&this.swiperInstance.lazy.load()}catch(i){this.setState({isLoading:!1,loadFailed:!0,loadErrorHtml:i.message})}}collectBodyAttributes(e){for(var n={},a=0;a<e.attributes.length;a++)n[e.attributes.item(a).nodeName]=e.attributes.item(a).nodeValue;this.setState({importedBodyAttributes:n})}HandleLoadingError(e){let a=`<p>There was a problem displaying this book: ${e.message}<p>`;(e.config&&e.config.url&&e.config.url.startsWith("file://")||e.message.indexOf("404")>=0)&&(a="<p>This book (or some part of it) was not found.<p>",e.config&&e.config.url&&(a+=`<p class='errorDetails'>${oD(e.config.url)}</p>`)),this.setState({isLoading:!1,loadFailed:!0,loadErrorHtml:a})}async finishUp(e=!0){if(this.finishUpCalled=!0,!this.htmlElement)return;Uo.setAllVideoPostersTo1x1TransparentPNG(this.htmlElement);const n=this.htmlElement.getElementsByClassName("bloom-page"),a=[];e&&(this.bookInfo.totalNumberedPages=0,this.bookInfo.questionCount=0,this.activityManager.collectActivityContextForBook(n),this.bookInteraction.clearPagesShown(),this.music.processAllMusicForBook(n));const i=this.bookInfo.getPreferredTranslationLanguages(),r=i[0]===this.props.activeLanguageCode||!this.props.activeLanguageCode,s={},u=h=>h.classList.contains("bloom-interactive-page")||h.classList.contains("simple-comprehension-quiz")||h.getAttribute("data-activity")=="iframe"||h.getElementsByClassName("questions").length>0;s.length=0,s.cover=0;for(let h=0;h<n.length;h++){const m=n[h],x=m.getAttribute("id");x&&(s[x]=h);const w=this.setPageSizeClass(m);m.setAttribute("data-index",h.toString(10)),h===0&&this.props.reportBookProperties&&this.props.reportBookProperties({landscape:w,canRotate:this.bookInfo.canRotate,preferredLanguages:i,pageNumbers:Array.from(n).map(E=>E.getAttribute("data-page-number")??""),isRtl:this.metaDataObject.isRtl,internalUrl:this.state.bookUrl}),e&&(this.fixRelativeUrls(m),m.classList.contains("numberedPage")&&(this.indexOflastNumberedPage=h,this.bookInfo.totalNumberedPages++),(m.getAttribute("data-analyticscategories")||m.getAttribute("data-analyticsCategories"))==="comprehension"&&this.bookInfo.questionCount++),this.showOrHideL1OnlyText(m,r);const P=u(m);P&&this.activityManager.initializePageHtml(this.urlPrefix,m,a.length),(!this.props.skipActivities||!P)&&a.push(m.outerHTML)}if(e){const h=this.htmlElement.getElementsByTagName("head")[0];this.bookInfo.setSomeBookInfoFromHead(h);const m=this.htmlElement.getElementsByTagName("body")[0];if(this.metaDataObject&&(this.bookInfo.setSomeBookInfoFromMetadata(this.metaDataObject,m),this.reportBookOpened(m)),this.props.controlsCallback){const x=hs.createLangDataArrayFromDomAndMetadata(m,this.metaDataObject);this.hasImageDescriptions=sD(m),this.props.controlsCallback(x,this.hasImageDescriptions,w=>{var P;(P=this.swiperInstance)==null||P.slideTo(w)})}}if(e){var c;try{c=await NB(this.htmlElement,this.urlPrefix,this.bookInfo,()=>this.legacyQuestionHandler.getPromiseForAnyQuizCss())}catch(h){this.HandleLoadingError(h),c=""}if(this.startingUpSwiper=!0,this.state.startPageId){if(s[this.state.startPageId]===void 0)throw new Error(`Page ID ${this.state.startPageId} not found in the current pageIdToIndexMap`);this.setState({startPageIndex:s[this.state.startPageId]})}this.setState({pages:a,pageIdToIndexMap:s,styleRules:c,isLoading:!1,currentSwiperIndex:this.state.startPageIndex??0})}else this.setState({pages:a,isLoading:!1});this.props.pageStylesAreNowInstalled(),e?window.setTimeout(()=>{this.setState({isFinishUpForNewBookComplete:!0});const h=this.startingUpSwiper;this.startingUpSwiper=!1;var m=this.state.startPageIndex??0;this.setIndex(m),this.showingPage(m),h&&this.addScrollbarsToPageWhenReady(this.swiperInstance.activeIndex);const x=document.getElementsByClassName("swiper-button-next")[0],w=document.getElementsByClassName("swiper-button-prev")[0];w==null||w.setAttribute("tabindex","4"),x==null||x.setAttribute("tabindex","5"),x==null||x.focus()},500):Se.currentPage&&window.setTimeout(()=>{this.setIndex(Se.currentPageIndex),this.showingPage(Se.currentPageIndex)},200)}showOrHideL1OnlyText(e,n){e.querySelectorAll(".coverBottomBookTopic, .coverBottomLangName").forEach(a=>{n||a.classList.contains("bloom-content1")?a.classList.remove("do-not-display"):a.classList.add("do-not-display")})}localizeOnce(){!this.isPagesLocalized&&this.state.pages!==this.initialPages&&this.state.styleRules!==this.initialStyleRules&&(He.localizePages(document.body,this.bookInfo.getPreferredTranslationLanguages()),this.isPagesLocalized=!0)}initializeMedia(){this.video||(this.video=new Uo,this.video.PageVideoComplete=new Ur,this.video.PageVideoComplete.subscribe(this.handlePageVideoComplete)),this.animation||(this.animation=new jl),ta.subscribe(this.handlePageNarrationComplete),Pr.subscribe(this.handlePlayFailed),Ya.subscribe(this.handlePlayCompleted),lC(this.storeAudioAnalytics.bind(this)),Ma.subscribe(this.handleToggleImageDescription.bind(this)),uC(()=>{var e;return(e=this.swiperInstance)==null?void 0:e.animating}),cC(e=>Gy(e,1)),this.music||(this.music=new YC,this.music.PlayFailed=new Ur,this.music.PlayFailed.subscribe(()=>{this.setState({inPauseForced:!0}),this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!0)}))}preprocessUrl(){let e=this.state.bookUrl;if(e===void 0||e.trim()==="")throw new Error("The url parameter was empty. It should point to the url of a book.");return e.endsWith("/")&&(e=e.substring(0,e.length-1)),e.endsWith("%2f")&&(e=e.substring(0,e.length-3)),e}handlePausePlay(){this.props.paused?this.pauseAllMultimedia():Se.currentPage!==Dy()||yn===Ge.MediaFinished?this.resetForNewPageAndPlay(Se.currentPage):yn===Ge.VideoPaused?this.video.play():(RC(),this.animation.resumeAnimation(),this.music.play())}getAllBloomCanvasElementsOnPage(){var a,i;const e=(a=this.htmlElement)==null?void 0:a.ownerDocument.getElementsByClassName("bloom-canvas");if(e&&e.length>0)return Array.from(e);const n=(i=this.htmlElement)==null?void 0:i.ownerDocument.getElementsByClassName("bloom-imageContainer");return n?Array.from(n).filter(r=>r.parentElement.closest(".bloom-imageContainer")===null):[]}computeMustUseOriginalPageSize(e){return this.props.useOriginalPageSize||e.querySelector(".bloom-canvas-element")?!0:!!e.querySelector(".bloom-textOverPicture")}updateOverlayPositionsByLangCode(){if(!(!this.props.activeLanguageCode||!this.htmlElement))try{const e=this.props.activeLanguageCode;this.getAllBloomCanvasElementsOnPage().forEach(n=>{Array.from(n.querySelectorAll(Ls)).forEach(i=>{const r=Array.from(i.getElementsByClassName("bloom-editable")).find(s=>s.getAttribute("lang")===e);if(r){const s=r.getAttribute("data-bubble-alternate");if(s){const u=JSON.parse(s.replace(/`/g,'"'));i.setAttribute("style",u.style)}}});const a=Array.from(n.getElementsByClassName("comical-alternate")).find(i=>i.getAttribute("data-lang")===e);if(a){const i=n.getElementsByClassName("comical-generated")[0];i&&(i.classList.remove("comical-generated"),i.classList.add("comical-alternate"),i.style.display="none"),a.classList.remove("comical-alternate"),a.classList.add("comical-generated"),a.style.removeProperty("display")}})}catch(e){console.error(e)}}updateDivVisibilityByLangCode(e){if(!this.props.activeLanguageCode||!this.htmlElement)return;const a=this.bookInfo.getPreferredTranslationLanguages()[0]===this.props.activeLanguageCode||!this.props.activeLanguageCode,i=this.props.activeLanguageCode,r=this.htmlElement.ownerDocument.evaluate(".//div[contains(@class, 'bloom-translationGroup')]",this.htmlElement,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),s="bloom-visibility-code-on";for(let u=0;u<r.snapshotLength;u++){const c=r.snapshotItem(u),h=c.getAttribute("data-default-languages"),m=h?h.split(/,| /):[],x=m==null||m.length===0||!m[0]||m.includes("V")||m.includes("L1")||Se.areStringsEqualInvariantCultureIgnoreCase(m[0],"auto"),w=c.childNodes;for(let P=0;P<w.length;P++){const E=w.item(P);!E||!E.classList||!E.classList.contains("bloom-editable")||(e&&E.setAttribute("data-original-class",E.getAttribute("class")||""),a?E.setAttribute("class",E.getAttribute("data-original-class")||""):x&&(E.getAttribute("lang")===i?(E.classList.add(s),Array.from(E.classList).forEach(A=>{A.startsWith("bloom-content")&&E.classList.remove(A)}),E.classList.add("bloom-content1"),E.classList.add("bloom-contentFirst")):E.classList.remove(s)))}}}static areStringsEqualInvariantCultureIgnoreCase(e,n){return e.localeCompare(n,"en-US",{sensitivity:"accent"})===0}static isDivInL2(e){return e.classList.contains("bloom-contentNational1")}static isDivInL3(e){return e.classList.contains("bloom-contentNational2")}componentWillUnmount(){this.pauseAllMultimedia(),document.removeEventListener("keydown",e=>this.handleDocumentLevelKeyDown(e)),this.unsubscribeAllEvents()}unsubscribeAllEvents(){this.video.PageVideoComplete.unsubscribe(this.handlePageVideoComplete),ta.unsubscribe(this.handlePageNarrationComplete),Pr.unsubscribe(this.handlePlayFailed),Ya.unsubscribe(this.handlePlayCompleted),Ma.unsubscribe(this.handleToggleImageDescription)}pauseAllMultimedia(){yn===Ge.VideoPlaying?this.video.pause():yn===Ge.AudioPlaying&&(OC(),this.animation.PauseAnimation()),this.music.pause()}reportBookOpened(e){const n=this.bookInfo.getAmbientAnalyticsProps();this.distributionSource&&(n.distributionSource=this.distributionSource),zT(n),Xy("BookOrShelf opened",{})}sendUpdateOfBookProgressReportToExternalContext(){const e=this.bookInteraction.getProgressReportPropertiesForAnalytics();IT("Pages Read",e)}makeNonEditable(e){const n=e.ownerDocument.evaluate(".//*[@contenteditable]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(let a=0;a<n.snapshotLength;a++)n.snapshotItem(a).removeAttribute("contenteditable")}setPageSizeClass(e){return Se.setPageSizeClass(e,this.bookInfo.canRotate,this.props.landscape,this.mustUseOriginalPageSize,this.originalPageClass)}static getPageSizeClass(e){const a=(e.getAttribute("class")||"").match(/\b\S*?(Portrait|Landscape)\b/);return a&&a.length?a[0]:""}static setPageSizeClass(e,n,a,i,r){let s=!1;const u=this.getPageSizeClass(e);if(u){s=n?a:u.endsWith("Landscape");let c="";i?c=s?r.replace("Portrait","Landscape"):r.replace("Landscape","Portrait"):c=s?"Device16x9Landscape":"Device16x9Portrait",u!==c&&(e.classList.remove(u),e.classList.add(c))}return s}goToFirstPage(){this.swiperInstance.slideTo(0)}goToLastPage(){this.swiperInstance.slideTo(99999)}fixRelativeUrls(e){const n=e.ownerDocument.evaluate(".//*[@src]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(let r=0;r<n.snapshotLength;r++){const s=n.snapshotItem(r);if(!s)continue;const u=s.getAttribute("src"),c=this.fullUrl(u);s.setAttribute("src",c)}const a=e.ownerDocument.evaluate(".//*[@style]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),i=new RegExp(/background-image:url\(['"](.*)['"]\)/);for(let r=0;r<a.snapshotLength;r++){const s=a.snapshotItem(r);if(!s)continue;const u=s.getAttribute("style")||"",c=i.exec(u);if(!c)continue;const h=this.fullUrl(c[1]),m=u.replace(i,"");s.setAttribute("style",m),s.setAttribute("data-background",h),s.classList.add("swiper-lazy")}}fullUrl(e){return this.urlPrefix+"/"+e}getRootDiv(){return this.rootDiv}slideNext(){this.swiperInstance&&this.swiperInstance.slideNext()}slidePrevious(){this.swiperInstance&&this.swiperInstance.slidePrev()}getPlayerOptionsForPage(e){if(!e)return;let n=e.getAttribute("data-player-options");if(n)try{return n=n.replace(/'/g,'"'),JSON.parse(n)}catch(a){console.log("getPlayerOptionsForPage failed to parse json: "+n+" with error "+a.message);return}}render(){var i;const e=this.activityManager.getActivityAbsorbsDragging();if(this.state.isLoading)return B.createElement(Tz,{className:"loadingSpinner",color:"secondary"});if(this.state.loadFailed)return B.createElement(B.Fragment,null,B.createElement(fk,{className:"loadFailedIcon",color:"secondary"}),B.createElement("div",{className:"loadErrorMessage",dangerouslySetInnerHTML:{__html:this.state.loadErrorHtml}}));if(this.state.requiredVersion)return B.createElement("div",{className:"requiredVersionMessage"},this.state.requiredVersion);vC(this.props.shouldReadImageDescriptions&&this.hasImageDescriptions);const n={getSwiper:r=>{var s,u;this.swiperInstance=r,(s=this.metaDataObject)!=null&&s.isRtl&&this.swiperInstance&&((u=this.swiperInstance.el)==null||u.setAttribute("dir","rtl"),this.swiperInstance.rtl=!0,this.swiperInstance.rtlTranslate=!0)},simulateTouch:!0,touchStartPreventDefault:!1,on:{slideChange:()=>{this.state.inPauseForced&&this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!1),this.setState({inPauseForced:!1}),this.startingUpSwiper||this.showingPage(this.swiperInstance.activeIndex)},slideChangeTransitionStart:()=>{this.startingUpSwiper||this.setIndex(this.swiperInstance.activeIndex)},slideChangeTransitionEnd:()=>{this.addScrollbarsToPageWhenReady(this.swiperInstance.activeIndex)}},keyboard:{enabled:!0,onlyInViewport:!1},preloadImages:!1,lazy:{loadPrevNext:!0,loadOnTransitionStart:!0,loadPrevNextAmount:2},shouldSwiperUpdate:!0};this.startingUpSwiper&&(n.activeSlideKey=(i=this.state.startPageIndex)==null?void 0:i.toString());let a="bloomPlayer";return this.currentPageHidesNavigationButtons?a+=" hideNextPrevButtons extraScalingForChrome85Bug":(this.props.outsideButtonPageClass&&(a+=" "+this.props.outsideButtonPageClass),e&&(a+=" showNavigationButtonsEvenOnTouchDevices")),B.createElement("div",{"aria-label":"Player Content",className:a+(this.props.extraClassNames?" "+this.props.extraClassNames:""),ref:r=>this.rootDiv=r},B.createElement(rC,{key:this.shouldAutoPlay()?"fade":"slide",...n,effect:this.shouldAutoPlay()?"fade":"slide"},this.state.pages.map((r,s)=>{const c=Math.abs(s-this.state.currentSwiperIndex)<2||this.indicesOfPagesWhereWeShouldPreserveDOMState[s];return B.createElement("div",{key:s,className:"page-preview-slide",onClick:h=>this.handlePageClick(h)},c?B.createElement(B.Fragment,null,B.createElement("style",{scoped:!0},this.state.styleRules),B.createElement("div",{...this.state.importedBodyAttributes,className:`bloomPlayer-page ${this.bookInfo.hasAppearanceSystem?"appearance-system":""} ${this.state.importedBodyAttributes.class??""}`,dangerouslySetInnerHTML:{__html:r}})):"")})),B.createElement("div",{className:"swiper-button-prev "+(this.metaDataObject.isRtl?"swiper-button-right":"swiper-button-left")+(this.props.hideSwiperButtons||this.state.currentSwiperIndex===0?" swiper-button-disabled":""),onClick:()=>this.slidePrevious(),onTouchStart:r=>{this.setState({ignorePhonyClick:!0})}},B.createElement(Ta,{className:"nav-button",disableRipple:!0},this.metaDataObject.isRtl?B.createElement(ih,{titleAccess:He.getTranslation("Button.Prev",this.props.preferredUiLanguages,"Previous Page")}):B.createElement(ah,{titleAccess:He.getTranslation("Button.Prev",this.props.preferredUiLanguages,"Previous Page")}))),B.createElement("div",{className:"swiper-button-next "+(this.metaDataObject.isRtl?"swiper-button-left":"swiper-button-right")+(this.props.hideSwiperButtons||this.state.currentSwiperIndex>=this.state.pages.length-1?" swiper-button-disabled":""),onClick:()=>this.slideNext(),onTouchStart:r=>{this.setState({ignorePhonyClick:!0})}},B.createElement(Ta,{className:"nav-button",disableRipple:!0},this.metaDataObject.isRtl?B.createElement(ah,{titleAccess:He.getTranslation("Button.Next",this.props.preferredUiLanguages,"Next Page")}):B.createElement(ih,{titleAccess:He.getTranslation("Button.Next",this.props.preferredUiLanguages,"Next Page")}))))}shouldAutoPlay(){var e=this.bookInfo.autoAdvance&&this.props.landscape;return this.props.autoplay==="yes"?e=!0:this.props.autoplay==="no"&&(e=!1),e&&!this.skipAutoPlay}setIndex(e){if(this.state.isLoading||this.startingUpSwiper)return;this.setState({currentSwiperIndex:e});const n=this.getPageAtSwiperIndex(e);n&&(this.setPageSizeClass(n),this.animation.HandlePageBeforeVisible(n),this.video.hidingPage(),this.video.HandlePageBeforeVisible(n),$C(),this.music.hidingPage(),yn===Ge.AudioPaused||yn===Ge.VideoPaused?Mn(Ge.NewPageMediaPaused):(this.skipAutoPlay=!0,AC(),this.skipAutoPlay=!1,Mn(Ge.NewPage)))}getPageAtSwiperIndex(e){if(this.swiperInstance==null)return null;const n=this.swiperInstance.slides[e];return n?n.getElementsByClassName("bloom-page")[0]:null}getPageIdFromIndex(e){const n=this.getPageAtSwiperIndex(e);if(!n)throw new Error("No bloomPage at index "+e);return n.getAttribute("id")}static getCurrentPage(){return Se.currentPage}isXmatterPage(){const e=Se.currentPage;if(!e)return!0;const n=e.getAttribute("class");return!n||n.indexOf("bloom-page")<0||n.indexOf("bloom-backMatter")>=0||n.indexOf("bloom-frontMatter")>=0?!0:e.hasAttribute("data-xmatter-page")}showingPage(e){if(this.state.isLoading||this.startingUpSwiper)return;this.props.pageChanged&&this.props.pageChanged(e);const n=this.getPageAtSwiperIndex(e);if(!n){window.setTimeout(()=>this.showingPage(e),50);return}const a=this.getPlayerOptionsForPage(n);this.currentPageHidesNavigationButtons=!!(a&&a.hideNavigation),this.props.hidingNavigationButtonsCallback&&this.props.hidingNavigationButtonsCallback(this.currentPageHidesNavigationButtons),this.activityManager.showingPage(e,n)&&(this.indicesOfPagesWhereWeShouldPreserveDOMState[e]=!0),window.setTimeout(()=>{Se.currentPage=n,Se.currentPageIndex=e,Se.currentPageHasVideo=Uo.pageHasVideo(n),this.setPageSizeClass(n),this.props.paused?this.animation.shouldAnimate(n)&&(this.animation.HandlePageBeforeVisible(n),this.animation.HandlePageVisible(n),this.animation.HandlePageDurationAvailable(n,Jg(n)),this.animation.PauseOnFirstFrame()):this.resetForNewPageAndPlay(n),this.isXmatterPage()||(this.bookInteraction.pageShown(e),e===this.indexOflastNumberedPage&&(this.bookInteraction.lastNumberedPageWasRead=!0)),this.props.reportPageProperties&&this.props.reportPageProperties({hasAudio:jC(n),hasMusic:this.music.pageHasMusic(n),hasVideo:Se.currentPageHasVideo}),this.bookInteraction.reportedAudioOnCurrentPage=!1,this.bookInteraction.reportedVideoOnCurrentPage=!1,this.sendUpdateOfBookProgressReportToExternalContext(),this.swiperInstance.params.noSwiping=this.activityManager.getActivityAbsorbsDragging(),this.swiperInstance.params.touchRatio=this.activityManager.getActivityAbsorbsDragging()?0:1,this.activityManager.getActivityAbsorbsTyping()?this.swiperInstance.keyboard.disable():this.swiperInstance.keyboard.enable(),Array.from(n.querySelectorAll("[data-sound]")).forEach(r=>{r.addEventListener("click",Hp)})},0)}addScrollbarsToPageWhenReady(e){if(this.state.isLoading||this.startingUpSwiper)return;const n=this.getPageAtSwiperIndex(e);if(!n){window.setTimeout(()=>this.addScrollbarsToPageWhenReady(e),50);return}OL(n,Se.handlePointerMoveEvent)}static handlePointerMoveEvent(e){var n;e.pointerType==="mouse"&&((n=e.target)!=null&&n.closest(".nicescroll-cursors"))&&e.stopPropagation()}storeAudioAnalytics(e){e<.001||Number.isNaN(e)||(this.bookInteraction.totalAudioDuration+=e,!this.isXmatterPage()&&(this.bookInteraction.reportedAudioOnCurrentPage||(this.bookInteraction.reportedAudioOnCurrentPage=!0,this.bookInteraction.audioPageShown(Se.currentPageIndex)),this.sendUpdateOfBookProgressReportToExternalContext()))}static storeVideoAnalytics(e){if(e<.001)return;const n=Se.currentPagePlayer;n.bookInteraction.totalVideoDuration+=e,!n.bookInteraction.reportedVideoOnCurrentPage&&!n.isXmatterPage()&&(n.bookInteraction.reportedVideoOnCurrentPage=!0,n.bookInteraction.videoPageShown(Se.currentPageIndex)),n.sendUpdateOfBookProgressReportToExternalContext()}resetForNewPageAndPlay(e){this.props.paused||(By(e),Se.currentPageHasVideo?(Mn(Ge.VideoPlaying),this.video.HandlePageVisible(e),this.music.pause()):this.playAudioAndAnimation(e))}playAudioAndAnimation(e){if(this.activityManager.getActivityManagesSound()){this.activityManager.doInitialSoundAndAnimation();return}if(Mn(Ge.AudioPlaying),!e)return;const n=Jg(e);this.animation.HandlePageDurationAvailable(e,n);const a=()=>{jl.pageHasAnimation(e)&&this.animation.HandlePageBeforeVisible(e),this.animation.HandlePageVisible(e),jy(e,this.animation.animatableCanvas),this.music.HandlePageVisible(e)};if(!this.sentBloomNotification&&(this.sentBloomNotification=!0,this.props.shouldReportSoundLog)){Uy("/publish/av/startRecording",this.videoList).then(a);return}a()}getVideoList(e){let n="";for(const r of Array.from(e.getElementsByTagName("video"))){var a=r,i=a.getElementsByTagName("source")[0].getAttribute("src");n&&(n+="|"),n+=i}return n}handlePageClick(e){if(!this.state.ignorePhonyClick&&(!this.activityManager.getActivityAbsorbsClicking()||e.target.closest("[data-href]")&&e.target.closest(".bloom-canvas"))&&!e.target.closest(".bloom-videoContainer")){const n=IB(e.nativeEvent,this.bookInfo.bookInstanceId,()=>this.getPageIdFromIndex(this.state.currentSwiperIndex));n?(this.navigate(n.bookUrl,n.pageId),e.stopPropagation(),e.preventDefault()):this.props.onContentClick&&this.props.onContentClick(e)}this.setState({ignorePhonyClick:!1})}}function oD(t){return t.replace("%23","#").replace(/[\u00A0-\u9999<>\&]/gim,e=>"&#"+e.charCodeAt(0)+";")}function sD(t){return t.ownerDocument.evaluate("//div[contains(@class, 'bloom-imageDescription')]/div[contains(@class, 'bloom-editable') and contains(@class, 'bloom-visibility-code-on')]//*[contains(@class, 'audio-sentence') or contains(@class, 'bloom-highlightSegment')]",t,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength>0?!0:t.ownerDocument.evaluate("//div[contains(@class, 'bloom-imageDescription')]/div[contains(@class, 'bloom-editable') and contains(@class, 'bloom-visibility-code-on') and @data-audiorecordingmode='TextBox']/p[text()]",t,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength>0}var Vp={},lD=ba,uD=wa;Object.defineProperty(Vp,"__esModule",{value:!0});var Xk=Vp.default=void 0,cD=uD(Ln()),dD=lD(ka()),fD=(0,dD.default)(cD.createElement("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"}),"ArrowBack");Xk=Vp.default=fD;var Gp={},hD=ba,pD=wa;Object.defineProperty(Gp,"__esModule",{value:!0});var Zk=Gp.default=void 0,gD=pD(Ln()),mD=hD(ka()),vD=(0,mD.default)(gD.createElement("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"}),"MoreHoriz");Zk=Gp.default=vD;var Up={},yD=ba,bD=wa;Object.defineProperty(Up,"__esModule",{value:!0});var Yp=Up.default=void 0,wD=bD(Ln()),kD=yD(ka()),xD=(0,kD.default)(wD.createElement("path",{d:"M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"}),"PlayCircleOutline");Yp=Up.default=xD;var Xp={},SD=ba,CD=wa;Object.defineProperty(Xp,"__esModule",{value:!0});var Jk=Xp.default=void 0,TD=CD(Ln()),ED=SD(ka()),PD=(0,ED.default)(TD.createElement("path",{d:"M9 16h2V8H9v8zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm1-4h2V8h-2v8z"}),"PauseCircleOutline");Jk=Xp.default=PD;var Zp={},MD=ba,AD=wa;Object.defineProperty(Zp,"__esModule",{value:!0});var Qk=Zp.default=void 0,ND=AD(Ln()),LD=MD(ka()),zD=(0,LD.default)(ND.createElement("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"}),"Language");Qk=Zp.default=zD;var Jp={},BD=ba,DD=wa;Object.defineProperty(Jp,"__esModule",{value:!0});var t0=Jp.default=void 0,ID=DD(Ln()),jD=BD(ka()),RD=(0,jD.default)(ID.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"}),"Fullscreen");t0=Jp.default=RD;var Qp={},OD=ba,KD=wa;Object.defineProperty(Qp,"__esModule",{value:!0});var e0=Qp.default=void 0,$D=KD(Ln()),qD=OD(ka()),HD=(0,qD.default)($D.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}),"FullscreenExit");e0=Qp.default=HD;function FD(t){return kt.createElement(nh,{...t,width:"21",height:"20",viewBox:"0 0 21 20"},kt.createElement("path",{d:"M20.6181 9.909C20.6181 9.909 17.3581 3.70568 10.2454 3.70568C10.1127 3.70568 9.9821 3.70851 9.8522 3.71275L9.23133 0.590958L8.27889 0.807585L8.87136 3.78574C2.72807 4.50344 0 9.86355 0 9.86355C0 9.86355 0.566707 11.0581 1.77366 12.4165L1.27674 9.91983C1.26639 9.90052 1.26089 9.89016 1.26089 9.89016C1.26089 9.89016 1.45882 9.53343 1.86833 9.01188L2.73952 13.3918C3.09729 13.7179 3.49205 14.0383 3.92423 14.3419L2.68074 8.09074C2.92754 7.84068 3.20826 7.58049 3.52199 7.32171L5.05787 15.0424C5.40441 15.2277 5.77033 15.3993 6.15474 15.5514L4.38901 6.67725C4.6772 6.48487 4.98565 6.29932 5.31568 6.12485L7.26481 15.9206C7.59924 16.0118 7.94578 16.0871 8.30509 16.146L7.56314 12.4167C7.89823 12.8518 8.32205 13.2046 8.80465 13.4464L9.36563 16.2656C9.59813 16.2802 9.83459 16.2891 10.0765 16.2891C10.1734 16.2891 10.2694 16.2873 10.3654 16.2844L9.86541 13.773C10.0112 13.7923 10.1591 13.8033 10.3099 13.8033C10.4957 13.8033 10.6783 13.7883 10.8559 13.7588L11.9801 19.4091L12.9321 19.1924L12.3108 16.0683C17.848 14.9378 20.6181 9.909 20.6181 9.909ZM6.88084 8.9881L6.22651 5.69889C6.53386 5.57339 6.8575 5.45942 7.19546 5.35982L7.6228 7.50844C7.28066 7.93015 7.02351 8.43381 6.88084 8.9881ZM8.46692 6.74577L8.14503 5.12836C8.45547 5.06785 8.77691 5.01958 9.11002 4.9859L9.3773 6.32923C9.05322 6.42294 8.74741 6.56375 8.46692 6.74577ZM10.3467 6.19713L10.0944 4.93033C10.1472 4.92963 10.1998 4.92845 10.2533 4.92845C10.4858 4.92845 10.713 4.93599 10.9365 4.94941C13.2188 5.33628 14.964 7.44981 14.964 9.99965C14.964 12.1188 13.7579 13.9352 12.0406 14.7106L11.7914 13.4565C13.0153 12.8558 13.8654 11.5342 13.8654 9.99942C13.8652 7.91226 12.2936 6.21856 10.3467 6.19713ZM14.5336 14.0984C15.4349 13.0056 15.9823 11.5718 15.9823 9.99942C15.9823 8.35399 15.3821 6.8595 14.405 5.74928C17.7771 7.16772 19.3574 9.92642 19.3574 9.92642C19.3574 9.92642 17.7491 12.6074 14.5336 14.0984Z"}))}var tg={},WD=ba,_D=wa;Object.defineProperty(tg,"__esModule",{value:!0});var n0=tg.default=void 0,VD=_D(Ln()),GD=WD(ka()),UD=(0,GD.default)(VD.createElement("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"}),"VolumeUp");n0=tg.default=UD;const YD=t=>{const[e,n]=B.useState((t.languages.filter(s=>s.IsSelected)[0]||t.languages[0]).Code),a=s=>{const u=s.target.value;n(u),t.onClose(u)},i=()=>{t.onClose("")},r=()=>{const s=t.languages.map(u=>kt.createElement("div",{className:"chooserItem",key:u.Code},kt.createElement(aB,{value:u.Code,control:kt.createElement(mB,null),label:u.Name,checked:u.Code===e}),kt.createElement("span",{className:"spacer"}),kt.createElement(n0,{className:"icon",visibility:u.HasAudio?"inherit":"hidden"})));return kt.createElement("div",{className:"radioGroupDiv"},s)};return kt.createElement(Fz,{className:"languageMenu",onClose:i,"aria-labelledby":"language-menu-title",open:!0,scroll:"paper"},kt.createElement(Yz,{id:"language-menu-title"},"Languages in this book:"),kt.createElement(tB,{component:"fieldset"},kt.createElement(vB,{className:"radioGroup","aria-label":"languages",name:"languages",value:e,onChange:a},r())),kt.createElement(Vz,null,kt.createElement(bz,{onClick:i,color:"secondary"},"Close")))};var _o=(t=>(t[t.showArrow=0]="showArrow",t[t.showEllipsis=1]="showEllipsis",t[t.showNothing=2]="showNothing",t))(_o||{});const XD=t=>{const[e,n]=B.useState(!1),a="button"+(t.bookLanguages.length<2?" disabled":""),i=E=>{n(!1),E!==""&&(t.onLanguageChanged(E),s({lang:E}))},r=()=>{try{document.fullscreenElement!=null||document.webkitFullscreenElement!=null?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullScreen&&document.webkitExitFullScreen():document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.webkitRequestFullscreen&&document.documentElement.webkitRequestFullscreen()}catch(E){console.error("RequestFullScreen failed: ",E)}},s=E=>{if(!t.videoPreviewMode)return;const z={lang:t.activeLanguageCode,imageDescriptions:t.readImageDescriptions,...E};Uy("publish/av/videoSettings",encodeURIComponent(JSON.stringify(z)))},u=He.getTranslation("Audio.Pause",t.preferredLanguages,"Pause"),c=t.paused?kt.createElement(Yp,{titleAccess:t.playLabel}):kt.createElement(Jk,{titleAccess:u}),h=He.getTranslation("Button.ReadImageDescriptions",t.preferredLanguages,"Read Image Descriptions"),m=He.getTranslation("Button.IgnoreImageDescriptions",t.preferredLanguages,"Ignore Image Descriptions"),x=gs({palette:{primary:{main:eD},secondary:{main:Uk.palette.secondary.main}}}),w=kt.createElement(Vl,{theme:x},kt.createElement(FD,{"aria-label":t.readImageDescriptions?"Read image descriptions":"Ignore image descriptions",titleAccess:t.readImageDescriptions?m:h,opacity:t.readImageDescriptions?1:.38,color:t.nowReadingImageDescription?"primary":"secondary"})),P=t.extraButtons?t.extraButtons.map(E=>kt.createElement(Ta,{key:E.id,color:"secondary",title:E.description,onClick:()=>ja({messageType:E.id})},kt.createElement("img",{style:{maxHeight:"24px",maxWidth:"24px"},src:E.iconUrl}))):void 0;return kt.createElement(uz,{color:"primary",className:`control-bar ${t.visible?", visible":""}`,id:"control-bar",elevation:0,position:"relative"},kt.createElement(MB,null,!t.videoPreviewMode&&kt.createElement(Ta,{color:"secondary",onClick:()=>{t.backClicked&&t.backClicked()},"data-testid":"history-back-button",disabled:t.getBackButtonState()===2},t.getBackButtonState()===0?kt.createElement(Xk,{"aria-label":"Go Back",titleAccess:He.getTranslation("Button.Back",t.preferredLanguages,"Back")}):t.getBackButtonState()===1&&kt.createElement(Zk,{"aria-label":"More Menu",titleAccess:He.getTranslation("Button.More",t.preferredLanguages,"More")})),kt.createElement("div",{className:"filler"}),t.bookHasImageDescriptions&&kt.createElement(Ta,{onClick:()=>{t.onReadImageDescriptionToggled(),s({imageDescriptions:!t.readImageDescriptions})}},w),t.bookLanguages.length>1&&kt.createElement(Ta,{className:a,"aria-label":"Choose Language",color:"secondary",onClick:()=>{n(!0)}},kt.createElement(Qk,{titleAccess:He.getTranslation("Button.ChooseLanguage",t.preferredLanguages,"Choose Language")})),e&&kt.createElement(YD,{languages:t.bookLanguages,onClose:i}),!t.videoPreviewMode&&kt.createElement(Ta,{color:"secondary","aria-label":"PlayPause",onClick:()=>{t.pausedChanged&&t.pausedChanged(!t.paused)}},t.showPlayPause?c:null),P,document.fullscreenEnabled&&t.canShowFullScreen&&!t.videoPreviewMode&&kt.createElement(Ta,{color:"secondary",onClick:()=>r()},document.fullscreenElement==null?kt.createElement(t0,{"aria-label":"Full Screen",titleAccess:He.getTranslation("Button.FullScreen",t.preferredLanguages,"Full Screen")}):kt.createElement(e0,{"aria-label":"Exit Full Screen",titleAccess:He.getTranslation("Button.ExitFullScreen",t.preferredLanguages,"Exit Full Screen")}))))};function _d(t,e){return Math.round(t/e)*e}function ZD(t){if(!(!t||t==="cover")){if(/^\d+$/.test(t))return t;try{return t.replace(new RegExp("(?![0-9])\\p{Nd}","gu"),e=>{const n=e.charCodeAt(0);return(n&15)-6*(new RegExp("\\p{Nd}","u").test(String.fromCodePoint(n|15))?1:0)})}catch{return}}}let Vd=!1,dh=t=>{};function JD(t){dh&&dh(t)}let fy=0,hy=0;function py(){const t=/iPad|iPhone|iPod/.test(navigator.platform);let e,n,a;t&&(e=document.getElementsByClassName("bloomPlayer")[0],n=e.parentElement,a=e.nextSibling,n.removeChild(e));const i=document.documentElement.clientWidth,r=document.documentElement.clientHeight;return t&&n.insertBefore(e,a),{width:i,height:r}}const QD=t=>{const[e,n]=B.useState(t.autoplay),a=t.centerVertically===void 0?!0:t.centerVertically;$T(ht=>{ht.pause?(Vd=!L,j(!0)):ht.resume&&Vd?j(!1):ht.play?(j(!1),ht.autoplay&&n(ht.autoplay)):ht.reset?(h(t.startPage??0),Ue.current&&Ue.current(t.startPage??0)):ht.controlAction&&rt(ht.controlAction)});const[i,r]=B.useState(!1),[s,u]=B.useState(t.initiallyShowAppBar),[c,h]=B.useState(t.startPage??0),[m,x]=B.useState([""]),[w,P]=B.useState(!1),[E,z]=B.useState(!1),[A,k]=B.useState(""),[S,N]=B.useState("Device16x9Portrait");B.useEffect(()=>{u(t.initiallyShowAppBar)},[t.initiallyShowAppBar]),B.useEffect(()=>{s?RT():OT()},[s]),B.useEffect(()=>{j(t.paused)},[t.paused]);const[L,j]=B.useState(t.paused),[f,G]=B.useState(!1),V=He.getBloomUiLanguage(),F=V==="en"?[V]:[V,"en"],[pt,ft]=B.useState(F);B.useEffect(()=>{L||(Vd=!1)},[L]);const[ot,Z]=B.useState(!1),[$,o]=B.useState(!1),[tt,v]=B.useState(!1),[Q,st]=B.useState(!1),[ut,I]=B.useState(!1),[lt,gt]=B.useState(0),[Tt,Ct]=B.useState(9/16),jt=[],[Ft,Yt]=B.useState(jt),[Wt,Te]=B.useState(""),Ue=B.useRef(),[hn,ke]=B.useState(!0),[ve,Ye]=B.useState(!1),[Et,xe]=B.useState(!1),[qn,We]=B.useState(0),C=()=>{We(ht=>ht+1)},[D,W]=B.useState("");B.useEffect(()=>{mt()},[ut,qn,ot,t.useOriginalPageSize]),B.useEffect(()=>()=>{const ht=document.getElementById("scale-style-sheet");ht&&ht.parentNode.removeChild(ht)},[]);const X=B.useRef(),rt=ht=>{switch(ht){case"navigate-to-next-page":X&&X.current&&X.current.slideNext();break;case"navigate-to-previous-page":X&&X.current&&X.current.slidePrevious();break;default:console.log("'handleControlMessage' received an unknown message.");return}},mt=()=>{const ht=document.getElementsByClassName("swiper-slide-active")[0];let zt=null;if(ht&&(zt=ht.getElementsByClassName("bloom-page")[0]),!zt||!ut){window.setTimeout(C,100);return}let qe=document.getElementById("scale-style-sheet");qe||(qe=document.createElement("style"),qe.setAttribute("type","text/css"),qe.setAttribute("id","scale-style-sheet"),document.head.appendChild(qe));let pe=lt,Jt=Tt;const ge=Se.getPageSizeClass(zt);(t.url!==A||ge!==S)&&(k(t.url),N(ge),window.onresize=()=>{const{width:ca,height:qa}=py();(qa!==hy||ca!==fy)&&C()},pe=Math.max(zt.offsetHeight,zt.offsetWidth),Jt=Math.min(zt.offsetHeight,zt.offsetWidth)/pe,Ct(Jt),gt(pe));const{width:St,height:Bt}=py();fy=St,hy=Bt;const ee=St>Bt;if(ee!==ot){Z(ee);return}let ye=0,ce=0;const Ze=window.getComputedStyle(document.body);Ze&&Ze.marginTop&&(ye=parseInt(Ze.marginTop,10)),Ze&&Ze.marginBottom&&(ce=parseInt(Ze.marginBottom,10));const ue=zt.getAttribute("class").indexOf("Landscape")>=0,ri=ue?pe*Jt:pe,nn=ue?pe:pe*Jt;let ua=ye+ce;if(s){const ca=document.getElementById("control-bar");ca&&(ua+=ca.offsetHeight);const qa=document.getElementById("pageNumberControl");qa&&(ua+=qa.offsetHeight)}const Ka=Bt-ua,oi=_t({pageWidth:nn,pageHeight:ri,desiredPageHeight:Ka}),mr=re(nn);let Je=Math.min(oi,mr);const Ne=ri*Je;let $a=Ne*Jt/Je;ue&&($a=Ne/Jt/Je);const $i=St/Je-$a;let Tn="",xa=Math.max((St-nn*Je)/2,0);t.roundMarginToNearestK&&(xa=_d(xa,t.roundMarginToNearestK));const uo=xa,co=Je,sc=30;if($i>100*2)Tn="largeOutsideButtons";else if($i>sc*2)Tn="smallOutsideButtons";else if(St>407&&navigator.userAgent.includes("Chrome")&&!t.hideSwiperButtons){const qa=new RegExp(" Chrome/([0-9]+).").exec(navigator.userAgent),vr=parseInt(qa[1]);vr&&vr<90&&(Je*=.9,xa=Math.max((St-nn*Je)/2,0),Tn="smallOutsideButtons extraScalingForChrome85Bug")}Tn!==D&&W(Tn);let fo="";if(a){const ca=(Bt-Ne-ua)/2;ca>0&&(fo=`translate(0, ${ca.toFixed(0)}px) `)}qe.innerText=`.bloomPlayer {
8050
+ `,"").replace("\r","")}const oc=[];function BB(){return oc.length>0}function DB(t){const e=oc.pop();if(e)return{bookUrl:t===e.bookId?void 0:ch(e.bookId),pageId:e.pageId}}function IB(t,e,n){const a=t.target.closest("[href], [data-href]");if(!a)return;t.preventDefault(),t.stopPropagation();const i=(a.getAttribute("href")||a.getAttribute("data-href"))??void 0;if(!i)return;if(i.startsWith("http://")||i.startsWith("https://")){window.open(i,"_blank","noreferrer");return}let r,s;if(i==="back"){const c=oc.pop();return c?{bookUrl:e===c.bookId?void 0:ch(c.bookId),pageId:c.pageId}:void 0}else if(i.startsWith("/book/")){const c=jB(i);r=c.bookId,s=c.pageId,c.bookId===e&&(r=void 0)}else i.startsWith("#")&&(s=i.substring(1));const u=n();if(r)return oy(e,u),{bookUrl:ch(r),pageId:s};if(s)return oy(e,u),{pageId:s}}function oy(t,e,n){oc.push({bookId:t,pageId:e})}function ch(t){return`/book/${t}/index.htm`}function jB(t){try{const e=new URL(t,window.location.origin);if(!e.pathname.startsWith("/book/"))throw new Error("Invalid book URL format");const n=e.pathname.replace("/book/",""),a=e.hash.replace("#","");return{bookId:n,pageId:a}}catch(e){return console.error("Error parsing book URL:",e),{bookId:void 0,pageId:void 0}}}const RB="bloom-player",OB="A library for displaying Bloom books in iframes or WebViews",KB="SIL Global",$B="MIT",qB="2.16.0-alpha.5",HB=!1,FB={type:"git",url:"https://github.com/BloomBooks/bloom-player.git"},WB="module",_B="lib/shared.es.js",VB="lib/index.d.ts",GB={".":{types:"./lib/index.d.ts",import:"./lib/shared.es.js",default:"./lib/shared.es.js"}},UB={"// COMMENTS: make the action a space rather than empty string so `yarn run` can list the scripts":" ","//":" ","// 'yarn dev' will build, watch, start a server, and open the player in a brower":" ","// You can edit index-for-developing.html to point to different books":" ","// Or just use 'yarn storybook' and skip this dev approach entirely":" ",dev:"vite","build:standalone":"vite build","build:sharedlib":"vite build --mode lib",test:"vitest","// blame.ignoreRevsFile - This allows blame to see through commits that are only there to format code.":" ",prepare:"husky install && git config blame.ignoreRevsFile .git-blame-ignore-revs",storybook:"storybook dev -p 6006","// run this when working with stories that use an iframe and bloomplayer.htm instead of the raw react components":" ",watchForStorybook:"yarn vite build --watch --mode development","strings:download":"crowdin download --config src/l10n/crowdin.yml && yarn strings:compile","strings:upload":"crowdin upload --config src/l10n/crowdin.yml","strings:compile":"yarn tsx ./src/l10n/compileL10Strings.ts","strings:sync":"yarn strings:upload && yarn strings:download"},YB={"@material-ui/core":"^4.12.3","@material-ui/icons":"^4.11.2",axios:"^0.18.0","compare-versions":"^6.1.1","dynamic-import-polyfill":"^0.1.1","jquery.nicescroll":"^3.7.6",react:"^17.0.2","react-dom":"^17.0.2","react-id-swiper":"2.3.2","style-scoped":"^0.2.1",swiper:"^4.5.0"},XB={"@crowdin/cli":"^4.2.0","@storybook/addon-essentials":"8.4.6","@storybook/addon-interactions":"^8.4.6","@storybook/addon-links":"8.4.6","@storybook/blocks":"8.4.6","@storybook/react":"8.4.6","@storybook/react-vite":"8.4.6","@storybook/test":"8.4.6","@types/jquery":"^3.5.5","@types/jquery.nicescroll":"^3.7.1","@types/node":"^22.7.6","@types/react":"^17.0.2","@types/react-dom":"^17.0.2",editorconfig:"^2.0.0",eslint:"^9.12.0","eslint-plugin-storybook":"^0.11.1",husky:"8.0.3",jsdom:"^25.0.1",less:"^4.2.0",prettier:"^3.3.3","semantic-release":"24.1.2",storybook:"8.4.6",tsx:"^4.19.1",typescript:"*",vite:"^5.4.9","vite-plugin-dts":"^4.5.3","vite-plugin-html":"^3.2.2","vite-plugin-static-copy":"^2.0.0",vitest:"^2.1.3"},ZB=["dist/*.js","dist/bloomplayer.htm","dist/*.mp3","lib/*.js","lib/*.d.ts","lib/*.js.map","src/shared/event.ts","src/shared/narration.ts","src/shared/dragActivityRuntime.ts","src/shared/scrolling.ts","src/shared/index.ts","dist/*.css","dist/*.tsv"],JB={node:"20.15.1",yarn:"1.22.19"},QB={name:RB,description:OB,author:KB,license:$B,version:qB,private:!1,"// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working":"",sideEffects:HB,repository:FB,type:WB,module:_B,types:VB,exports:GB,scripts:UB,dependencies:YB,devDependencies:XB,"// The four src/ files are directly exported so BloomDesktop can consume them as shared code.":"",files:ZB,volta:JB},gi="#d65649",tD="#2e2e2e",eD="#febf00",Uk=gs({palette:{primary:{main:tD,contrastText:gi},secondary:{main:gi}}});function Yk(){var t=QB.version;return t}const nD=()=>{const[t,e]=B.useState(!1),n=Yk(),a=new Date("2025-10-07T19:02:17.777Z").toLocaleDateString();return B.useEffect(()=>{const i=s=>{s.key==="Control"&&e(!0)},r=s=>{s.key==="Control"&&e(!1)};return window.addEventListener("keydown",i),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",r)}},[]),t?kt.createElement("div",{className:"version-control",style:{color:gi,fontFamily:"sans-serif",padding:"5px",zIndex:1e3}},"Bloom Player v",n," (built ",a,")"):null},aD=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,sy=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");const e=t.match(aD);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},ly=t=>t==="*"||t==="x"||t==="X",uy=t=>{const e=parseInt(t,10);return isNaN(e)?t:e},iD=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],rD=(t,e)=>{if(ly(t)||ly(e))return 0;const[n,a]=iD(uy(t),uy(e));return n>a?1:n<a?-1:0},cy=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){const a=rD(t[n]||"0",e[n]||"0");if(a!==0)return a}return 0},dy=(t,e)=>{const n=sy(t),a=sy(e),i=n.pop(),r=a.pop(),s=cy(n,a);return s!==0?s:i&&r?cy(i.split("."),r.split(".")):i||r?i?-1:1:0};class Se extends B.Component{constructor(e,n){super(e,n),this.activityManager=new ez,this.initialPages=["loading..."],this.initialStyleRules="",this.originalPageClass="Device16x9Portrait",this.bookInfo=new uh,this.bookInteraction=new AB,this.mustUseOriginalPageSize=!1,this.indicesOfPagesWhereWeShouldPreserveDOMState={},this.startingUpSwiper=!0,this.state={pages:this.initialPages,pageIdToIndexMap:{},styleRules:this.initialStyleRules,importedBodyAttributes:{},currentSwiperIndex:0,isLoading:!0,loadFailed:!1,loadErrorHtml:"",ignorePhonyClick:!1,isFinishUpForNewBookComplete:!1,inPauseForced:!1,bookUrl:""},this.isPagesLocalized=!1,this.currentPageHidesNavigationButtons=!1,this.handleDocumentLevelKeyDown=i=>{i.key==="Home"&&(this.goToFirstPage(),i.preventDefault()),i.key==="End"&&(this.goToLastPage(),i.preventDefault())},this.distributionSource="",this.finishUpCalled=!1,this.hasImageDescriptions=!1,this.handlePageVideoComplete=i=>{i.page===Se.currentPage&&this.playAudioAndAnimation(i.page)},this.handlePlayFailed=()=>{this.setState({inPauseForced:!0}),this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!0)},this.handlePlayCompleted=()=>{Mn(Ge.MediaFinished),this.props.imageDescriptionCallback(!1)},this.handleToggleImageDescription=i=>{this.props.imageDescriptionCallback(i)},this.handlePageNarrationComplete=i=>{if(i&&(Mn(Ge.MediaFinished),this.shouldAutoPlay())){const r=this.props.autoplayCount??0,s=this.state.startPageIndex??0,u=this.swiperInstance.slides.length-1;let c=this.props.autoplayCount?Math.min(s+r-1,u):u;this.swiperInstance.activeIndex>=c?(this.music.pause(),this.props.shouldReportSoundLog&&UC(),VC(),DT({})):this.swiperInstance.slideNext()}},this.skipAutoPlay=!1,this.sentBloomNotification=!1;const a=e.url.startsWith("http")?new URL(e.url):new URL(e.url,window.location.origin);a.hash?(this.state.startPageId=a.hash.substring(1),a.hash=""):this.state.startPageIndex=e.startPageIndex,this.state.bookUrl=a.href,Se.currentPagePlayer=this,this.legacyQuestionHandler=new az(e.locationOfDistFolder)}componentDidMount(){He.setUp(),window.addEventListener("focus",()=>this.handleWindowFocus()),window.addEventListener("blur",()=>this.handleWindowBlur()),document.addEventListener("keydown",e=>this.handleDocumentLevelKeyDown(e)),document.addEventListener("pointerdown",e=>{(e.target.closest("[href], [data-href]")||e.target.closest(".bloom-videoContainer")&&!e.target.closest("[data-draggable-id]"))&&(e.stopPropagation(),e.preventDefault())},{capture:!0}),document.addEventListener("dragstart",e=>{this.activityManager.getActivityAbsorbsDragging()||e.preventDefault()},{capture:!0}),this.componentDidUpdate(this.props,this.state)}CanGoBack(){return BB()}HandleBackButtonClickedIfHavePlayerHistory(){const e=DB(this.bookInfo.bookInstanceId);return e?(this.navigate(e.bookUrl,e.pageId),!0):!1}navigate(e,n){if(e){const a=new URL(e,this.state.bookUrl);this.setState({bookUrl:a.href,startPageId:n,startPageIndex:void 0})}else if(n!==void 0){const a=this.state.pageIdToIndexMap[n];this.swiperInstance.slideTo(a)}}handleWindowFocus(){const e=localStorage.getItem(Hl),n=localStorage.getItem(tm);e&&n==this.sourceUrl&&(this.bookInteraction.beginReadTime=Date.now()-parseInt(e,10))}handleWindowBlur(){const e=Date.now()-this.bookInteraction.beginReadTime;localStorage.setItem(Hl,e.toString()),localStorage.setItem(tm,this.sourceUrl)}getRequiredVersionMessage(e){var c;const n=(c=e.querySelector('meta[name="FeatureRequirement"]'))==null?void 0:c.getAttribute("content");if(!n)return"";const a=/BloomPlayerMinVersion":"(.*?)".*?"FeatureId":"(.*?)"/g;let i,r=null,s=null;for(;(i=a.exec(n))!==null;){const h=i[1];(!r||dy(h,r)>0)&&(r=h,s=i[2])}if(!r||!s)return"";const u=Yk();if(dy(u,r)>=0)return"";if(window.location.hostname.toLowerCase().indexOf("bloomlibrary.org")>=0)return He.getTranslation("Version.Problem.Web",this.props.preferredUiLanguages,"This book uses the feature {feature}. Unfortunately, {hostname} is not ready to display this book yet. Please check back again later or write to issues@bloomlibrary.org if you think this is unexpected.").replace("{feature}",s).replace("{hostname}",window.location.hostname);{let h=ga("host","");switch(h){case"bloomreader":h="Bloom Reader";break;case"bloompubviewer":h="BloomPUB Viewer";break;case"readerapp":h="";break}return h?He.getTranslation("Version.Problem.Host",this.props.preferredUiLanguages,"This book uses the feature {feature} and requires a newer version of {host} to read it. Please upgrade to the latest version.").replace("{feature}",s).replace("{host}",h):He.getTranslation("Version.Problem.NoHost",this.props.preferredUiLanguages,"This book uses the feature {feature} and requires a newer version of the program you are using to read it. Please upgrade to the latest version.").replace("{feature}",s)}}componentDidUpdate(e,n){var a;try{if(!this.props.url||this.state.loadFailed)return;this.initializeMedia();const i=this.preprocessUrl();if(i&&i!=="/working"&&i!==this.sourceUrl){this.finishUpCalled=!1,this.setState({isLoading:!0,loadFailed:!1}),this.metaDataObject=void 0,this.htmlElement=void 0,this.sourceUrl=i;const r=this.sourceUrl.lastIndexOf("/"),s=this.sourceUrl.lastIndexOf("%2f");let u;r>s?u=this.sourceUrl.substring(r+1,this.sourceUrl.length):u=this.sourceUrl.substring(s+3,this.sourceUrl.length);const c=u.endsWith(".htm"),h=c?this.sourceUrl:this.sourceUrl+"/"+u+".htm";this.urlPrefix=c?this.sourceUrl.substring(0,Math.max(r,s)):this.sourceUrl,this.music.urlPrefix=this.urlPrefix,dC(this.music.urlPrefix);const m=Ja.get(this.fullUrl(".distribution")).then(P=>P,P=>({data:""})),x=Ja.get(h),w=Ja.get(this.fullUrl("meta.json"));Promise.all([x,w,m]).then(P=>{const[E,z,A]=P;this.metaDataObject=z==null?void 0:z.data,this.distributionSource=A.data;const S=new DOMParser().parseFromString(E==null?void 0:E.data,"text/html"),N=S.documentElement,L=this.getRequiredVersionMessage(S);this.setState({requiredVersion:L});const j=N.getElementsByTagName("body")[0];this.mustUseOriginalPageSize=this.computeMustUseOriginalPageSize(j),this.bookInfo.setSomeBookInfoFromBody(j),this.localizeOnce(),this.props.shouldReportSoundLog&&(this.videoList=this.getVideoList(S)),this.animation.PlayAnimations=this.bookInfo.playAnimations,this.collectBodyAttributes(j),this.makeNonEditable(j),this.htmlElement=N;const f=N.getElementsByClassName("bloom-page")[0];this.originalPageClass="Device16x9Portrait",f&&(this.originalPageClass=Se.getPageSizeClass(f)),this.legacyQuestionHandler.generateQuizPagesFromLegacyJSON(this.urlPrefix,j,this.originalPageClass,()=>{this.finishUp()})}).catch(P=>this.HandleLoadingError(P))}else if(e.landscape!==this.props.landscape||e.useOriginalPageSize!==this.props.useOriginalPageSize||e.autoplay!==this.props.autoplay){const r=document.getElementsByClassName("bloom-page");for(let s=0;s<r.length;s++){const u=r[s];this.setPageSizeClass(u)}}!this.state.isLoading&&(n.isLoading||e.activeLanguageCode!==this.props.activeLanguageCode)&&(this.updateDivVisibilityByLangCode(n.isLoading),this.updateOverlayPositionsByLangCode(),this.finishUpCalled&&this.finishUp(!1)),this.state.currentSwiperIndex!=n.currentSwiperIndex&&((a=this.rootDiv)==null||a.querySelectorAll(_p).forEach(r=>{const s=zs(r).getNiceScroll();s&&s.length>0&&s.remove()})),!this.state.isLoading&&(n.isLoading||e.shouldReadImageDescriptions!==this.props.shouldReadImageDescriptions)&&this.finishUpCalled&&(this.setIndex(this.state.currentSwiperIndex),this.showingPage(this.state.currentSwiperIndex)),this.state.isFinishUpForNewBookComplete&&e.landscape!==this.props.landscape&&(this.setIndex(this.state.currentSwiperIndex),this.showingPage(this.state.currentSwiperIndex)),e.paused!==this.props.paused&&this.handlePausePlay(),this.swiperInstance&&this.swiperInstance.lazy.load()}catch(i){this.setState({isLoading:!1,loadFailed:!0,loadErrorHtml:i.message})}}collectBodyAttributes(e){for(var n={},a=0;a<e.attributes.length;a++)n[e.attributes.item(a).nodeName]=e.attributes.item(a).nodeValue;this.setState({importedBodyAttributes:n})}HandleLoadingError(e){let a=`<p>There was a problem displaying this book: ${e.message}<p>`;(e.config&&e.config.url&&e.config.url.startsWith("file://")||e.message.indexOf("404")>=0)&&(a="<p>This book (or some part of it) was not found.<p>",e.config&&e.config.url&&(a+=`<p class='errorDetails'>${oD(e.config.url)}</p>`)),this.setState({isLoading:!1,loadFailed:!0,loadErrorHtml:a})}async finishUp(e=!0){if(this.finishUpCalled=!0,!this.htmlElement)return;Uo.setAllVideoPostersTo1x1TransparentPNG(this.htmlElement);const n=this.htmlElement.getElementsByClassName("bloom-page"),a=[];e&&(this.bookInfo.totalNumberedPages=0,this.bookInfo.questionCount=0,this.activityManager.collectActivityContextForBook(n),this.bookInteraction.clearPagesShown(),this.music.processAllMusicForBook(n));const i=this.bookInfo.getPreferredTranslationLanguages(),r=i[0]===this.props.activeLanguageCode||!this.props.activeLanguageCode,s={},u=h=>h.classList.contains("bloom-interactive-page")||h.classList.contains("simple-comprehension-quiz")||h.getAttribute("data-activity")=="iframe"||h.getElementsByClassName("questions").length>0;s.length=0,s.cover=0;for(let h=0;h<n.length;h++){const m=n[h],x=m.getAttribute("id");x&&(s[x]=h);const w=this.setPageSizeClass(m);m.setAttribute("data-index",h.toString(10)),h===0&&this.props.reportBookProperties&&this.props.reportBookProperties({landscape:w,canRotate:this.bookInfo.canRotate,preferredLanguages:i,pageNumbers:Array.from(n).map(E=>E.getAttribute("data-page-number")??""),isRtl:this.metaDataObject.isRtl,internalUrl:this.state.bookUrl}),e&&(this.fixRelativeUrls(m),m.classList.contains("numberedPage")&&(this.indexOflastNumberedPage=h,this.bookInfo.totalNumberedPages++),(m.getAttribute("data-analyticscategories")||m.getAttribute("data-analyticsCategories"))==="comprehension"&&this.bookInfo.questionCount++),this.showOrHideL1OnlyText(m,r);const P=u(m);P&&this.activityManager.initializePageHtml(this.urlPrefix,m,a.length),(!this.props.skipActivities||!P)&&a.push(m.outerHTML)}if(e){const h=this.htmlElement.getElementsByTagName("head")[0];this.bookInfo.setSomeBookInfoFromHead(h);const m=this.htmlElement.getElementsByTagName("body")[0];if(this.metaDataObject&&(this.bookInfo.setSomeBookInfoFromMetadata(this.metaDataObject,m),this.reportBookOpened(m)),this.props.controlsCallback){const x=hs.createLangDataArrayFromDomAndMetadata(m,this.metaDataObject);this.hasImageDescriptions=sD(m),this.props.controlsCallback(x,this.hasImageDescriptions,w=>{var P;(P=this.swiperInstance)==null||P.slideTo(w)})}}if(e){var c;try{c=await NB(this.htmlElement,this.urlPrefix,this.bookInfo,()=>this.legacyQuestionHandler.getPromiseForAnyQuizCss())}catch(h){this.HandleLoadingError(h),c=""}if(this.startingUpSwiper=!0,this.state.startPageId){if(s[this.state.startPageId]===void 0)throw new Error(`Page ID ${this.state.startPageId} not found in the current pageIdToIndexMap`);this.setState({startPageIndex:s[this.state.startPageId]})}this.setState({pages:a,pageIdToIndexMap:s,styleRules:c,isLoading:!1,currentSwiperIndex:this.state.startPageIndex??0})}else this.setState({pages:a,isLoading:!1});this.props.pageStylesAreNowInstalled(),e?window.setTimeout(()=>{this.setState({isFinishUpForNewBookComplete:!0});const h=this.startingUpSwiper;this.startingUpSwiper=!1;var m=this.state.startPageIndex??0;this.setIndex(m),this.showingPage(m),h&&this.addScrollbarsToPageWhenReady(this.swiperInstance.activeIndex);const x=document.getElementsByClassName("swiper-button-next")[0],w=document.getElementsByClassName("swiper-button-prev")[0];w==null||w.setAttribute("tabindex","4"),x==null||x.setAttribute("tabindex","5"),x==null||x.focus()},500):Se.currentPage&&window.setTimeout(()=>{this.setIndex(Se.currentPageIndex),this.showingPage(Se.currentPageIndex)},200)}showOrHideL1OnlyText(e,n){e.querySelectorAll(".coverBottomBookTopic, .coverBottomLangName").forEach(a=>{n||a.classList.contains("bloom-content1")?a.classList.remove("do-not-display"):a.classList.add("do-not-display")})}localizeOnce(){!this.isPagesLocalized&&this.state.pages!==this.initialPages&&this.state.styleRules!==this.initialStyleRules&&(He.localizePages(document.body,this.bookInfo.getPreferredTranslationLanguages()),this.isPagesLocalized=!0)}initializeMedia(){this.video||(this.video=new Uo,this.video.PageVideoComplete=new Ur,this.video.PageVideoComplete.subscribe(this.handlePageVideoComplete)),this.animation||(this.animation=new jl),ta.subscribe(this.handlePageNarrationComplete),Pr.subscribe(this.handlePlayFailed),Ya.subscribe(this.handlePlayCompleted),lC(this.storeAudioAnalytics.bind(this)),Ma.subscribe(this.handleToggleImageDescription.bind(this)),uC(()=>{var e;return(e=this.swiperInstance)==null?void 0:e.animating}),cC(e=>Gy(e,1)),this.music||(this.music=new YC,this.music.PlayFailed=new Ur,this.music.PlayFailed.subscribe(()=>{this.setState({inPauseForced:!0}),this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!0)}))}preprocessUrl(){let e=this.state.bookUrl;if(e===void 0||e.trim()==="")throw new Error("The url parameter was empty. It should point to the url of a book.");return e.endsWith("/")&&(e=e.substring(0,e.length-1)),e.endsWith("%2f")&&(e=e.substring(0,e.length-3)),e}handlePausePlay(){this.props.paused?this.pauseAllMultimedia():Se.currentPage!==Dy()||yn===Ge.MediaFinished?this.resetForNewPageAndPlay(Se.currentPage):yn===Ge.VideoPaused?this.video.play():(RC(),this.animation.resumeAnimation(),this.music.play())}getAllBloomCanvasElementsOnPage(){var a,i;const e=(a=this.htmlElement)==null?void 0:a.ownerDocument.getElementsByClassName("bloom-canvas");if(e&&e.length>0)return Array.from(e);const n=(i=this.htmlElement)==null?void 0:i.ownerDocument.getElementsByClassName("bloom-imageContainer");return n?Array.from(n).filter(r=>r.parentElement.closest(".bloom-imageContainer")===null):[]}computeMustUseOriginalPageSize(e){return this.props.useOriginalPageSize||e.querySelector(".bloom-canvas-element")?!0:!!e.querySelector(".bloom-textOverPicture")}updateOverlayPositionsByLangCode(){if(!(!this.props.activeLanguageCode||!this.htmlElement))try{const e=this.props.activeLanguageCode;this.getAllBloomCanvasElementsOnPage().forEach(n=>{Array.from(n.querySelectorAll(Ls)).forEach(i=>{const r=Array.from(i.getElementsByClassName("bloom-editable")).find(s=>s.getAttribute("lang")===e);if(r){const s=r.getAttribute("data-bubble-alternate");if(s){const u=JSON.parse(s.replace(/`/g,'"'));i.setAttribute("style",u.style)}}});const a=Array.from(n.getElementsByClassName("comical-alternate")).find(i=>i.getAttribute("data-lang")===e);if(a){const i=n.getElementsByClassName("comical-generated")[0];i&&(i.classList.remove("comical-generated"),i.classList.add("comical-alternate"),i.style.display="none"),a.classList.remove("comical-alternate"),a.classList.add("comical-generated"),a.style.removeProperty("display")}})}catch(e){console.error(e)}}updateDivVisibilityByLangCode(e){if(!this.props.activeLanguageCode||!this.htmlElement)return;const a=this.bookInfo.getPreferredTranslationLanguages()[0]===this.props.activeLanguageCode||!this.props.activeLanguageCode,i=this.props.activeLanguageCode,r=this.htmlElement.ownerDocument.evaluate(".//div[contains(@class, 'bloom-translationGroup')]",this.htmlElement,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),s="bloom-visibility-code-on";for(let u=0;u<r.snapshotLength;u++){const c=r.snapshotItem(u),h=c.getAttribute("data-default-languages"),m=h?h.split(/,| /):[],x=m==null||m.length===0||!m[0]||m.includes("V")||m.includes("L1")||Se.areStringsEqualInvariantCultureIgnoreCase(m[0],"auto"),w=c.childNodes;for(let P=0;P<w.length;P++){const E=w.item(P);!E||!E.classList||!E.classList.contains("bloom-editable")||(e&&E.setAttribute("data-original-class",E.getAttribute("class")||""),a?E.setAttribute("class",E.getAttribute("data-original-class")||""):x&&(E.getAttribute("lang")===i?(E.classList.add(s),Array.from(E.classList).forEach(A=>{A.startsWith("bloom-content")&&E.classList.remove(A)}),E.classList.add("bloom-content1"),E.classList.add("bloom-contentFirst")):E.classList.remove(s)))}}}static areStringsEqualInvariantCultureIgnoreCase(e,n){return e.localeCompare(n,"en-US",{sensitivity:"accent"})===0}static isDivInL2(e){return e.classList.contains("bloom-contentNational1")}static isDivInL3(e){return e.classList.contains("bloom-contentNational2")}componentWillUnmount(){this.pauseAllMultimedia(),document.removeEventListener("keydown",e=>this.handleDocumentLevelKeyDown(e)),this.unsubscribeAllEvents()}unsubscribeAllEvents(){this.video.PageVideoComplete.unsubscribe(this.handlePageVideoComplete),ta.unsubscribe(this.handlePageNarrationComplete),Pr.unsubscribe(this.handlePlayFailed),Ya.unsubscribe(this.handlePlayCompleted),Ma.unsubscribe(this.handleToggleImageDescription)}pauseAllMultimedia(){yn===Ge.VideoPlaying?this.video.pause():yn===Ge.AudioPlaying&&(OC(),this.animation.PauseAnimation()),this.music.pause()}reportBookOpened(e){const n=this.bookInfo.getAmbientAnalyticsProps();this.distributionSource&&(n.distributionSource=this.distributionSource),zT(n),Xy("BookOrShelf opened",{})}sendUpdateOfBookProgressReportToExternalContext(){const e=this.bookInteraction.getProgressReportPropertiesForAnalytics();IT("Pages Read",e)}makeNonEditable(e){const n=e.ownerDocument.evaluate(".//*[@contenteditable]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(let a=0;a<n.snapshotLength;a++)n.snapshotItem(a).removeAttribute("contenteditable")}setPageSizeClass(e){return Se.setPageSizeClass(e,this.bookInfo.canRotate,this.props.landscape,this.mustUseOriginalPageSize,this.originalPageClass)}static getPageSizeClass(e){const a=(e.getAttribute("class")||"").match(/\b\S*?(Portrait|Landscape)\b/);return a&&a.length?a[0]:""}static setPageSizeClass(e,n,a,i,r){let s=!1;const u=this.getPageSizeClass(e);if(u){s=n?a:u.endsWith("Landscape");let c="";i?c=s?r.replace("Portrait","Landscape"):r.replace("Landscape","Portrait"):c=s?"Device16x9Landscape":"Device16x9Portrait",u!==c&&(e.classList.remove(u),e.classList.add(c))}return s}goToFirstPage(){this.swiperInstance.slideTo(0)}goToLastPage(){this.swiperInstance.slideTo(99999)}fixRelativeUrls(e){const n=e.ownerDocument.evaluate(".//*[@src]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(let r=0;r<n.snapshotLength;r++){const s=n.snapshotItem(r);if(!s)continue;const u=s.getAttribute("src"),c=this.fullUrl(u);s.setAttribute("src",c)}const a=e.ownerDocument.evaluate(".//*[@style]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),i=new RegExp(/background-image:url\(['"](.*)['"]\)/);for(let r=0;r<a.snapshotLength;r++){const s=a.snapshotItem(r);if(!s)continue;const u=s.getAttribute("style")||"",c=i.exec(u);if(!c)continue;const h=this.fullUrl(c[1]),m=u.replace(i,"");s.setAttribute("style",m),s.setAttribute("data-background",h),s.classList.add("swiper-lazy")}}fullUrl(e){return this.urlPrefix+"/"+e}getRootDiv(){return this.rootDiv}slideNext(){this.swiperInstance&&this.swiperInstance.slideNext()}slidePrevious(){this.swiperInstance&&this.swiperInstance.slidePrev()}getPlayerOptionsForPage(e){if(!e)return;let n=e.getAttribute("data-player-options");if(n)try{return n=n.replace(/'/g,'"'),JSON.parse(n)}catch(a){console.log("getPlayerOptionsForPage failed to parse json: "+n+" with error "+a.message);return}}render(){var i;const e=this.activityManager.getActivityAbsorbsDragging();if(this.state.isLoading)return B.createElement(Tz,{className:"loadingSpinner",color:"secondary"});if(this.state.loadFailed)return B.createElement(B.Fragment,null,B.createElement(fk,{className:"loadFailedIcon",color:"secondary"}),B.createElement("div",{className:"loadErrorMessage",dangerouslySetInnerHTML:{__html:this.state.loadErrorHtml}}));if(this.state.requiredVersion)return B.createElement("div",{className:"requiredVersionMessage"},this.state.requiredVersion);vC(this.props.shouldReadImageDescriptions&&this.hasImageDescriptions);const n={getSwiper:r=>{var s,u;this.swiperInstance=r,(s=this.metaDataObject)!=null&&s.isRtl&&this.swiperInstance&&((u=this.swiperInstance.el)==null||u.setAttribute("dir","rtl"),this.swiperInstance.rtl=!0,this.swiperInstance.rtlTranslate=!0)},simulateTouch:!0,touchStartPreventDefault:!1,on:{slideChange:()=>{this.state.inPauseForced&&this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!1),this.setState({inPauseForced:!1}),this.startingUpSwiper||this.showingPage(this.swiperInstance.activeIndex)},slideChangeTransitionStart:()=>{this.startingUpSwiper||this.setIndex(this.swiperInstance.activeIndex)},slideChangeTransitionEnd:()=>{this.addScrollbarsToPageWhenReady(this.swiperInstance.activeIndex)}},keyboard:{enabled:!0,onlyInViewport:!1},preloadImages:!1,lazy:{loadPrevNext:!0,loadOnTransitionStart:!0,loadPrevNextAmount:2},shouldSwiperUpdate:!0};this.startingUpSwiper&&(n.activeSlideKey=(i=this.state.startPageIndex)==null?void 0:i.toString());let a="bloomPlayer";return this.currentPageHidesNavigationButtons?a+=" hideNextPrevButtons extraScalingForChrome85Bug":(this.props.outsideButtonPageClass&&(a+=" "+this.props.outsideButtonPageClass),e&&(a+=" showNavigationButtonsEvenOnTouchDevices")),B.createElement("div",{"aria-label":"Player Content",className:a+(this.props.extraClassNames?" "+this.props.extraClassNames:""),ref:r=>this.rootDiv=r},B.createElement(rC,{key:this.shouldAutoPlay()?"fade":"slide",...n,effect:this.shouldAutoPlay()?"fade":"slide"},this.state.pages.map((r,s)=>{const c=Math.abs(s-this.state.currentSwiperIndex)<2||this.indicesOfPagesWhereWeShouldPreserveDOMState[s];return B.createElement("div",{key:s,className:"page-preview-slide",onClick:h=>this.handlePageClick(h)},c?B.createElement(B.Fragment,null,B.createElement("style",{scoped:!0},this.state.styleRules),B.createElement("div",{...this.state.importedBodyAttributes,className:`bloomPlayer-page ${this.bookInfo.hasAppearanceSystem?"appearance-system":""} ${this.state.importedBodyAttributes.class??""}`,dangerouslySetInnerHTML:{__html:r}})):"")})),B.createElement("div",{className:"swiper-button-prev "+(this.metaDataObject.isRtl?"swiper-button-right":"swiper-button-left")+(this.props.hideSwiperButtons||this.state.currentSwiperIndex===0?" swiper-button-disabled":""),onClick:()=>this.slidePrevious(),onTouchStart:r=>{this.setState({ignorePhonyClick:!0})}},B.createElement(Ta,{className:"nav-button",disableRipple:!0},this.metaDataObject.isRtl?B.createElement(ih,{titleAccess:He.getTranslation("Button.Prev",this.props.preferredUiLanguages,"Previous Page")}):B.createElement(ah,{titleAccess:He.getTranslation("Button.Prev",this.props.preferredUiLanguages,"Previous Page")}))),B.createElement("div",{className:"swiper-button-next "+(this.metaDataObject.isRtl?"swiper-button-left":"swiper-button-right")+(this.props.hideSwiperButtons||this.state.currentSwiperIndex>=this.state.pages.length-1?" swiper-button-disabled":""),onClick:()=>this.slideNext(),onTouchStart:r=>{this.setState({ignorePhonyClick:!0})}},B.createElement(Ta,{className:"nav-button",disableRipple:!0},this.metaDataObject.isRtl?B.createElement(ah,{titleAccess:He.getTranslation("Button.Next",this.props.preferredUiLanguages,"Next Page")}):B.createElement(ih,{titleAccess:He.getTranslation("Button.Next",this.props.preferredUiLanguages,"Next Page")}))))}shouldAutoPlay(){var e=this.bookInfo.autoAdvance&&this.props.landscape;return this.props.autoplay==="yes"?e=!0:this.props.autoplay==="no"&&(e=!1),e&&!this.skipAutoPlay}setIndex(e){if(this.state.isLoading||this.startingUpSwiper)return;this.setState({currentSwiperIndex:e});const n=this.getPageAtSwiperIndex(e);n&&(this.setPageSizeClass(n),this.animation.HandlePageBeforeVisible(n),this.video.hidingPage(),this.video.HandlePageBeforeVisible(n),$C(),this.music.hidingPage(),yn===Ge.AudioPaused||yn===Ge.VideoPaused?Mn(Ge.NewPageMediaPaused):(this.skipAutoPlay=!0,AC(),this.skipAutoPlay=!1,Mn(Ge.NewPage)))}getPageAtSwiperIndex(e){if(this.swiperInstance==null)return null;const n=this.swiperInstance.slides[e];return n?n.getElementsByClassName("bloom-page")[0]:null}getPageIdFromIndex(e){const n=this.getPageAtSwiperIndex(e);if(!n)throw new Error("No bloomPage at index "+e);return n.getAttribute("id")}static getCurrentPage(){return Se.currentPage}isXmatterPage(){const e=Se.currentPage;if(!e)return!0;const n=e.getAttribute("class");return!n||n.indexOf("bloom-page")<0||n.indexOf("bloom-backMatter")>=0||n.indexOf("bloom-frontMatter")>=0?!0:e.hasAttribute("data-xmatter-page")}showingPage(e){if(this.state.isLoading||this.startingUpSwiper)return;this.props.pageChanged&&this.props.pageChanged(e);const n=this.getPageAtSwiperIndex(e);if(!n){window.setTimeout(()=>this.showingPage(e),50);return}const a=this.getPlayerOptionsForPage(n);this.currentPageHidesNavigationButtons=!!(a&&a.hideNavigation),this.props.hidingNavigationButtonsCallback&&this.props.hidingNavigationButtonsCallback(this.currentPageHidesNavigationButtons),this.activityManager.showingPage(e,n)&&(this.indicesOfPagesWhereWeShouldPreserveDOMState[e]=!0),window.setTimeout(()=>{Se.currentPage=n,Se.currentPageIndex=e,Se.currentPageHasVideo=Uo.pageHasVideo(n),this.setPageSizeClass(n),this.resetForNewPageAndPlay(n),this.props.paused&&this.animation.shouldAnimate(n)&&(this.animation.HandlePageBeforeVisible(n),this.animation.HandlePageVisible(n),this.animation.HandlePageDurationAvailable(n,Jg(n)),this.animation.PauseOnFirstFrame()),this.isXmatterPage()||(this.bookInteraction.pageShown(e),e===this.indexOflastNumberedPage&&(this.bookInteraction.lastNumberedPageWasRead=!0)),this.props.reportPageProperties&&this.props.reportPageProperties({hasAudio:jC(n),hasMusic:this.music.pageHasMusic(n),hasVideo:Se.currentPageHasVideo}),this.bookInteraction.reportedAudioOnCurrentPage=!1,this.bookInteraction.reportedVideoOnCurrentPage=!1,this.sendUpdateOfBookProgressReportToExternalContext(),this.swiperInstance.params.noSwiping=this.activityManager.getActivityAbsorbsDragging(),this.swiperInstance.params.touchRatio=this.activityManager.getActivityAbsorbsDragging()?0:1,this.activityManager.getActivityAbsorbsTyping()?this.swiperInstance.keyboard.disable():this.swiperInstance.keyboard.enable(),Array.from(n.querySelectorAll("[data-sound]")).forEach(r=>{r.addEventListener("click",Hp)})},0)}addScrollbarsToPageWhenReady(e){if(this.state.isLoading||this.startingUpSwiper)return;const n=this.getPageAtSwiperIndex(e);if(!n){window.setTimeout(()=>this.addScrollbarsToPageWhenReady(e),50);return}OL(n,Se.handlePointerMoveEvent)}static handlePointerMoveEvent(e){var n;e.pointerType==="mouse"&&((n=e.target)!=null&&n.closest(".nicescroll-cursors"))&&e.stopPropagation()}storeAudioAnalytics(e){e<.001||Number.isNaN(e)||(this.bookInteraction.totalAudioDuration+=e,!this.isXmatterPage()&&(this.bookInteraction.reportedAudioOnCurrentPage||(this.bookInteraction.reportedAudioOnCurrentPage=!0,this.bookInteraction.audioPageShown(Se.currentPageIndex)),this.sendUpdateOfBookProgressReportToExternalContext()))}static storeVideoAnalytics(e){if(e<.001)return;const n=Se.currentPagePlayer;n.bookInteraction.totalVideoDuration+=e,!n.bookInteraction.reportedVideoOnCurrentPage&&!n.isXmatterPage()&&(n.bookInteraction.reportedVideoOnCurrentPage=!0,n.bookInteraction.videoPageShown(Se.currentPageIndex)),n.sendUpdateOfBookProgressReportToExternalContext()}resetForNewPageAndPlay(e){if(this.props.paused){this.video.HandlePageVisible(e,()=>this.props.paused);return}By(e),Se.currentPageHasVideo?(Mn(Ge.VideoPlaying),this.video.HandlePageVisible(e,()=>this.props.paused),this.music.pause()):this.playAudioAndAnimation(e)}playAudioAndAnimation(e){if(this.activityManager.getActivityManagesSound()){this.activityManager.doInitialSoundAndAnimation();return}if(Mn(Ge.AudioPlaying),!e)return;const n=Jg(e);this.animation.HandlePageDurationAvailable(e,n);const a=()=>{jl.pageHasAnimation(e)&&this.animation.HandlePageBeforeVisible(e),this.animation.HandlePageVisible(e),jy(e,this.animation.animatableCanvas),this.music.HandlePageVisible(e)};if(!this.sentBloomNotification&&(this.sentBloomNotification=!0,this.props.shouldReportSoundLog)){Uy("/publish/av/startRecording",this.videoList).then(a);return}a()}getVideoList(e){let n="";for(const r of Array.from(e.getElementsByTagName("video"))){var a=r,i=a.getElementsByTagName("source")[0].getAttribute("src");n&&(n+="|"),n+=i}return n}handlePageClick(e){if(!this.state.ignorePhonyClick&&(!this.activityManager.getActivityAbsorbsClicking()||e.target.closest("[data-href]")&&e.target.closest(".bloom-canvas"))&&!e.target.closest(".bloom-videoContainer")){const n=IB(e.nativeEvent,this.bookInfo.bookInstanceId,()=>this.getPageIdFromIndex(this.state.currentSwiperIndex));n?(this.navigate(n.bookUrl,n.pageId),e.stopPropagation(),e.preventDefault()):this.props.onContentClick&&this.props.onContentClick(e)}this.setState({ignorePhonyClick:!1})}}function oD(t){return t.replace("%23","#").replace(/[\u00A0-\u9999<>\&]/gim,e=>"&#"+e.charCodeAt(0)+";")}function sD(t){return t.ownerDocument.evaluate("//div[contains(@class, 'bloom-imageDescription')]/div[contains(@class, 'bloom-editable') and contains(@class, 'bloom-visibility-code-on')]//*[contains(@class, 'audio-sentence') or contains(@class, 'bloom-highlightSegment')]",t,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength>0?!0:t.ownerDocument.evaluate("//div[contains(@class, 'bloom-imageDescription')]/div[contains(@class, 'bloom-editable') and contains(@class, 'bloom-visibility-code-on') and @data-audiorecordingmode='TextBox']/p[text()]",t,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength>0}var Vp={},lD=ba,uD=wa;Object.defineProperty(Vp,"__esModule",{value:!0});var Xk=Vp.default=void 0,cD=uD(Ln()),dD=lD(ka()),fD=(0,dD.default)(cD.createElement("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"}),"ArrowBack");Xk=Vp.default=fD;var Gp={},hD=ba,pD=wa;Object.defineProperty(Gp,"__esModule",{value:!0});var Zk=Gp.default=void 0,gD=pD(Ln()),mD=hD(ka()),vD=(0,mD.default)(gD.createElement("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"}),"MoreHoriz");Zk=Gp.default=vD;var Up={},yD=ba,bD=wa;Object.defineProperty(Up,"__esModule",{value:!0});var Yp=Up.default=void 0,wD=bD(Ln()),kD=yD(ka()),xD=(0,kD.default)(wD.createElement("path",{d:"M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"}),"PlayCircleOutline");Yp=Up.default=xD;var Xp={},SD=ba,CD=wa;Object.defineProperty(Xp,"__esModule",{value:!0});var Jk=Xp.default=void 0,TD=CD(Ln()),ED=SD(ka()),PD=(0,ED.default)(TD.createElement("path",{d:"M9 16h2V8H9v8zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm1-4h2V8h-2v8z"}),"PauseCircleOutline");Jk=Xp.default=PD;var Zp={},MD=ba,AD=wa;Object.defineProperty(Zp,"__esModule",{value:!0});var Qk=Zp.default=void 0,ND=AD(Ln()),LD=MD(ka()),zD=(0,LD.default)(ND.createElement("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"}),"Language");Qk=Zp.default=zD;var Jp={},BD=ba,DD=wa;Object.defineProperty(Jp,"__esModule",{value:!0});var t0=Jp.default=void 0,ID=DD(Ln()),jD=BD(ka()),RD=(0,jD.default)(ID.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"}),"Fullscreen");t0=Jp.default=RD;var Qp={},OD=ba,KD=wa;Object.defineProperty(Qp,"__esModule",{value:!0});var e0=Qp.default=void 0,$D=KD(Ln()),qD=OD(ka()),HD=(0,qD.default)($D.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}),"FullscreenExit");e0=Qp.default=HD;function FD(t){return kt.createElement(nh,{...t,width:"21",height:"20",viewBox:"0 0 21 20"},kt.createElement("path",{d:"M20.6181 9.909C20.6181 9.909 17.3581 3.70568 10.2454 3.70568C10.1127 3.70568 9.9821 3.70851 9.8522 3.71275L9.23133 0.590958L8.27889 0.807585L8.87136 3.78574C2.72807 4.50344 0 9.86355 0 9.86355C0 9.86355 0.566707 11.0581 1.77366 12.4165L1.27674 9.91983C1.26639 9.90052 1.26089 9.89016 1.26089 9.89016C1.26089 9.89016 1.45882 9.53343 1.86833 9.01188L2.73952 13.3918C3.09729 13.7179 3.49205 14.0383 3.92423 14.3419L2.68074 8.09074C2.92754 7.84068 3.20826 7.58049 3.52199 7.32171L5.05787 15.0424C5.40441 15.2277 5.77033 15.3993 6.15474 15.5514L4.38901 6.67725C4.6772 6.48487 4.98565 6.29932 5.31568 6.12485L7.26481 15.9206C7.59924 16.0118 7.94578 16.0871 8.30509 16.146L7.56314 12.4167C7.89823 12.8518 8.32205 13.2046 8.80465 13.4464L9.36563 16.2656C9.59813 16.2802 9.83459 16.2891 10.0765 16.2891C10.1734 16.2891 10.2694 16.2873 10.3654 16.2844L9.86541 13.773C10.0112 13.7923 10.1591 13.8033 10.3099 13.8033C10.4957 13.8033 10.6783 13.7883 10.8559 13.7588L11.9801 19.4091L12.9321 19.1924L12.3108 16.0683C17.848 14.9378 20.6181 9.909 20.6181 9.909ZM6.88084 8.9881L6.22651 5.69889C6.53386 5.57339 6.8575 5.45942 7.19546 5.35982L7.6228 7.50844C7.28066 7.93015 7.02351 8.43381 6.88084 8.9881ZM8.46692 6.74577L8.14503 5.12836C8.45547 5.06785 8.77691 5.01958 9.11002 4.9859L9.3773 6.32923C9.05322 6.42294 8.74741 6.56375 8.46692 6.74577ZM10.3467 6.19713L10.0944 4.93033C10.1472 4.92963 10.1998 4.92845 10.2533 4.92845C10.4858 4.92845 10.713 4.93599 10.9365 4.94941C13.2188 5.33628 14.964 7.44981 14.964 9.99965C14.964 12.1188 13.7579 13.9352 12.0406 14.7106L11.7914 13.4565C13.0153 12.8558 13.8654 11.5342 13.8654 9.99942C13.8652 7.91226 12.2936 6.21856 10.3467 6.19713ZM14.5336 14.0984C15.4349 13.0056 15.9823 11.5718 15.9823 9.99942C15.9823 8.35399 15.3821 6.8595 14.405 5.74928C17.7771 7.16772 19.3574 9.92642 19.3574 9.92642C19.3574 9.92642 17.7491 12.6074 14.5336 14.0984Z"}))}var tg={},WD=ba,_D=wa;Object.defineProperty(tg,"__esModule",{value:!0});var n0=tg.default=void 0,VD=_D(Ln()),GD=WD(ka()),UD=(0,GD.default)(VD.createElement("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"}),"VolumeUp");n0=tg.default=UD;const YD=t=>{const[e,n]=B.useState((t.languages.filter(s=>s.IsSelected)[0]||t.languages[0]).Code),a=s=>{const u=s.target.value;n(u),t.onClose(u)},i=()=>{t.onClose("")},r=()=>{const s=t.languages.map(u=>kt.createElement("div",{className:"chooserItem",key:u.Code},kt.createElement(aB,{value:u.Code,control:kt.createElement(mB,null),label:u.Name,checked:u.Code===e}),kt.createElement("span",{className:"spacer"}),kt.createElement(n0,{className:"icon",visibility:u.HasAudio?"inherit":"hidden"})));return kt.createElement("div",{className:"radioGroupDiv"},s)};return kt.createElement(Fz,{className:"languageMenu",onClose:i,"aria-labelledby":"language-menu-title",open:!0,scroll:"paper"},kt.createElement(Yz,{id:"language-menu-title"},"Languages in this book:"),kt.createElement(tB,{component:"fieldset"},kt.createElement(vB,{className:"radioGroup","aria-label":"languages",name:"languages",value:e,onChange:a},r())),kt.createElement(Vz,null,kt.createElement(bz,{onClick:i,color:"secondary"},"Close")))};var _o=(t=>(t[t.showArrow=0]="showArrow",t[t.showEllipsis=1]="showEllipsis",t[t.showNothing=2]="showNothing",t))(_o||{});const XD=t=>{const[e,n]=B.useState(!1),a="button"+(t.bookLanguages.length<2?" disabled":""),i=E=>{n(!1),E!==""&&(t.onLanguageChanged(E),s({lang:E}))},r=()=>{try{document.fullscreenElement!=null||document.webkitFullscreenElement!=null?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullScreen&&document.webkitExitFullScreen():document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.webkitRequestFullscreen&&document.documentElement.webkitRequestFullscreen()}catch(E){console.error("RequestFullScreen failed: ",E)}},s=E=>{if(!t.videoPreviewMode)return;const z={lang:t.activeLanguageCode,imageDescriptions:t.readImageDescriptions,...E};Uy("publish/av/videoSettings",encodeURIComponent(JSON.stringify(z)))},u=He.getTranslation("Audio.Pause",t.preferredLanguages,"Pause"),c=t.paused?kt.createElement(Yp,{titleAccess:t.playLabel}):kt.createElement(Jk,{titleAccess:u}),h=He.getTranslation("Button.ReadImageDescriptions",t.preferredLanguages,"Read Image Descriptions"),m=He.getTranslation("Button.IgnoreImageDescriptions",t.preferredLanguages,"Ignore Image Descriptions"),x=gs({palette:{primary:{main:eD},secondary:{main:Uk.palette.secondary.main}}}),w=kt.createElement(Vl,{theme:x},kt.createElement(FD,{"aria-label":t.readImageDescriptions?"Read image descriptions":"Ignore image descriptions",titleAccess:t.readImageDescriptions?m:h,opacity:t.readImageDescriptions?1:.38,color:t.nowReadingImageDescription?"primary":"secondary"})),P=t.extraButtons?t.extraButtons.map(E=>kt.createElement(Ta,{key:E.id,color:"secondary",title:E.description,onClick:()=>ja({messageType:E.id})},kt.createElement("img",{style:{maxHeight:"24px",maxWidth:"24px"},src:E.iconUrl}))):void 0;return kt.createElement(uz,{color:"primary",className:`control-bar ${t.visible?", visible":""}`,id:"control-bar",elevation:0,position:"relative"},kt.createElement(MB,null,!t.videoPreviewMode&&kt.createElement(Ta,{color:"secondary",onClick:()=>{t.backClicked&&t.backClicked()},"data-testid":"history-back-button",disabled:t.getBackButtonState()===2},t.getBackButtonState()===0?kt.createElement(Xk,{"aria-label":"Go Back",titleAccess:He.getTranslation("Button.Back",t.preferredLanguages,"Back")}):t.getBackButtonState()===1&&kt.createElement(Zk,{"aria-label":"More Menu",titleAccess:He.getTranslation("Button.More",t.preferredLanguages,"More")})),kt.createElement("div",{className:"filler"}),t.bookHasImageDescriptions&&kt.createElement(Ta,{onClick:()=>{t.onReadImageDescriptionToggled(),s({imageDescriptions:!t.readImageDescriptions})}},w),t.bookLanguages.length>1&&kt.createElement(Ta,{className:a,"aria-label":"Choose Language",color:"secondary",onClick:()=>{n(!0)}},kt.createElement(Qk,{titleAccess:He.getTranslation("Button.ChooseLanguage",t.preferredLanguages,"Choose Language")})),e&&kt.createElement(YD,{languages:t.bookLanguages,onClose:i}),!t.videoPreviewMode&&kt.createElement(Ta,{color:"secondary","aria-label":"PlayPause",onClick:()=>{t.pausedChanged&&t.pausedChanged(!t.paused)}},t.showPlayPause?c:null),P,document.fullscreenEnabled&&t.canShowFullScreen&&!t.videoPreviewMode&&kt.createElement(Ta,{color:"secondary",onClick:()=>r()},document.fullscreenElement==null?kt.createElement(t0,{"aria-label":"Full Screen",titleAccess:He.getTranslation("Button.FullScreen",t.preferredLanguages,"Full Screen")}):kt.createElement(e0,{"aria-label":"Exit Full Screen",titleAccess:He.getTranslation("Button.ExitFullScreen",t.preferredLanguages,"Exit Full Screen")}))))};function _d(t,e){return Math.round(t/e)*e}function ZD(t){if(!(!t||t==="cover")){if(/^\d+$/.test(t))return t;try{return t.replace(new RegExp("(?![0-9])\\p{Nd}","gu"),e=>{const n=e.charCodeAt(0);return(n&15)-6*(new RegExp("\\p{Nd}","u").test(String.fromCodePoint(n|15))?1:0)})}catch{return}}}let Vd=!1,dh=t=>{};function JD(t){dh&&dh(t)}let fy=0,hy=0;function py(){const t=/iPad|iPhone|iPod/.test(navigator.platform);let e,n,a;t&&(e=document.getElementsByClassName("bloomPlayer")[0],n=e.parentElement,a=e.nextSibling,n.removeChild(e));const i=document.documentElement.clientWidth,r=document.documentElement.clientHeight;return t&&n.insertBefore(e,a),{width:i,height:r}}const QD=t=>{const[e,n]=B.useState(t.autoplay),a=t.centerVertically===void 0?!0:t.centerVertically;$T(ht=>{ht.pause?(Vd=!L,j(!0)):ht.resume&&Vd?j(!1):ht.play?(j(!1),ht.autoplay&&n(ht.autoplay)):ht.reset?(h(t.startPage??0),Ue.current&&Ue.current(t.startPage??0)):ht.controlAction&&rt(ht.controlAction)});const[i,r]=B.useState(!1),[s,u]=B.useState(t.initiallyShowAppBar),[c,h]=B.useState(t.startPage??0),[m,x]=B.useState([""]),[w,P]=B.useState(!1),[E,z]=B.useState(!1),[A,k]=B.useState(""),[S,N]=B.useState("Device16x9Portrait");B.useEffect(()=>{u(t.initiallyShowAppBar)},[t.initiallyShowAppBar]),B.useEffect(()=>{s?RT():OT()},[s]),B.useEffect(()=>{j(t.paused)},[t.paused]);const[L,j]=B.useState(t.paused),[f,G]=B.useState(!1),V=He.getBloomUiLanguage(),F=V==="en"?[V]:[V,"en"],[pt,ft]=B.useState(F);B.useEffect(()=>{L||(Vd=!1)},[L]);const[ot,Z]=B.useState(!1),[$,o]=B.useState(!1),[tt,v]=B.useState(!1),[Q,st]=B.useState(!1),[ut,I]=B.useState(!1),[lt,gt]=B.useState(0),[Tt,Ct]=B.useState(9/16),jt=[],[Ft,Yt]=B.useState(jt),[Wt,Te]=B.useState(""),Ue=B.useRef(),[hn,ke]=B.useState(!0),[ve,Ye]=B.useState(!1),[Et,xe]=B.useState(!1),[qn,We]=B.useState(0),C=()=>{We(ht=>ht+1)},[D,W]=B.useState("");B.useEffect(()=>{mt()},[ut,qn,ot,t.useOriginalPageSize]),B.useEffect(()=>()=>{const ht=document.getElementById("scale-style-sheet");ht&&ht.parentNode.removeChild(ht)},[]);const X=B.useRef(),rt=ht=>{switch(ht){case"navigate-to-next-page":X&&X.current&&X.current.slideNext();break;case"navigate-to-previous-page":X&&X.current&&X.current.slidePrevious();break;default:console.log("'handleControlMessage' received an unknown message.");return}},mt=()=>{const ht=document.getElementsByClassName("swiper-slide-active")[0];let zt=null;if(ht&&(zt=ht.getElementsByClassName("bloom-page")[0]),!zt||!ut){window.setTimeout(C,100);return}let qe=document.getElementById("scale-style-sheet");qe||(qe=document.createElement("style"),qe.setAttribute("type","text/css"),qe.setAttribute("id","scale-style-sheet"),document.head.appendChild(qe));let pe=lt,Jt=Tt;const ge=Se.getPageSizeClass(zt);(t.url!==A||ge!==S)&&(k(t.url),N(ge),window.onresize=()=>{const{width:ca,height:qa}=py();(qa!==hy||ca!==fy)&&C()},pe=Math.max(zt.offsetHeight,zt.offsetWidth),Jt=Math.min(zt.offsetHeight,zt.offsetWidth)/pe,Ct(Jt),gt(pe));const{width:St,height:Bt}=py();fy=St,hy=Bt;const ee=St>Bt;if(ee!==ot){Z(ee);return}let ye=0,ce=0;const Ze=window.getComputedStyle(document.body);Ze&&Ze.marginTop&&(ye=parseInt(Ze.marginTop,10)),Ze&&Ze.marginBottom&&(ce=parseInt(Ze.marginBottom,10));const ue=zt.getAttribute("class").indexOf("Landscape")>=0,ri=ue?pe*Jt:pe,nn=ue?pe:pe*Jt;let ua=ye+ce;if(s){const ca=document.getElementById("control-bar");ca&&(ua+=ca.offsetHeight);const qa=document.getElementById("pageNumberControl");qa&&(ua+=qa.offsetHeight)}const Ka=Bt-ua,oi=_t({pageWidth:nn,pageHeight:ri,desiredPageHeight:Ka}),mr=re(nn);let Je=Math.min(oi,mr);const Ne=ri*Je;let $a=Ne*Jt/Je;ue&&($a=Ne/Jt/Je);const $i=St/Je-$a;let Tn="",xa=Math.max((St-nn*Je)/2,0);t.roundMarginToNearestK&&(xa=_d(xa,t.roundMarginToNearestK));const uo=xa,co=Je,sc=30;if($i>100*2)Tn="largeOutsideButtons";else if($i>sc*2)Tn="smallOutsideButtons";else if(St>407&&navigator.userAgent.includes("Chrome")&&!t.hideSwiperButtons){const qa=new RegExp(" Chrome/([0-9]+).").exec(navigator.userAgent),vr=parseInt(qa[1]);vr&&vr<90&&(Je*=.9,xa=Math.max((St-nn*Je)/2,0),Tn="smallOutsideButtons extraScalingForChrome85Bug")}Tn!==D&&W(Tn);let fo="";if(a){const ca=(Bt-Ne-ua)/2;ca>0&&(fo=`translate(0, ${ca.toFixed(0)}px) `)}qe.innerText=`.bloomPlayer {
8051
8051
  width: ${$a}px;
8052
8052
  transform-origin: left top 0;
8053
8053
  transform: ${fo}scale(${Je});
@@ -8060,4 +8060,4 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
8060
8060
  }
8061
8061
  }
8062
8062
  .bloomPlayer-page {height: ${Ne/Je}px; overflow: hidden;}`,qL(zt,Je),i||r(!0)},_t=ht=>{const{pageWidth:zt,pageHeight:qe,desiredPageHeight:pe}=ht,Jt=pe/qe;if(!t.roundPageWidthToNearestK)return Jt;const ge=zt*Jt;return _d(ge,t.roundPageWidthToNearestK)/zt},re=ht=>{let zt=document.body.offsetWidth;return t.roundPageWidthToNearestK&&(zt=_d(zt,t.roundPageWidthToNearestK)),zt/ht};B.useEffect(()=>{f&&!L&&G(!1);const ht=document.getElementById("root");ht&&(dh=zt=>{(zt.key===" "||zt.key==="ArrowRight"&&f)&&(zt.preventDefault(),zt.stopImmediatePropagation(),j(!L),G(!1))},ht.addEventListener("keydown",JD,{capture:!0}))});const oe=ht=>{Wt!==ht&&(hs.selectNewLanguageCode(Ft,ht),Te(ht))},Ot=(ht,zt,qe)=>{Ue.current=qe;let pe;if(t.videoSettings){const Jt=JSON.parse(t.videoSettings);pe=Jt.lang,ke(Jt.imageDescriptions??!1)}t.initialLanguageCode&&(pe=t.initialLanguageCode),pe&&ht.map(Jt=>Jt.Code).includes(pe)?hs.selectNewLanguageCode(ht,pe):pe=ht.length>0?ht[0].Code:"",Te(pe),Yt(ht),Ye(zt),t.videoPreviewMode&&!s&&u(!0)},Ie=He.getTranslation("Audio.Play",pt,"Play"),_e=He.getTranslation("Audio.ReadAloud",pt,"Read Aloud"),Cn=$?_e:Ie,{allowToggleAppBar:pn,showBackButton:la,initiallyShowAppBar:Oa,locationOfDistFolder:Xe,hideFullScreenButton:Pt,...ln}=t,H=gs({palette:{primary:{main:"#000",contrastText:"#FFF"},secondary:{main:"#FFF"}}}),Lt=ht=>{xe(ht)},Xt=Re({root:{color:gi,height:2,padding:"15px 0"},active:{},valueLabel:{left:"calc(50% - 16px)",top:-31,"& *":{background:gi,color:"white"}},track:{height:4,opacity:.5},rail:{height:2,opacity:.5,backgroundColor:gi},mark:{backgroundColor:"transparent"},markActive:{backgroundColor:"transparent"},markLabel:{top:20,fontSize:"0.6rem",color:gi},markLabelActive:{top:20,fontSize:"0.6rem",color:gi}})(TB),Oe=gs({direction:"rtl"}),Ae=kt.createElement(Xt,{valueLabelDisplay:"on",min:1,max:m.length,step:1,disabled:E,defaultValue:c+1,onChangeCommitted:(ht,zt)=>{zt-1!=c&&(h(zt-1),Ue.current&&Ue.current(zt-1))},valueLabelFormat:(ht,zt)=>m[ht-1],marks:[{value:m.length,label:m.length.toString()}]});return kt.createElement("div",{className:"reactRoot"},f&&kt.createElement(kt.Fragment,null,kt.createElement("div",{className:"bigButtonOverlay"},kt.createElement(Vl,{theme:H},kt.createElement(Ta,{color:"secondary",onClick:()=>{G(!1),j(!1)}},kt.createElement(Yp,{titleAccess:Cn,preserveAspectRatio:"xMidYMid meet"})))),kt.createElement("div",{className:"behindBigButtonOverlay"})),kt.createElement(XD,{getBackButtonState:()=>{var ht;return(ht=X.current)!=null&&ht.CanGoBack()?_o.showArrow:la?window===window.top?_o.showArrow:_o.showEllipsis:_o.showNothing},visible:s,paused:L,pausedChanged:ht=>j(ht),playLabel:Cn,preferredLanguages:pt,backClicked:()=>{var ht;(ht=X.current)!=null&&ht.HandleBackButtonClickedIfHavePlayerHistory()||jT()},showPlayPause:$||tt||Q,bookLanguages:Ft,activeLanguageCode:Wt,onLanguageChanged:oe,canShowFullScreen:!t.hideFullScreenButton,extraButtons:t.extraButtons,bookHasImageDescriptions:ve,readImageDescriptions:hn,onReadImageDescriptionToggled:()=>ke(!hn),nowReadingImageDescription:Et,videoPreviewMode:t.videoPreviewMode}),kt.createElement(nD,null),kt.createElement(Se,{ref:X,url:t.url,landscape:ot,paused:L,preferredUiLanguages:pt,pageStylesAreNowInstalled:()=>{I(!0)},locationOfDistFolder:t.locationOfDistFolder,reportBookProperties:ht=>{const zt={landscape:ht.landscape,canRotate:ht.canRotate};BT(zt),ft([V].concat(ht.preferredLanguages)),x(ht.pageNumbers),P(ht.isRtl),ht.internalUrl!=Gd&&(Gd&&C(),Gd=ht.internalUrl)},controlsCallback:Ot,setForcedPausedCallback:ht=>{ht?(j(ht),G(!0)):G(!1)},reportPageProperties:ht=>{o(ht.hasAudio),v(ht.hasMusic),st(ht.hasVideo)},onContentClick:ht=>{t.allowToggleAppBar&&(u(!s),window.setTimeout(C,300+50))},activeLanguageCode:Wt,useOriginalPageSize:t.useOriginalPageSize,hideSwiperButtons:t.hideSwiperButtons,autoplay:e,skipActivities:t.skipActivities,outsideButtonPageClass:D,extraClassNames:i?"":"hidePlayer",shouldReadImageDescriptions:hn,imageDescriptionCallback:Lt,pageChanged:ht=>{ht!=c&&h(ht)},hidingNavigationButtonsCallback:ht=>{ht!=E&&z(ht)},shouldReportSoundLog:t.shouldReportSoundLog,startPageIndex:t.startPage,autoplayCount:t.autoplayCount}),s&&!t.videoPreviewMode&&kt.createElement("div",{id:"pageNumberControl",className:"MuiToolbar-gutters"},w?kt.createElement(Vl,{theme:Oe},Ae):Ae))};function tI(){const t=ga("extraButtons");if(!t)return[];const e=decodeURIComponent(t);try{return JSON.parse(e)}catch(n){return console.error("Failed to parse extra button info "+JSON.stringify(n)),KT("error decoding extraButtons param "+t+": "+n),[]}}function eI(){mC(parseFloat(ga("defaultDuration","3.0")));const t=ga("autoplay","motion"),e=ga("start-page"),n=ZD(e),a=n?parseInt(n):void 0,i=ga("autoplay-count"),r=e?parseInt(i):void 0,s=Vn("paused",!1);Ki.render(kt.createElement(Vl,{theme:Uk},kt.createElement(QD,{url:ga("url"),allowToggleAppBar:Vn("allowToggleAppBar",!1),showBackButton:Vn("showBackButton",!1),initiallyShowAppBar:Vn("initiallyShowAppBar",!0),centerVertically:Vn("centerVertically",!0),initialLanguageCode:ga("lang"),videoSettings:ga("videoSettings"),paused:s,locationOfDistFolder:"",useOriginalPageSize:Vn("useOriginalPageSize",!1),hideFullScreenButton:Vn("hideFullScreenButton",!1),autoplay:t,skipActivities:Vn("skipActivities",!1),videoPreviewMode:Vn("videoPreviewMode",!1),hideSwiperButtons:Vn("hideNavButtons",!1),extraButtons:tI(),shouldReportSoundLog:Vn("reportSoundLog",!1),startPage:a,autoplayCount:r,roundPageWidthToNearestK:Qg("roundPageWidthToNearestK"),roundMarginToNearestK:Qg("roundMarginToNearestK")})),document.getElementById("root"))}let Gd="";eI();
8063
- //# sourceMappingURL=bloomPlayer.B_3eHZ__.js.map
8063
+ //# sourceMappingURL=bloomPlayer.DY9dkgL8.js.map
@@ -18,7 +18,7 @@
18
18
 
19
19
  <!-- At build time, we replace the target of this script tag to point at the
20
20
  the bloom player bundle with the cache-busting hash in its name. -->
21
- <script src="bloomPlayer.B_3eHZ__.js"></script>
21
+ <script src="bloomPlayer.DY9dkgL8.js"></script>
22
22
  </body>
23
23
 
24
24
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A library for displaying Bloom books in iframes or WebViews",
4
4
  "author": "SIL Global",
5
5
  "license": "MIT",
6
- "version": "2.16.0-alpha.4",
6
+ "version": "2.16.0-alpha.5",
7
7
  "private": false,
8
8
  "// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working": "",
9
9
  "sideEffects": false,