bloom-player 2.19.4 → 2.19.5-alpha.1
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.
|
@@ -8044,7 +8044,7 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
|
|
|
8044
8044
|
display:none !important;
|
|
8045
8045
|
}
|
|
8046
8046
|
`.replace(`
|
|
8047
|
-
`,"").replace("\r","")}const sc=[];function DB(){return sc.length>0}function jB(e){const t=sc.pop();if(t)return{bookUrl:e===t.bookId?void 0:fh(t.bookId),pageId:t.pageId}}function RB(e,t,n){const a=e.target.closest("[href], [data-href]");if(!a)return;e.preventDefault(),e.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=sc.pop();return c?{bookUrl:t===c.bookId?void 0:fh(c.bookId),pageId:c.pageId}:void 0}else if(i.startsWith("/book/")){const c=OB(i);r=c.bookId,s=c.pageId,c.bookId===t&&(r=void 0)}else i.startsWith("#")&&(s=i.substring(1));const l=n();if(r)return dy(t,l),{bookUrl:fh(r),pageId:s};if(s)return dy(t,l),{pageId:s}}function dy(e,t,n){sc.push({bookId:e,pageId:t})}function fh(e){return`/book/${e}/index.htm`}function OB(e){try{const t=new URL(e,window.location.origin);if(!t.pathname.startsWith("/book/"))throw new Error("Invalid book URL format");const n=t.pathname.replace("/book/",""),a=t.hash.replace("#","");return{bookId:n,pageId:a}}catch(t){return console.error("Error parsing book URL:",t),{bookId:void 0,pageId:void 0}}}const KB="bloom-player",$B="A library for displaying Bloom books in iframes or WebViews",qB="SIL Global",HB="MIT",FB="2.19.4",WB=!1,_B={type:"git",url:"git+https://github.com/BloomBooks/bloom-player.git"},VB="module",GB="lib/shared.es.js",UB="lib/index.d.ts",YB={".":{types:"./lib/index.d.ts",import:"./lib/shared.es.js",default:"./lib/shared.es.js"}},XB={"// 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"},ZB={"@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"},JB={"@crowdin/cli":"^4.13.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",glob:"^10",husky:"8.0.3",jsdom:"^25.0.1",less:"^4.2.0",prettier:"^3.3.3",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"},QB=["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"],tI={node:"24.13.0",yarn:"1.22.19"},eI={name:KB,description:$B,author:qB,license:HB,version:FB,private:!1,"// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working":"",sideEffects:WB,repository:_B,type:VB,module:GB,types:UB,exports:YB,scripts:XB,dependencies:ZB,devDependencies:JB,"// The four src/ files are directly exported so BloomDesktop can consume them as shared code.":"",files:QB,volta:tI},vi="#d65649",nI="#2e2e2e",aI="#febf00",Zk=gs({palette:{primary:{main:nI,contrastText:vi},secondary:{main:vi}}});function Jk(){var e=eI.version;return e}const iI=({getBookInstanceId:e})=>{const[t,n]=B.useState(!1),a=Jk(),i=new Date("2026-04-02T04:51:18.650Z").toLocaleDateString();if(B.useEffect(()=>{const s=c=>{c.key==="Control"&&n(!0)},l=c=>{c.key==="Control"&&n(!1)};return window.addEventListener("keydown",s),window.addEventListener("keyup",l),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",l)}},[]),!t)return null;const r=e==null?void 0:e();return wt.createElement("div",{className:"diagnostic-info-control",style:{color:vi,fontFamily:"sans-serif",padding:"5px",zIndex:1e3,lineHeight:"1.5"}},wt.createElement("div",null,"Bloom Player v",a," (built ",i,")"),wt.createElement("div",null,"Book ID: ",r??""))},rI=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,fy=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");const t=e.match(rI);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},hy=e=>e==="*"||e==="x"||e==="X",py=e=>{const t=parseInt(e,10);return isNaN(t)?e:t},oI=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],sI=(e,t)=>{if(hy(e)||hy(t))return 0;const[n,a]=oI(py(e),py(t));return n>a?1:n<a?-1:0},gy=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){const a=sI(e[n]||"0",t[n]||"0");if(a!==0)return a}return 0},my=(e,t)=>{const n=fy(e),a=fy(t),i=n.pop(),r=a.pop(),s=gy(n,a);return s!==0?s:i&&r?gy(i.split("."),r.split(".")):i||r?i?-1:1:0},hh=new ur;class Te extends B.Component{constructor(t,n){super(t,n),this.activityManager=new az,this.initialPages=["loading..."],this.initialStyleRules="",this.originalPageClass="Device16x9Portrait",this.bookInfo=new dh,this.bookInteraction=new LB,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===Te.currentPage&&this.playAudioAndAnimation(i.page)},this.handlePlayFailed=()=>{this.setState({inPauseForced:!0}),this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!0)},this.handlePlayCompleted=()=>{Tn(Ge.MediaFinished),this.props.imageDescriptionCallback(!1)},this.handleToggleImageDescription=i=>{this.props.imageDescriptionCallback(i)},this.handlePageNarrationComplete=i=>{if(i&&(Tn(Ge.MediaFinished),this.shouldAutoPlay())){const r=this.props.autoplayCount??0,s=this.state.startPageIndex??0,l=this.swiperInstance.slides.length-1;let c=this.props.autoplayCount?Math.min(s+r-1,l):l;this.swiperInstance.activeIndex>=c?(this.music.pause(),this.props.shouldReportSoundLog&&YC(),GC(),DT({})):this.swiperInstance.slideNext()}},this.skipAutoPlay=!1,this.sentBloomNotification=!1;const a=t.url.startsWith("http")?new URL(t.url):new URL(t.url,window.location.origin);a.hash?(this.state.startPageId=a.hash.substring(1),a.hash=""):this.state.startPageIndex=t.startPageIndex,this.state.bookUrl=a.href,Te.currentPagePlayer=this,this.legacyQuestionHandler=new rz(t.locationOfDistFolder)}componentDidMount(){He.setUp(),window.addEventListener("focus",()=>this.handleWindowFocus()),window.addEventListener("blur",()=>this.handleWindowBlur()),document.addEventListener("keydown",t=>this.handleDocumentLevelKeyDown(t)),document.addEventListener("pointerdown",t=>{(t.target.closest("[href], [data-href]")||t.target.closest(".bloom-videoContainer")&&!t.target.closest("[data-draggable-id]"))&&(t.stopPropagation(),t.preventDefault())},{capture:!0}),document.addEventListener("dragstart",t=>{this.activityManager.getActivityAbsorbsDragging()||t.preventDefault()},{capture:!0}),this.componentDidUpdate(this.props,this.state)}CanGoBack(){return DB()}HandleBackButtonClickedIfHavePlayerHistory(){const t=this.getBookIdFromBookUrlForHistory(this.state.bookUrl)||this.bookInfo.bookInstanceId,n=jB(t);return n?(this.navigate(n.bookUrl,n.pageId),!0):!1}navigate(t,n){if(t){const a=new URL(t,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)}}getBookIdFromBookUrlForHistory(t){if(t)try{const a=new URL(t,window.location.href).pathname.match(/^\/book\/([^/]+)\/index\.htm$/i);return a?a[1]:void 0}catch{return}}handleWindowFocus(){const t=localStorage.getItem(Fl),n=localStorage.getItem(im);t&&n==this.sourceUrl&&(this.bookInteraction.beginReadTime=Date.now()-parseInt(t,10))}handleWindowBlur(){const t=Date.now()-this.bookInteraction.beginReadTime;localStorage.setItem(Fl,t.toString()),localStorage.setItem(im,this.sourceUrl)}getRequiredVersionMessage(t){var c;const n=(c=t.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||my(h,r)>0)&&(r=h,s=i[2])}if(!r||!s)return"";const l=Jk();if(my(l,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=pa("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(t,n){var a;try{if(!this.props.url||this.state.loadFailed&&n.bookUrl===this.state.bookUrl)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 l;r>s?l=this.sourceUrl.substring(r+1,this.sourceUrl.length):l=this.sourceUrl.substring(s+3,this.sourceUrl.length);const c=l.endsWith(".htm"),h=c?this.sourceUrl:this.sourceUrl+"/"+l+".htm";this.urlPrefix=c?this.sourceUrl.substring(0,Math.max(r,s)):this.sourceUrl,this.music.urlPrefix=this.urlPrefix,pC(this.music.urlPrefix);const m=ei.get(this.fullUrl(".distribution")).then(P=>P,P=>({data:""})),k=ei.get(h),w=ei.get(this.fullUrl("meta.json"));Promise.all([k,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=Te.getPageSizeClass(f)),this.legacyQuestionHandler.generateQuizPagesFromLegacyJSON(this.urlPrefix,j,this.originalPageClass,()=>{this.finishUp()})}).catch(P=>this.HandleLoadingError(P))}else if(t.landscape!==this.props.landscape||t.useOriginalPageSize!==this.props.useOriginalPageSize||t.autoplay!==this.props.autoplay){const r=document.getElementsByClassName("bloom-page");for(let s=0;s<r.length;s++){const l=r[s];this.setPageSizeClass(l)}}!this.state.isLoading&&(n.isLoading||t.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(Up).forEach(r=>{const s=zs(r).getNiceScroll();s&&s.length>0&&s.remove()})),!this.state.isLoading&&(n.isLoading||t.shouldReadImageDescriptions!==this.props.shouldReadImageDescriptions)&&this.finishUpCalled&&(this.setIndex(this.state.currentSwiperIndex),this.showingPage(this.state.currentSwiperIndex)),this.state.isFinishUpForNewBookComplete&&t.landscape!==this.props.landscape&&(this.setIndex(this.state.currentSwiperIndex),this.showingPage(this.state.currentSwiperIndex)),t.paused!==this.props.paused&&this.handlePausePlay(),this.swiperInstance&&this.swiperInstance.lazy.load()}catch(i){this.setState({isLoading:!1,loadFailed:!0,loadErrorHtml:i.message})}}collectBodyAttributes(t){for(var n={},a=0;a<t.attributes.length;a++)n[t.attributes.item(a).nodeName]=t.attributes.item(a).nodeValue;this.setState({importedBodyAttributes:n})}HandleLoadingError(t){var r;let a=`<p>There was a problem displaying this book: ${t.message}<p>`;const i=!!((r=t.config)!=null&&r.url)&&new URL(t.config.url,window.location.href).pathname.startsWith("/book/");i?a="<p>We could not find that book.</p>":(t.config&&t.config.url&&t.config.url.startsWith("file://")||t.message.indexOf("404")>=0)&&(a="<p>This book (or some part of it) was not found.<p>",t.config&&t.config.url&&(a+=`<p class='errorDetails'>${lI(t.config.url)}</p>`)),this.setState({isLoading:!1,loadFailed:!0,loadErrorHtml:a}),i&&hh.raise()}async finishUp(t=!0){if(this.finishUpCalled=!0,!this.htmlElement)return;Uo.setAllVideoPostersTo1x1TransparentPNG(this.htmlElement);const n=this.htmlElement.getElementsByClassName("bloom-page"),a=[];t&&(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={},l=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],k=m.getAttribute("id");k&&(s[k]=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}),t&&(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=l(m);P&&this.activityManager.initializePageHtml(this.urlPrefix,m,a.length),(!this.props.skipActivities||!P)&&a.push(m.outerHTML)}if(t){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 k=hs.createLangDataArrayFromDomAndMetadata(m,this.metaDataObject);this.hasImageDescriptions=uI(m),this.props.controlsCallback(k,this.hasImageDescriptions,w=>{var P;(P=this.swiperInstance)==null||P.slideTo(w)})}}if(t){var c;try{c=await zB(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(),t?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 k=document.getElementsByClassName("swiper-button-next")[0],w=document.getElementsByClassName("swiper-button-prev")[0];w==null||w.setAttribute("tabindex","4"),k==null||k.setAttribute("tabindex","5"),this.shouldFocusNextButtonForNewBook()&&(k==null||k.focus())},500):Te.currentPage&&window.setTimeout(()=>{this.setIndex(Te.currentPageIndex),this.showingPage(Te.currentPageIndex)},200)}shouldFocusNextButtonForNewBook(){return window.self===window.top||document.referrer.startsWith("http://localhost:")?!0:document.referrer.includes("bloomlibrary.org/player/")}showOrHideL1OnlyText(t,n){t.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 Rl),ta.subscribe(this.handlePageNarrationComplete),Ar.subscribe(this.handlePlayFailed),Ja.subscribe(this.handlePlayCompleted),dC(this.storeAudioAnalytics.bind(this)),La.subscribe(this.handleToggleImageDescription.bind(this)),fC(()=>{var t;return(t=this.swiperInstance)==null?void 0:t.animating}),hC(t=>Jy(t,1)),this.music||(this.music=new XC,this.music.PlayFailed=new ur,this.music.PlayFailed.subscribe(()=>{this.setState({inPauseForced:!0}),this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!0)}))}preprocessUrl(){let t=this.state.bookUrl;if(t===void 0||t.trim()==="")throw new Error("The url parameter was empty. It should point to the url of a book.");return t.endsWith("/")&&(t=t.substring(0,t.length-1)),t.endsWith("%2f")&&(t=t.substring(0,t.length-3)),t}handlePausePlay(){this.props.paused?this.pauseAllMultimedia():Te.currentPage!==Ky()||mn===Ge.MediaFinished?this.resetForNewPageAndPlay(Te.currentPage):mn===Ge.VideoPaused?this.video.play():($C(),this.animation.resumeAnimation(),this.music.play())}getAllBloomCanvasElementsOnPage(){var a,i;const t=(a=this.htmlElement)==null?void 0:a.ownerDocument.getElementsByClassName("bloom-canvas");if(t&&t.length>0)return Array.from(t);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(t){return this.props.useOriginalPageSize||t.querySelector(".bloom-canvas-element")?!0:!!t.querySelector(".bloom-textOverPicture")}updateOverlayPositionsByLangCode(){if(!(!this.props.activeLanguageCode||!this.htmlElement))try{const t=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")===t);if(r){const s=r.getAttribute("data-bubble-alternate");if(s){const l=JSON.parse(s.replace(/`/g,'"'));i.setAttribute("style",l.style)}}});const a=Array.from(n.getElementsByClassName("comical-alternate")).find(i=>i.getAttribute("data-lang")===t);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(t){console.error(t)}}updateDivVisibilityByLangCode(t){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 l=0;l<r.snapshotLength;l++){const c=r.snapshotItem(l),h=c.getAttribute("data-default-languages"),m=h?h.split(/,| /):[],k=m==null||m.length===0||!m[0]||m.includes("V")||m.includes("L1")||Te.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")||(t&&E.setAttribute("data-original-class",E.getAttribute("class")||""),a?E.setAttribute("class",E.getAttribute("data-original-class")||""):k&&(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(t,n){return t.localeCompare(n,"en-US",{sensitivity:"accent"})===0}static isDivInL2(t){return t.classList.contains("bloom-contentNational1")}static isDivInL3(t){return t.classList.contains("bloom-contentNational2")}componentWillUnmount(){this.pauseAllMultimedia(),document.removeEventListener("keydown",t=>this.handleDocumentLevelKeyDown(t)),this.unsubscribeAllEvents()}unsubscribeAllEvents(){this.video.PageVideoComplete.unsubscribe(this.handlePageVideoComplete),ta.unsubscribe(this.handlePageNarrationComplete),Ar.unsubscribe(this.handlePlayFailed),Ja.unsubscribe(this.handlePlayCompleted),La.unsubscribe(this.handleToggleImageDescription)}pauseAllMultimedia(){mn===Ge.VideoPlaying?this.video.pause():mn===Ge.AudioPlaying&&(qC(),this.animation.PauseAnimation()),this.music.pause()}reportBookOpened(t){const n=this.bookInfo.getAmbientAnalyticsProps();this.distributionSource&&(n.distributionSource=this.distributionSource),BT(n),tb("BookOrShelf opened",{})}sendUpdateOfBookProgressReportToExternalContext(){const t=this.bookInteraction.getProgressReportPropertiesForAnalytics();jT("Pages Read",t)}makeNonEditable(t){const n=t.ownerDocument.evaluate(".//*[@contenteditable]",t,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(let a=0;a<n.snapshotLength;a++)n.snapshotItem(a).removeAttribute("contenteditable")}setPageSizeClass(t){return Te.setPageSizeClass(t,this.bookInfo.canRotate,this.props.landscape,this.mustUseOriginalPageSize,this.originalPageClass)}static getPageSizeClass(t){const a=(t.getAttribute("class")||"").match(/\b\S*?(Portrait|Landscape)\b/);return a&&a.length?a[0]:""}static setPageSizeClass(t,n,a,i,r){let s=!1;const l=this.getPageSizeClass(t);if(l){s=n?a:l.endsWith("Landscape");let c="";i?c=s?r.replace("Portrait","Landscape"):r.replace("Landscape","Portrait"):c=s?"Device16x9Landscape":"Device16x9Portrait",l!==c&&(t.classList.remove(l),t.classList.add(c))}return s}goToFirstPage(){this.swiperInstance.slideTo(0)}goToLastPage(){this.swiperInstance.slideTo(99999)}fixRelativeUrls(t){const n=t.ownerDocument.evaluate(".//*[@src]",t,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(let r=0;r<n.snapshotLength;r++){const s=n.snapshotItem(r);if(!s)continue;const l=s.getAttribute("src"),c=this.fullUrl(l);s.setAttribute("src",c)}const a=t.ownerDocument.evaluate(".//*[@style]",t,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 l=s.getAttribute("style")||"",c=i.exec(l);if(!c)continue;const h=this.fullUrl(c[1]),m=l.replace(i,"");s.setAttribute("style",m),s.setAttribute("data-background",h),s.classList.add("swiper-lazy")}}fullUrl(t){return this.urlPrefix+"/"+t}getRootDiv(){return this.rootDiv}slideNext(){this.swiperInstance&&this.swiperInstance.slideNext()}slidePrevious(){this.swiperInstance&&this.swiperInstance.slidePrev()}getBookInstanceId(){return this.bookInfo.bookInstanceId}getPlayerOptionsForPage(t){if(!t)return;let n=t.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 t=this.activityManager.getActivityAbsorbsDragging();if(this.state.isLoading)return B.createElement(Pz,{className:"loadingSpinner",color:"secondary"});if(this.state.loadFailed)return B.createElement(B.Fragment,null,B.createElement(mk,{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);wC(this.props.shouldReadImageDescriptions&&this.hasImageDescriptions);const n={getSwiper:r=>{var s,l;this.swiperInstance=r,(s=this.metaDataObject)!=null&&s.isRtl&&this.swiperInstance&&((l=this.swiperInstance.el)==null||l.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),t&&(a+=" showNavigationButtonsEvenOnTouchDevices")),B.createElement("div",{"aria-label":"Player Content",className:a+(this.props.extraClassNames?" "+this.props.extraClassNames:""),ref:r=>this.rootDiv=r},B.createElement(lC,{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(Ma,{className:"nav-button",disableRipple:!0},this.metaDataObject.isRtl?B.createElement(oh,{titleAccess:He.getTranslation("Button.Prev",this.props.preferredUiLanguages,"Previous Page")}):B.createElement(rh,{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(Ma,{className:"nav-button",disableRipple:!0},this.metaDataObject.isRtl?B.createElement(rh,{titleAccess:He.getTranslation("Button.Next",this.props.preferredUiLanguages,"Next Page")}):B.createElement(oh,{titleAccess:He.getTranslation("Button.Next",this.props.preferredUiLanguages,"Next Page")}))))}shouldAutoPlay(){var t=this.bookInfo.autoAdvance&&this.props.landscape;return this.props.autoplay==="yes"?t=!0:this.props.autoplay==="no"&&(t=!1),t&&!this.skipAutoPlay}setIndex(t){if(this.state.isLoading||this.startingUpSwiper)return;this.setState({currentSwiperIndex:t});const n=this.getPageAtSwiperIndex(t);n&&(this.setPageSizeClass(n),this.animation.HandlePageBeforeVisible(n),this.video.hidingPage(),this.video.HandlePageBeforeVisible(n),FC(),this.music.hidingPage(),mn===Ge.AudioPaused||mn===Ge.VideoPaused?Tn(Ge.NewPageMediaPaused):(this.skipAutoPlay=!0,zC(),this.skipAutoPlay=!1,Tn(Ge.NewPage)))}getPageAtSwiperIndex(t){if(this.swiperInstance==null)return null;const n=this.swiperInstance.slides[t];return n?n.getElementsByClassName("bloom-page")[0]:null}getPageIdFromIndex(t){const n=this.getPageAtSwiperIndex(t);if(!n)throw new Error("No bloomPage at index "+t);return n.getAttribute("id")}static getCurrentPage(){return Te.currentPage}isXmatterPage(){const t=Te.currentPage;if(!t)return!0;const n=t.getAttribute("class");return!n||n.indexOf("bloom-page")<0||n.indexOf("bloom-backMatter")>=0||n.indexOf("bloom-frontMatter")>=0?!0:t.hasAttribute("data-xmatter-page")}showingPage(t){if(this.state.isLoading||this.startingUpSwiper)return;this.props.pageChanged&&this.props.pageChanged(t);const n=this.getPageAtSwiperIndex(t);if(!n){window.setTimeout(()=>this.showingPage(t),50);return}const a=this.getPlayerOptionsForPage(n);this.currentPageHidesNavigationButtons=!!(a&&a.hideNavigation),this.props.hidingNavigationButtonsCallback&&this.props.hidingNavigationButtonsCallback(this.currentPageHidesNavigationButtons),this.activityManager.showingPage(t,n)&&(this.indicesOfPagesWhereWeShouldPreserveDOMState[t]=!0),window.setTimeout(()=>{Te.currentPage=n,Te.currentPageIndex=t,Te.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.props.paused),this.animation.HandlePageDurationAvailable(n,em(n),this.props.paused)),this.isXmatterPage()||(this.bookInteraction.pageShown(t),t===this.indexOflastNumberedPage&&(this.bookInteraction.lastNumberedPageWasRead=!0)),this.props.reportPageProperties&&this.props.reportPageProperties({hasAudio:KC(n),hasMusic:this.music.pageHasMusic(n),hasVideo:Te.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",_p)})},0)}addScrollbarsToPageWhenReady(t){if(this.state.isLoading||this.startingUpSwiper)return;const n=this.getPageAtSwiperIndex(t);if(!n){window.setTimeout(()=>this.addScrollbarsToPageWhenReady(t),50);return}$L(n,Te.handlePointerMoveEvent)}static handlePointerMoveEvent(t){var n;t.pointerType==="mouse"&&((n=t.target)!=null&&n.closest(".nicescroll-cursors"))&&t.stopPropagation()}storeAudioAnalytics(t){t<.001||Number.isNaN(t)||(this.bookInteraction.totalAudioDuration+=t,!this.isXmatterPage()&&(this.bookInteraction.reportedAudioOnCurrentPage||(this.bookInteraction.reportedAudioOnCurrentPage=!0,this.bookInteraction.audioPageShown(Te.currentPageIndex)),this.sendUpdateOfBookProgressReportToExternalContext()))}static storeVideoAnalytics(t){if(t<.001)return;const n=Te.currentPagePlayer;n.bookInteraction.totalVideoDuration+=t,!n.bookInteraction.reportedVideoOnCurrentPage&&!n.isXmatterPage()&&(n.bookInteraction.reportedVideoOnCurrentPage=!0,n.bookInteraction.videoPageShown(Te.currentPageIndex)),n.sendUpdateOfBookProgressReportToExternalContext()}resetForNewPageAndPlay(t){if(this.props.paused){this.video.HandlePageVisible(t,()=>this.props.paused);return}if(Oy(t),Te.currentPageHasVideo){const n=()=>{this.video.HandlePageVisible(t,()=>this.props.paused),this.music.pause()};if(Tn(Ge.VideoPlaying),!this.sentBloomNotification&&(this.sentBloomNotification=!0,this.props.shouldReportSoundLog)){ef("/publish/av/startRecording",this.videoList).then(n);return}n()}else this.playAudioAndAnimation(t)}playAudioAndAnimation(t){if(this.activityManager.getActivityManagesSound()){this.activityManager.doInitialSoundAndAnimation();return}if(Tn(Ge.AudioPlaying),!t)return;const n=em(t);this.animation.HandlePageDurationAvailable(t,n,this.props.paused);const a=()=>{Rl.pageHasAnimation(t)&&this.animation.HandlePageBeforeVisible(t),this.animation.HandlePageVisible(t,this.props.paused),qy(t,this.animation.animatableCanvas),this.music.HandlePageVisible(t)};if(!this.sentBloomNotification&&(this.sentBloomNotification=!0,this.props.shouldReportSoundLog)){ef("/publish/av/startRecording",this.videoList).then(a);return}a()}getVideoList(t){let n="";for(const r of Array.from(t.getElementsByTagName("video"))){var a=r,i=a.getElementsByTagName("source")[0].getAttribute("src");n&&(n+="|"),n+=i}return n}handlePageClick(t){if(!this.state.ignorePhonyClick&&(!this.activityManager.getActivityAbsorbsClicking()||t.target.closest("[data-href]")&&t.target.closest(".bloom-canvas"))&&!t.target.closest(".bloom-videoContainer")){const n=RB(t.nativeEvent,this.bookInfo.bookInstanceId,()=>this.getPageIdFromIndex(this.state.currentSwiperIndex));n?(this.navigate(n.bookUrl,n.pageId),t.stopPropagation(),t.preventDefault()):this.props.onContentClick&&this.props.onContentClick(t)}this.setState({ignorePhonyClick:!1})}}function lI(e){return e.replace("%23","#").replace(/[\u00A0-\u9999<>\&]/gim,t=>"&#"+t.charCodeAt(0)+";")}function uI(e){return e.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')]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength>0?!0:e.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()]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength>0}var Yp={},cI=ya,dI=ba;Object.defineProperty(Yp,"__esModule",{value:!0});var Qk=Yp.default=void 0,fI=dI(Mn()),hI=cI(wa()),pI=(0,hI.default)(fI.createElement("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"}),"ArrowBack");Qk=Yp.default=pI;var Xp={},gI=ya,mI=ba;Object.defineProperty(Xp,"__esModule",{value:!0});var t0=Xp.default=void 0,vI=mI(Mn()),yI=gI(wa()),bI=(0,yI.default)(vI.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");t0=Xp.default=bI;var Zp={},wI=ya,kI=ba;Object.defineProperty(Zp,"__esModule",{value:!0});var Jp=Zp.default=void 0,xI=kI(Mn()),SI=wI(wa()),CI=(0,SI.default)(xI.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");Jp=Zp.default=CI;var Qp={},TI=ya,EI=ba;Object.defineProperty(Qp,"__esModule",{value:!0});var e0=Qp.default=void 0,PI=EI(Mn()),MI=TI(wa()),AI=(0,MI.default)(PI.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");e0=Qp.default=AI;var tg={},NI=ya,LI=ba;Object.defineProperty(tg,"__esModule",{value:!0});var n0=tg.default=void 0,zI=LI(Mn()),BI=NI(wa()),II=(0,BI.default)(zI.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");n0=tg.default=II;var eg={},DI=ya,jI=ba;Object.defineProperty(eg,"__esModule",{value:!0});var a0=eg.default=void 0,RI=jI(Mn()),OI=DI(wa()),KI=(0,OI.default)(RI.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"}),"Fullscreen");a0=eg.default=KI;var ng={},$I=ya,qI=ba;Object.defineProperty(ng,"__esModule",{value:!0});var i0=ng.default=void 0,HI=qI(Mn()),FI=$I(wa()),WI=(0,FI.default)(HI.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}),"FullscreenExit");i0=ng.default=WI;function _I(e){return wt.createElement(ih,{...e,width:"21",height:"20",viewBox:"0 0 21 20"},wt.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 ag={},VI=ya,GI=ba;Object.defineProperty(ag,"__esModule",{value:!0});var r0=ag.default=void 0,UI=GI(Mn()),YI=VI(wa()),XI=(0,YI.default)(UI.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");r0=ag.default=XI;const ZI=e=>{const[t,n]=B.useState((e.languages.filter(s=>s.IsSelected)[0]||e.languages[0]).Code),a=s=>{const l=s.target.value;n(l),e.onClose(l)},i=()=>{e.onClose("")},r=()=>{const s=e.languages.map(l=>wt.createElement("div",{className:"chooserItem",key:l.Code},wt.createElement(rB,{value:l.Code,control:wt.createElement(yB,null),label:l.Name,checked:l.Code===t}),wt.createElement("span",{className:"spacer"}),wt.createElement(r0,{className:"icon",visibility:l.HasAudio?"inherit":"hidden"})));return wt.createElement("div",{className:"radioGroupDiv"},s)};return wt.createElement(_z,{className:"languageMenu",onClose:i,"aria-labelledby":"language-menu-title",open:!0,scroll:"paper"},wt.createElement(Zz,{id:"language-menu-title"},"Languages in this book:"),wt.createElement(nB,{component:"fieldset"},wt.createElement(bB,{className:"radioGroup","aria-label":"languages",name:"languages",value:t,onChange:a},r())),wt.createElement(Uz,null,wt.createElement(kz,{onClick:i,color:"secondary"},"Close")))};var _o=(e=>(e[e.showArrow=0]="showArrow",e[e.showEllipsis=1]="showEllipsis",e[e.showNothing=2]="showNothing",e))(_o||{});const JI=e=>{const[t,n]=B.useState(!1),a="button"+(e.bookLanguages.length<2?" disabled":""),i=E=>{n(!1),E!==""&&(e.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(!e.videoPreviewMode)return;const z={lang:e.activeLanguageCode,imageDescriptions:e.readImageDescriptions,...E};ef("publish/av/videoSettings",encodeURIComponent(JSON.stringify(z)))},l=He.getTranslation("Audio.Pause",e.preferredLanguages,"Pause"),c=e.paused?wt.createElement(Jp,{titleAccess:e.playLabel}):wt.createElement(e0,{titleAccess:l}),h=He.getTranslation("Button.ReadImageDescriptions",e.preferredLanguages,"Read Image Descriptions"),m=He.getTranslation("Button.IgnoreImageDescriptions",e.preferredLanguages,"Ignore Image Descriptions"),k=gs({palette:{primary:{main:aI},secondary:{main:Zk.palette.secondary.main}}}),w=wt.createElement(Gl,{theme:k},wt.createElement(_I,{"aria-label":e.readImageDescriptions?"Read image descriptions":"Ignore image descriptions",titleAccess:e.readImageDescriptions?m:h,opacity:e.readImageDescriptions?1:.38,color:e.nowReadingImageDescription?"primary":"secondary"})),P=e.extraButtons?e.extraButtons.map(E=>wt.createElement(Ma,{key:E.id,color:"secondary",title:E.description,onClick:()=>$a({messageType:E.id})},wt.createElement("img",{style:{maxHeight:"24px",maxWidth:"24px"},src:E.iconUrl}))):void 0;return wt.createElement(dz,{color:"primary",className:`control-bar ${e.visible?", visible":""}`,id:"control-bar",elevation:0,position:"relative"},wt.createElement(NB,null,!e.videoPreviewMode&&wt.createElement(Ma,{color:"secondary",onClick:()=>{e.backClicked&&e.backClicked()},"data-testid":"history-back-button",disabled:e.getBackButtonState()===2},e.getBackButtonState()===0?wt.createElement(Qk,{"aria-label":"Go Back",titleAccess:He.getTranslation("Button.Back",e.preferredLanguages,"Back")}):e.getBackButtonState()===1&&wt.createElement(t0,{"aria-label":"More Menu",titleAccess:He.getTranslation("Button.More",e.preferredLanguages,"More")})),wt.createElement("div",{className:"filler"}),e.bookHasImageDescriptions&&wt.createElement(Ma,{onClick:()=>{e.onReadImageDescriptionToggled(),s({imageDescriptions:!e.readImageDescriptions})}},w),e.bookLanguages.length>1&&wt.createElement(Ma,{className:a,"aria-label":"Choose Language",color:"secondary",onClick:()=>{n(!0)}},wt.createElement(n0,{titleAccess:He.getTranslation("Button.ChooseLanguage",e.preferredLanguages,"Choose Language")})),t&&wt.createElement(ZI,{languages:e.bookLanguages,onClose:i}),!e.videoPreviewMode&&wt.createElement(Ma,{color:"secondary","aria-label":"PlayPause",onClick:()=>{e.pausedChanged&&e.pausedChanged(!e.paused)}},e.showPlayPause?c:null),P,document.fullscreenEnabled&&e.canShowFullScreen&&!e.videoPreviewMode&&wt.createElement(Ma,{color:"secondary",onClick:()=>r()},document.fullscreenElement==null?wt.createElement(a0,{"aria-label":"Full Screen",titleAccess:He.getTranslation("Button.FullScreen",e.preferredLanguages,"Full Screen")}):wt.createElement(i0,{"aria-label":"Exit Full Screen",titleAccess:He.getTranslation("Button.ExitFullScreen",e.preferredLanguages,"Exit Full Screen")}))))};function Vd(e,t){return Math.round(e/t)*t}function QI(e){if(!(!e||e==="cover")){if(/^\d+$/.test(e))return e;try{return e.replace(new RegExp("(?![0-9])\\p{Nd}","gu"),t=>{const n=t.charCodeAt(0);return(n&15)-6*(new RegExp("\\p{Nd}","u").test(String.fromCodePoint(n|15))?1:0)})}catch{return}}}let Gd=!1,ph=e=>{};function tD(e){ph&&ph(e)}let vy=0,yy=0;function by(){const e=/iPad|iPhone|iPod/.test(navigator.platform);let t,n,a;e&&(t=document.getElementsByClassName("bloomPlayer")[0],n=t.parentElement,a=t.nextSibling,n.removeChild(t));const i=document.documentElement.clientWidth,r=document.documentElement.clientHeight;return e&&n.insertBefore(t,a),{width:i,height:r}}const eD=e=>{const[t,n]=B.useState(e.autoplay),a=e.centerVertically===void 0?!0:e.centerVertically;qT(ut=>{ut.pause?(Gd=!j,f(!0)):ut.resume&&Gd?f(!1):ut.play?(f(!1),ut.autoplay&&n(ut.autoplay)):ut.reset?(m(e.startPage??0),Qe.current&&Qe.current(e.startPage??0)):ut.controlAction&&mt(ut.controlAction)});const[i,r]=B.useState(!1),[s,l]=B.useState(e.initiallyShowAppBar),[,c]=B.useState(0);B.useEffect(()=>{const ut=()=>{l(!0),c(Ut=>Ut+1)};return hh.subscribe(ut),()=>{hh.unsubscribe(ut)}},[]);const[h,m]=B.useState(e.startPage??0),[k,w]=B.useState([""]),[P,E]=B.useState(!1),[z,A]=B.useState(!1),[x,S]=B.useState(""),[N,L]=B.useState("Device16x9Portrait");B.useEffect(()=>{l(e.initiallyShowAppBar)},[e.initiallyShowAppBar]),B.useEffect(()=>{s?OT():KT()},[s]),B.useEffect(()=>{f(e.paused)},[e.paused]);const[j,f]=B.useState(e.paused),[U,_]=B.useState(!1),F=He.getBloomUiLanguage(),gt=F==="en"?[F]:[F,"en"],[dt,ot]=B.useState(gt);B.useEffect(()=>{j||(Gd=!1)},[j]);const[X,$]=B.useState(!1),[o,tt]=B.useState(!1),[v,Q]=B.useState(!1),[st,ft]=B.useState(!1),[D,lt]=B.useState(!1),[pt,Ct]=B.useState(0),[St,Dt]=B.useState(9/16),Ht=[],[Vt,Gt]=B.useState(Ht),[Se,dn]=B.useState(""),Qe=B.useRef(),[be,me]=B.useState(!0),[Ue,Tt]=B.useState(!1),[Ce,Kn]=B.useState(!1),[We,T]=B.useState(0),I=()=>{T(ut=>ut+1)},[W,Z]=B.useState("");B.useEffect(()=>{Ft()},[D,We,X,e.useOriginalPageSize]),B.useEffect(()=>()=>{const ut=document.getElementById("scale-style-sheet");ut&&ut.parentNode.removeChild(ut)},[]);const nt=B.useRef(),mt=ut=>{switch(ut){case"navigate-to-next-page":nt&&nt.current&&nt.current.slideNext();break;case"navigate-to-previous-page":nt&&nt.current&&nt.current.slidePrevious();break;default:console.log("'handleControlMessage' received an unknown message.");return}},Ft=()=>{const ut=document.getElementsByClassName("swiper-slide-active")[0];let Ut=null;if(ut&&(Ut=ut.getElementsByClassName("bloom-page")[0]),!Ut||!D){window.setTimeout(I,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 Jt=pt,te=St;const Et=Te.getPageSizeClass(Ut);(e.url!==x||Et!==N)&&(S(e.url),L(Et),window.onresize=()=>{const{width:ua,height:Ta}=by();(Ta!==yy||ua!==vy)&&I()},Jt=Math.max(Ut.offsetHeight,Ut.offsetWidth),te=Math.min(Ut.offsetHeight,Ut.offsetWidth)/Jt,Dt(te),Ct(Jt));const{width:Lt,height:Qt}=by();vy=Lt,yy=Qt;const we=Lt>Qt;if(we!==X){$(we);return}let fe=0,xn=0;const re=window.getComputedStyle(document.body);re&&re.marginTop&&(fe=parseInt(re.marginTop,10)),re&&re.marginBottom&&(xn=parseInt(re.marginBottom,10));const Ha=Ut.getAttribute("class").indexOf("Landscape")>=0,fn=Ha?Jt*te:Jt,la=Ha?Jt:Jt*te;let Un=fe+xn;if(s){const ua=document.getElementById("control-bar");ua&&(Un+=ua.offsetHeight);const Ta=document.getElementById("pageNumberControl");Ta&&(Un+=Ta.offsetHeight)}const si=Qt-Un,yr=se({pageWidth:la,pageHeight:fn,desiredPageHeight:si}),Fa=le(la);let de=Math.min(yr,Fa);const Sa=fn*de;let li=Sa*te/de;Ha&&(li=Sa/te/de);const Yn=Lt/de-li;let Ca="",Wa=Math.max((Lt-la*de)/2,0);e.roundMarginToNearestK&&(Wa=Vd(Wa,e.roundMarginToNearestK));const co=Wa,lc=de,qs=30;if(Yn>100*2)Ca="largeOutsideButtons";else if(Yn>qs*2)Ca="smallOutsideButtons";else if(Lt>407&&navigator.userAgent.includes("Chrome")&&!e.hideSwiperButtons){const Ta=new RegExp(" Chrome/([0-9]+).").exec(navigator.userAgent),fo=parseInt(Ta[1]);fo&&fo<90&&(de*=.9,Wa=Math.max((Lt-la*de)/2,0),Ca="smallOutsideButtons extraScalingForChrome85Bug")}Ca!==W&&Z(Ca);let br="";if(a){const ua=(Qt-Sa-Un)/2;ua>0&&(br=`translate(0, ${ua.toFixed(0)}px) `)}qe.innerText=`.bloomPlayer {
|
|
8047
|
+
`,"").replace("\r","")}const sc=[];function DB(){return sc.length>0}function jB(e){const t=sc.pop();if(t)return{bookUrl:e===t.bookId?void 0:fh(t.bookId),pageId:t.pageId}}function RB(e,t,n){const a=e.target.closest("[href], [data-href]");if(!a)return;e.preventDefault(),e.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=sc.pop();return c?{bookUrl:t===c.bookId?void 0:fh(c.bookId),pageId:c.pageId}:void 0}else if(i.startsWith("/book/")){const c=OB(i);r=c.bookId,s=c.pageId,c.bookId===t&&(r=void 0)}else i.startsWith("#")&&(s=i.substring(1));const l=n();if(r)return dy(t,l),{bookUrl:fh(r),pageId:s};if(s)return dy(t,l),{pageId:s}}function dy(e,t,n){sc.push({bookId:e,pageId:t})}function fh(e){return`/book/${e}/index.htm`}function OB(e){try{const t=new URL(e,window.location.origin);if(!t.pathname.startsWith("/book/"))throw new Error("Invalid book URL format");const n=t.pathname.replace("/book/",""),a=t.hash.replace("#","");return{bookId:n,pageId:a}}catch(t){return console.error("Error parsing book URL:",t),{bookId:void 0,pageId:void 0}}}const KB="bloom-player",$B="A library for displaying Bloom books in iframes or WebViews",qB="SIL Global",HB="MIT",FB="2.19.5-alpha.1",WB=!1,_B={type:"git",url:"git+https://github.com/BloomBooks/bloom-player.git"},VB="module",GB="lib/shared.es.js",UB="lib/index.d.ts",YB={".":{types:"./lib/index.d.ts",import:"./lib/shared.es.js",default:"./lib/shared.es.js"}},XB={"// 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"},ZB={"@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"},JB={"@crowdin/cli":"^4.13.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",glob:"^10",husky:"8.0.3",jsdom:"^25.0.1",less:"^4.2.0",prettier:"^3.3.3",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"},QB=["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"],tI={node:"24.13.0",yarn:"1.22.19"},eI={name:KB,description:$B,author:qB,license:HB,version:FB,private:!1,"// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working":"",sideEffects:WB,repository:_B,type:VB,module:GB,types:UB,exports:YB,scripts:XB,dependencies:ZB,devDependencies:JB,"// The four src/ files are directly exported so BloomDesktop can consume them as shared code.":"",files:QB,volta:tI},vi="#d65649",nI="#2e2e2e",aI="#febf00",Zk=gs({palette:{primary:{main:nI,contrastText:vi},secondary:{main:vi}}});function Jk(){var e=eI.version;return e}const iI=({getBookInstanceId:e})=>{const[t,n]=B.useState(!1),a=Jk(),i=new Date("2026-04-02T14:57:33.893Z").toLocaleDateString();if(B.useEffect(()=>{const s=c=>{c.key==="Control"&&n(!0)},l=c=>{c.key==="Control"&&n(!1)};return window.addEventListener("keydown",s),window.addEventListener("keyup",l),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",l)}},[]),!t)return null;const r=e==null?void 0:e();return wt.createElement("div",{className:"diagnostic-info-control",style:{color:vi,fontFamily:"sans-serif",padding:"5px",zIndex:1e3,lineHeight:"1.5"}},wt.createElement("div",null,"Bloom Player v",a," (built ",i,")"),wt.createElement("div",null,"Book ID: ",r??""))},rI=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,fy=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");const t=e.match(rI);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},hy=e=>e==="*"||e==="x"||e==="X",py=e=>{const t=parseInt(e,10);return isNaN(t)?e:t},oI=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],sI=(e,t)=>{if(hy(e)||hy(t))return 0;const[n,a]=oI(py(e),py(t));return n>a?1:n<a?-1:0},gy=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){const a=sI(e[n]||"0",t[n]||"0");if(a!==0)return a}return 0},my=(e,t)=>{const n=fy(e),a=fy(t),i=n.pop(),r=a.pop(),s=gy(n,a);return s!==0?s:i&&r?gy(i.split("."),r.split(".")):i||r?i?-1:1:0},hh=new ur;class Te extends B.Component{constructor(t,n){super(t,n),this.activityManager=new az,this.initialPages=["loading..."],this.initialStyleRules="",this.originalPageClass="Device16x9Portrait",this.bookInfo=new dh,this.bookInteraction=new LB,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===Te.currentPage&&this.playAudioAndAnimation(i.page)},this.handlePlayFailed=()=>{this.setState({inPauseForced:!0}),this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!0)},this.handlePlayCompleted=()=>{Tn(Ge.MediaFinished),this.props.imageDescriptionCallback(!1)},this.handleToggleImageDescription=i=>{this.props.imageDescriptionCallback(i)},this.handlePageNarrationComplete=i=>{if(i&&(Tn(Ge.MediaFinished),this.shouldAutoPlay())){const r=this.props.autoplayCount??0,s=this.state.startPageIndex??0,l=this.swiperInstance.slides.length-1;let c=this.props.autoplayCount?Math.min(s+r-1,l):l;this.swiperInstance.activeIndex>=c?(this.music.pause(),this.props.shouldReportSoundLog&&YC(),GC(),DT({})):this.swiperInstance.slideNext()}},this.skipAutoPlay=!1,this.sentBloomNotification=!1;const a=t.url.startsWith("http")?new URL(t.url):new URL(t.url,window.location.origin);a.hash?(this.state.startPageId=a.hash.substring(1),a.hash=""):this.state.startPageIndex=t.startPageIndex,this.state.bookUrl=a.href,Te.currentPagePlayer=this,this.legacyQuestionHandler=new rz(t.locationOfDistFolder)}componentDidMount(){He.setUp(),window.addEventListener("focus",()=>this.handleWindowFocus()),window.addEventListener("blur",()=>this.handleWindowBlur()),document.addEventListener("keydown",t=>this.handleDocumentLevelKeyDown(t)),document.addEventListener("pointerdown",t=>{(t.target.closest("[href], [data-href]")||t.target.closest(".bloom-videoContainer")&&!t.target.closest("[data-draggable-id]"))&&(t.stopPropagation(),t.preventDefault())},{capture:!0}),document.addEventListener("dragstart",t=>{this.activityManager.getActivityAbsorbsDragging()||t.preventDefault()},{capture:!0}),this.componentDidUpdate(this.props,this.state)}CanGoBack(){return DB()}HandleBackButtonClickedIfHavePlayerHistory(){const t=this.getBookIdFromBookUrlForHistory(this.state.bookUrl)||this.bookInfo.bookInstanceId,n=jB(t);return n?(this.navigate(n.bookUrl,n.pageId),!0):!1}navigate(t,n){if(t){const a=new URL(t,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)}}getBookIdFromBookUrlForHistory(t){if(t)try{const a=new URL(t,window.location.href).pathname.match(/^\/book\/([^/]+)\/index\.htm$/i);return a?a[1]:void 0}catch{return}}handleWindowFocus(){const t=localStorage.getItem(Fl),n=localStorage.getItem(im);t&&n==this.sourceUrl&&(this.bookInteraction.beginReadTime=Date.now()-parseInt(t,10))}handleWindowBlur(){const t=Date.now()-this.bookInteraction.beginReadTime;localStorage.setItem(Fl,t.toString()),localStorage.setItem(im,this.sourceUrl)}getRequiredVersionMessage(t){var c;const n=(c=t.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||my(h,r)>0)&&(r=h,s=i[2])}if(!r||!s)return"";const l=Jk();if(my(l,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=pa("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(t,n){var a;try{if(!this.props.url||this.state.loadFailed&&n.bookUrl===this.state.bookUrl)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 l;r>s?l=this.sourceUrl.substring(r+1,this.sourceUrl.length):l=this.sourceUrl.substring(s+3,this.sourceUrl.length);const c=l.endsWith(".htm"),h=c?this.sourceUrl:this.sourceUrl+"/"+l+".htm";this.urlPrefix=c?this.sourceUrl.substring(0,Math.max(r,s)):this.sourceUrl,this.music.urlPrefix=this.urlPrefix,pC(this.music.urlPrefix);const m=ei.get(this.fullUrl(".distribution")).then(P=>P,P=>({data:""})),k=ei.get(h),w=ei.get(this.fullUrl("meta.json"));Promise.all([k,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=Te.getPageSizeClass(f)),this.legacyQuestionHandler.generateQuizPagesFromLegacyJSON(this.urlPrefix,j,this.originalPageClass,()=>{this.finishUp()})}).catch(P=>this.HandleLoadingError(P))}else if(t.landscape!==this.props.landscape||t.useOriginalPageSize!==this.props.useOriginalPageSize||t.autoplay!==this.props.autoplay){const r=document.getElementsByClassName("bloom-page");for(let s=0;s<r.length;s++){const l=r[s];this.setPageSizeClass(l)}}!this.state.isLoading&&(n.isLoading||t.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(Up).forEach(r=>{const s=zs(r).getNiceScroll();s&&s.length>0&&s.remove()})),!this.state.isLoading&&(n.isLoading||t.shouldReadImageDescriptions!==this.props.shouldReadImageDescriptions)&&this.finishUpCalled&&(this.setIndex(this.state.currentSwiperIndex),this.showingPage(this.state.currentSwiperIndex)),this.state.isFinishUpForNewBookComplete&&t.landscape!==this.props.landscape&&(this.setIndex(this.state.currentSwiperIndex),this.showingPage(this.state.currentSwiperIndex)),t.paused!==this.props.paused&&this.handlePausePlay(),this.swiperInstance&&this.swiperInstance.lazy.load()}catch(i){this.setState({isLoading:!1,loadFailed:!0,loadErrorHtml:i.message})}}collectBodyAttributes(t){for(var n={},a=0;a<t.attributes.length;a++)n[t.attributes.item(a).nodeName]=t.attributes.item(a).nodeValue;this.setState({importedBodyAttributes:n})}HandleLoadingError(t){var r;let a=`<p>There was a problem displaying this book: ${t.message}<p>`;const i=!!((r=t.config)!=null&&r.url)&&new URL(t.config.url,window.location.href).pathname.startsWith("/book/");i?a="<p>We could not find that book.</p>":(t.config&&t.config.url&&t.config.url.startsWith("file://")||t.message.indexOf("404")>=0)&&(a="<p>This book (or some part of it) was not found.<p>",t.config&&t.config.url&&(a+=`<p class='errorDetails'>${lI(t.config.url)}</p>`)),this.setState({isLoading:!1,loadFailed:!0,loadErrorHtml:a}),i&&hh.raise()}async finishUp(t=!0){if(this.finishUpCalled=!0,!this.htmlElement)return;Uo.setAllVideoPostersTo1x1TransparentPNG(this.htmlElement);const n=this.htmlElement.getElementsByClassName("bloom-page"),a=[];t&&(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={},l=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],k=m.getAttribute("id");k&&(s[k]=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}),t&&(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=l(m);P&&this.activityManager.initializePageHtml(this.urlPrefix,m,a.length),(!this.props.skipActivities||!P)&&a.push(m.outerHTML)}if(t){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 k=hs.createLangDataArrayFromDomAndMetadata(m,this.metaDataObject);this.hasImageDescriptions=uI(m),this.props.controlsCallback(k,this.hasImageDescriptions,w=>{var P;(P=this.swiperInstance)==null||P.slideTo(w)})}}if(t){var c;try{c=await zB(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(),t?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 k=document.getElementsByClassName("swiper-button-next")[0],w=document.getElementsByClassName("swiper-button-prev")[0];w==null||w.setAttribute("tabindex","4"),k==null||k.setAttribute("tabindex","5"),this.shouldFocusNextButtonForNewBook()&&(k==null||k.focus())},500):Te.currentPage&&window.setTimeout(()=>{this.setIndex(Te.currentPageIndex),this.showingPage(Te.currentPageIndex)},200)}shouldFocusNextButtonForNewBook(){return window.self===window.top||document.referrer.startsWith("http://localhost:")?!0:document.referrer.includes("bloomlibrary.org/player/")}showOrHideL1OnlyText(t,n){t.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 Rl),ta.subscribe(this.handlePageNarrationComplete),Ar.subscribe(this.handlePlayFailed),Ja.subscribe(this.handlePlayCompleted),dC(this.storeAudioAnalytics.bind(this)),La.subscribe(this.handleToggleImageDescription.bind(this)),fC(()=>{var t;return(t=this.swiperInstance)==null?void 0:t.animating}),hC(t=>Jy(t,1)),this.music||(this.music=new XC,this.music.PlayFailed=new ur,this.music.PlayFailed.subscribe(()=>{this.setState({inPauseForced:!0}),this.props.setForcedPausedCallback&&this.props.setForcedPausedCallback(!0)}))}preprocessUrl(){let t=this.state.bookUrl;if(t===void 0||t.trim()==="")throw new Error("The url parameter was empty. It should point to the url of a book.");return t.endsWith("/")&&(t=t.substring(0,t.length-1)),t.endsWith("%2f")&&(t=t.substring(0,t.length-3)),t}handlePausePlay(){this.props.paused?this.pauseAllMultimedia():Te.currentPage!==Ky()||mn===Ge.MediaFinished?this.resetForNewPageAndPlay(Te.currentPage):mn===Ge.VideoPaused?this.video.play():($C(),this.animation.resumeAnimation(),this.music.play())}getAllBloomCanvasElementsOnPage(){var a,i;const t=(a=this.htmlElement)==null?void 0:a.ownerDocument.getElementsByClassName("bloom-canvas");if(t&&t.length>0)return Array.from(t);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(t){return this.props.useOriginalPageSize||t.querySelector(".bloom-canvas-element")?!0:!!t.querySelector(".bloom-textOverPicture")}updateOverlayPositionsByLangCode(){if(!(!this.props.activeLanguageCode||!this.htmlElement))try{const t=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")===t);if(r){const s=r.getAttribute("data-bubble-alternate");if(s){const l=JSON.parse(s.replace(/`/g,'"'));i.setAttribute("style",l.style)}}});const a=Array.from(n.getElementsByClassName("comical-alternate")).find(i=>i.getAttribute("data-lang")===t);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(t){console.error(t)}}updateDivVisibilityByLangCode(t){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 l=0;l<r.snapshotLength;l++){const c=r.snapshotItem(l),h=c.getAttribute("data-default-languages"),m=h?h.split(/,| /):[],k=m==null||m.length===0||!m[0]||m.includes("V")||m.includes("L1")||Te.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")||(t&&E.setAttribute("data-original-class",E.getAttribute("class")||""),a?E.setAttribute("class",E.getAttribute("data-original-class")||""):k&&(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(t,n){return t.localeCompare(n,"en-US",{sensitivity:"accent"})===0}static isDivInL2(t){return t.classList.contains("bloom-contentNational1")}static isDivInL3(t){return t.classList.contains("bloom-contentNational2")}componentWillUnmount(){this.pauseAllMultimedia(),document.removeEventListener("keydown",t=>this.handleDocumentLevelKeyDown(t)),this.unsubscribeAllEvents()}unsubscribeAllEvents(){this.video.PageVideoComplete.unsubscribe(this.handlePageVideoComplete),ta.unsubscribe(this.handlePageNarrationComplete),Ar.unsubscribe(this.handlePlayFailed),Ja.unsubscribe(this.handlePlayCompleted),La.unsubscribe(this.handleToggleImageDescription)}pauseAllMultimedia(){mn===Ge.VideoPlaying?this.video.pause():mn===Ge.AudioPlaying&&(qC(),this.animation.PauseAnimation()),this.music.pause()}reportBookOpened(t){const n=this.bookInfo.getAmbientAnalyticsProps();this.distributionSource&&(n.distributionSource=this.distributionSource),BT(n),tb("BookOrShelf opened",{})}sendUpdateOfBookProgressReportToExternalContext(){const t=this.bookInteraction.getProgressReportPropertiesForAnalytics();jT("Pages Read",t)}makeNonEditable(t){const n=t.ownerDocument.evaluate(".//*[@contenteditable]",t,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(let a=0;a<n.snapshotLength;a++)n.snapshotItem(a).removeAttribute("contenteditable")}setPageSizeClass(t){return Te.setPageSizeClass(t,this.bookInfo.canRotate,this.props.landscape,this.mustUseOriginalPageSize,this.originalPageClass)}static getPageSizeClass(t){const a=(t.getAttribute("class")||"").match(/\b\S*?(Portrait|Landscape)\b/);return a&&a.length?a[0]:""}static setPageSizeClass(t,n,a,i,r){let s=!1;const l=this.getPageSizeClass(t);if(l){s=n?a:l.endsWith("Landscape");let c="";i?c=s?r.replace("Portrait","Landscape"):r.replace("Landscape","Portrait"):c=s?"Device16x9Landscape":"Device16x9Portrait",l!==c&&(t.classList.remove(l),t.classList.add(c))}return s}goToFirstPage(){this.swiperInstance.slideTo(0)}goToLastPage(){this.swiperInstance.slideTo(99999)}fixRelativeUrls(t){const n=t.ownerDocument.evaluate(".//*[@src]",t,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(let r=0;r<n.snapshotLength;r++){const s=n.snapshotItem(r);if(!s)continue;const l=s.getAttribute("src"),c=this.fullUrl(l);s.setAttribute("src",c)}const a=t.ownerDocument.evaluate(".//*[@style]",t,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 l=s.getAttribute("style")||"",c=i.exec(l);if(!c)continue;const h=this.fullUrl(c[1]),m=l.replace(i,"");s.setAttribute("style",m),s.setAttribute("data-background",h),s.classList.add("swiper-lazy")}}fullUrl(t){return this.urlPrefix+"/"+t}getRootDiv(){return this.rootDiv}slideNext(){this.swiperInstance&&this.swiperInstance.slideNext()}slidePrevious(){this.swiperInstance&&this.swiperInstance.slidePrev()}getBookInstanceId(){return this.bookInfo.bookInstanceId}getPlayerOptionsForPage(t){if(!t)return;let n=t.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 t=this.activityManager.getActivityAbsorbsDragging();if(this.state.isLoading)return B.createElement(Pz,{className:"loadingSpinner",color:"secondary"});if(this.state.loadFailed)return B.createElement(B.Fragment,null,B.createElement(mk,{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);wC(this.props.shouldReadImageDescriptions&&this.hasImageDescriptions);const n={getSwiper:r=>{var s,l;this.swiperInstance=r,(s=this.metaDataObject)!=null&&s.isRtl&&this.swiperInstance&&((l=this.swiperInstance.el)==null||l.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),t&&(a+=" showNavigationButtonsEvenOnTouchDevices")),B.createElement("div",{"aria-label":"Player Content",className:a+(this.props.extraClassNames?" "+this.props.extraClassNames:""),ref:r=>this.rootDiv=r},B.createElement(lC,{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(Ma,{className:"nav-button",disableRipple:!0},this.metaDataObject.isRtl?B.createElement(oh,{titleAccess:He.getTranslation("Button.Prev",this.props.preferredUiLanguages,"Previous Page")}):B.createElement(rh,{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(Ma,{className:"nav-button",disableRipple:!0},this.metaDataObject.isRtl?B.createElement(rh,{titleAccess:He.getTranslation("Button.Next",this.props.preferredUiLanguages,"Next Page")}):B.createElement(oh,{titleAccess:He.getTranslation("Button.Next",this.props.preferredUiLanguages,"Next Page")}))))}shouldAutoPlay(){var t=this.bookInfo.autoAdvance&&this.props.landscape;return this.props.autoplay==="yes"?t=!0:this.props.autoplay==="no"&&(t=!1),t&&!this.skipAutoPlay}setIndex(t){if(this.state.isLoading||this.startingUpSwiper)return;this.setState({currentSwiperIndex:t});const n=this.getPageAtSwiperIndex(t);n&&(this.setPageSizeClass(n),this.animation.HandlePageBeforeVisible(n),this.video.hidingPage(),this.video.HandlePageBeforeVisible(n),FC(),this.music.hidingPage(),mn===Ge.AudioPaused||mn===Ge.VideoPaused?Tn(Ge.NewPageMediaPaused):(this.skipAutoPlay=!0,zC(),this.skipAutoPlay=!1,Tn(Ge.NewPage)))}getPageAtSwiperIndex(t){if(this.swiperInstance==null)return null;const n=this.swiperInstance.slides[t];return n?n.getElementsByClassName("bloom-page")[0]:null}getPageIdFromIndex(t){const n=this.getPageAtSwiperIndex(t);if(!n)throw new Error("No bloomPage at index "+t);return n.getAttribute("id")}static getCurrentPage(){return Te.currentPage}isXmatterPage(){const t=Te.currentPage;if(!t)return!0;const n=t.getAttribute("class");return!n||n.indexOf("bloom-page")<0||n.indexOf("bloom-backMatter")>=0||n.indexOf("bloom-frontMatter")>=0?!0:t.hasAttribute("data-xmatter-page")}showingPage(t){if(this.state.isLoading||this.startingUpSwiper)return;this.props.pageChanged&&this.props.pageChanged(t);const n=this.getPageAtSwiperIndex(t);if(!n){window.setTimeout(()=>this.showingPage(t),50);return}const a=this.getPlayerOptionsForPage(n);this.currentPageHidesNavigationButtons=!!(a&&a.hideNavigation),this.props.hidingNavigationButtonsCallback&&this.props.hidingNavigationButtonsCallback(this.currentPageHidesNavigationButtons),this.activityManager.showingPage(t,n)&&(this.indicesOfPagesWhereWeShouldPreserveDOMState[t]=!0),window.setTimeout(()=>{Te.currentPage=n,Te.currentPageIndex=t,Te.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.props.paused),this.animation.HandlePageDurationAvailable(n,em(n),this.props.paused)),this.isXmatterPage()||(this.bookInteraction.pageShown(t),t===this.indexOflastNumberedPage&&(this.bookInteraction.lastNumberedPageWasRead=!0)),this.props.reportPageProperties&&this.props.reportPageProperties({hasAudio:KC(n),hasMusic:this.music.pageHasMusic(n),hasVideo:Te.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",_p)})},0)}addScrollbarsToPageWhenReady(t){if(this.state.isLoading||this.startingUpSwiper)return;const n=this.getPageAtSwiperIndex(t);if(!n){window.setTimeout(()=>this.addScrollbarsToPageWhenReady(t),50);return}$L(n,Te.handlePointerMoveEvent)}static handlePointerMoveEvent(t){var n;t.pointerType==="mouse"&&((n=t.target)!=null&&n.closest(".nicescroll-cursors"))&&t.stopPropagation()}storeAudioAnalytics(t){t<.001||Number.isNaN(t)||(this.bookInteraction.totalAudioDuration+=t,!this.isXmatterPage()&&(this.bookInteraction.reportedAudioOnCurrentPage||(this.bookInteraction.reportedAudioOnCurrentPage=!0,this.bookInteraction.audioPageShown(Te.currentPageIndex)),this.sendUpdateOfBookProgressReportToExternalContext()))}static storeVideoAnalytics(t){if(t<.001)return;const n=Te.currentPagePlayer;n.bookInteraction.totalVideoDuration+=t,!n.bookInteraction.reportedVideoOnCurrentPage&&!n.isXmatterPage()&&(n.bookInteraction.reportedVideoOnCurrentPage=!0,n.bookInteraction.videoPageShown(Te.currentPageIndex)),n.sendUpdateOfBookProgressReportToExternalContext()}resetForNewPageAndPlay(t){if(this.props.paused){this.video.HandlePageVisible(t,()=>this.props.paused);return}if(Oy(t),Te.currentPageHasVideo){const n=()=>{this.video.HandlePageVisible(t,()=>this.props.paused),this.music.pause()};if(Tn(Ge.VideoPlaying),!this.sentBloomNotification&&(this.sentBloomNotification=!0,this.props.shouldReportSoundLog)){ef("/publish/av/startRecording",this.videoList).then(n);return}n()}else this.playAudioAndAnimation(t)}playAudioAndAnimation(t){if(this.activityManager.getActivityManagesSound()){this.activityManager.doInitialSoundAndAnimation();return}if(Tn(Ge.AudioPlaying),!t)return;const n=em(t);this.animation.HandlePageDurationAvailable(t,n,this.props.paused);const a=()=>{Rl.pageHasAnimation(t)&&this.animation.HandlePageBeforeVisible(t),this.animation.HandlePageVisible(t,this.props.paused),qy(t,this.animation.animatableCanvas),this.music.HandlePageVisible(t)};if(!this.sentBloomNotification&&(this.sentBloomNotification=!0,this.props.shouldReportSoundLog)){ef("/publish/av/startRecording",this.videoList).then(a);return}a()}getVideoList(t){let n="";for(const r of Array.from(t.getElementsByTagName("video"))){var a=r,i=a.getElementsByTagName("source")[0].getAttribute("src");n&&(n+="|"),n+=i}return n}handlePageClick(t){if(!this.state.ignorePhonyClick&&(!this.activityManager.getActivityAbsorbsClicking()||t.target.closest("[data-href]")&&t.target.closest(".bloom-canvas"))&&!t.target.closest(".bloom-videoContainer")){const n=RB(t.nativeEvent,this.bookInfo.bookInstanceId,()=>this.getPageIdFromIndex(this.state.currentSwiperIndex));n?(this.navigate(n.bookUrl,n.pageId),t.stopPropagation(),t.preventDefault()):this.props.onContentClick&&this.props.onContentClick(t)}this.setState({ignorePhonyClick:!1})}}function lI(e){return e.replace("%23","#").replace(/[\u00A0-\u9999<>\&]/gim,t=>"&#"+t.charCodeAt(0)+";")}function uI(e){return e.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')]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength>0?!0:e.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()]",e,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength>0}var Yp={},cI=ya,dI=ba;Object.defineProperty(Yp,"__esModule",{value:!0});var Qk=Yp.default=void 0,fI=dI(Mn()),hI=cI(wa()),pI=(0,hI.default)(fI.createElement("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"}),"ArrowBack");Qk=Yp.default=pI;var Xp={},gI=ya,mI=ba;Object.defineProperty(Xp,"__esModule",{value:!0});var t0=Xp.default=void 0,vI=mI(Mn()),yI=gI(wa()),bI=(0,yI.default)(vI.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");t0=Xp.default=bI;var Zp={},wI=ya,kI=ba;Object.defineProperty(Zp,"__esModule",{value:!0});var Jp=Zp.default=void 0,xI=kI(Mn()),SI=wI(wa()),CI=(0,SI.default)(xI.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");Jp=Zp.default=CI;var Qp={},TI=ya,EI=ba;Object.defineProperty(Qp,"__esModule",{value:!0});var e0=Qp.default=void 0,PI=EI(Mn()),MI=TI(wa()),AI=(0,MI.default)(PI.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");e0=Qp.default=AI;var tg={},NI=ya,LI=ba;Object.defineProperty(tg,"__esModule",{value:!0});var n0=tg.default=void 0,zI=LI(Mn()),BI=NI(wa()),II=(0,BI.default)(zI.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");n0=tg.default=II;var eg={},DI=ya,jI=ba;Object.defineProperty(eg,"__esModule",{value:!0});var a0=eg.default=void 0,RI=jI(Mn()),OI=DI(wa()),KI=(0,OI.default)(RI.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"}),"Fullscreen");a0=eg.default=KI;var ng={},$I=ya,qI=ba;Object.defineProperty(ng,"__esModule",{value:!0});var i0=ng.default=void 0,HI=qI(Mn()),FI=$I(wa()),WI=(0,FI.default)(HI.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}),"FullscreenExit");i0=ng.default=WI;function _I(e){return wt.createElement(ih,{...e,width:"21",height:"20",viewBox:"0 0 21 20"},wt.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 ag={},VI=ya,GI=ba;Object.defineProperty(ag,"__esModule",{value:!0});var r0=ag.default=void 0,UI=GI(Mn()),YI=VI(wa()),XI=(0,YI.default)(UI.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");r0=ag.default=XI;const ZI=e=>{const[t,n]=B.useState((e.languages.filter(s=>s.IsSelected)[0]||e.languages[0]).Code),a=s=>{const l=s.target.value;n(l),e.onClose(l)},i=()=>{e.onClose("")},r=()=>{const s=e.languages.map(l=>wt.createElement("div",{className:"chooserItem",key:l.Code},wt.createElement(rB,{value:l.Code,control:wt.createElement(yB,null),label:l.Name,checked:l.Code===t}),wt.createElement("span",{className:"spacer"}),wt.createElement(r0,{className:"icon",visibility:l.HasAudio?"inherit":"hidden"})));return wt.createElement("div",{className:"radioGroupDiv"},s)};return wt.createElement(_z,{className:"languageMenu",onClose:i,"aria-labelledby":"language-menu-title",open:!0,scroll:"paper"},wt.createElement(Zz,{id:"language-menu-title"},"Languages in this book:"),wt.createElement(nB,{component:"fieldset"},wt.createElement(bB,{className:"radioGroup","aria-label":"languages",name:"languages",value:t,onChange:a},r())),wt.createElement(Uz,null,wt.createElement(kz,{onClick:i,color:"secondary"},"Close")))};var _o=(e=>(e[e.showArrow=0]="showArrow",e[e.showEllipsis=1]="showEllipsis",e[e.showNothing=2]="showNothing",e))(_o||{});const JI=e=>{const[t,n]=B.useState(!1),a="button"+(e.bookLanguages.length<2?" disabled":""),i=E=>{n(!1),E!==""&&(e.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(!e.videoPreviewMode)return;const z={lang:e.activeLanguageCode,imageDescriptions:e.readImageDescriptions,...E};ef("publish/av/videoSettings",encodeURIComponent(JSON.stringify(z)))},l=He.getTranslation("Audio.Pause",e.preferredLanguages,"Pause"),c=e.paused?wt.createElement(Jp,{titleAccess:e.playLabel}):wt.createElement(e0,{titleAccess:l}),h=He.getTranslation("Button.ReadImageDescriptions",e.preferredLanguages,"Read Image Descriptions"),m=He.getTranslation("Button.IgnoreImageDescriptions",e.preferredLanguages,"Ignore Image Descriptions"),k=gs({palette:{primary:{main:aI},secondary:{main:Zk.palette.secondary.main}}}),w=wt.createElement(Gl,{theme:k},wt.createElement(_I,{"aria-label":e.readImageDescriptions?"Read image descriptions":"Ignore image descriptions",titleAccess:e.readImageDescriptions?m:h,opacity:e.readImageDescriptions?1:.38,color:e.nowReadingImageDescription?"primary":"secondary"})),P=e.extraButtons?e.extraButtons.map(E=>wt.createElement(Ma,{key:E.id,color:"secondary",title:E.description,onClick:()=>$a({messageType:E.id})},wt.createElement("img",{style:{maxHeight:"24px",maxWidth:"24px"},src:E.iconUrl}))):void 0;return wt.createElement(dz,{color:"primary",className:`control-bar ${e.visible?", visible":""}`,id:"control-bar",elevation:0,position:"relative"},wt.createElement(NB,null,!e.videoPreviewMode&&wt.createElement(Ma,{color:"secondary",onClick:()=>{e.backClicked&&e.backClicked()},"data-testid":"history-back-button",disabled:e.getBackButtonState()===2},e.getBackButtonState()===0?wt.createElement(Qk,{"aria-label":"Go Back",titleAccess:He.getTranslation("Button.Back",e.preferredLanguages,"Back")}):e.getBackButtonState()===1&&wt.createElement(t0,{"aria-label":"More Menu",titleAccess:He.getTranslation("Button.More",e.preferredLanguages,"More")})),wt.createElement("div",{className:"filler"}),e.bookHasImageDescriptions&&wt.createElement(Ma,{onClick:()=>{e.onReadImageDescriptionToggled(),s({imageDescriptions:!e.readImageDescriptions})}},w),e.bookLanguages.length>1&&wt.createElement(Ma,{className:a,"aria-label":"Choose Language",color:"secondary",onClick:()=>{n(!0)}},wt.createElement(n0,{titleAccess:He.getTranslation("Button.ChooseLanguage",e.preferredLanguages,"Choose Language")})),t&&wt.createElement(ZI,{languages:e.bookLanguages,onClose:i}),!e.videoPreviewMode&&wt.createElement(Ma,{color:"secondary","aria-label":"PlayPause",onClick:()=>{e.pausedChanged&&e.pausedChanged(!e.paused)}},e.showPlayPause?c:null),P,document.fullscreenEnabled&&e.canShowFullScreen&&!e.videoPreviewMode&&wt.createElement(Ma,{color:"secondary",onClick:()=>r()},document.fullscreenElement==null?wt.createElement(a0,{"aria-label":"Full Screen",titleAccess:He.getTranslation("Button.FullScreen",e.preferredLanguages,"Full Screen")}):wt.createElement(i0,{"aria-label":"Exit Full Screen",titleAccess:He.getTranslation("Button.ExitFullScreen",e.preferredLanguages,"Exit Full Screen")}))))};function Vd(e,t){return Math.round(e/t)*t}function QI(e){if(!(!e||e==="cover")){if(/^\d+$/.test(e))return e;try{return e.replace(new RegExp("(?![0-9])\\p{Nd}","gu"),t=>{const n=t.charCodeAt(0);return(n&15)-6*(new RegExp("\\p{Nd}","u").test(String.fromCodePoint(n|15))?1:0)})}catch{return}}}let Gd=!1,ph=e=>{};function tD(e){ph&&ph(e)}let vy=0,yy=0;function by(){const e=/iPad|iPhone|iPod/.test(navigator.platform);let t,n,a;e&&(t=document.getElementsByClassName("bloomPlayer")[0],n=t.parentElement,a=t.nextSibling,n.removeChild(t));const i=document.documentElement.clientWidth,r=document.documentElement.clientHeight;return e&&n.insertBefore(t,a),{width:i,height:r}}const eD=e=>{const[t,n]=B.useState(e.autoplay),a=e.centerVertically===void 0?!0:e.centerVertically;qT(ut=>{ut.pause?(Gd=!j,f(!0)):ut.resume&&Gd?f(!1):ut.play?(f(!1),ut.autoplay&&n(ut.autoplay)):ut.reset?(m(e.startPage??0),Qe.current&&Qe.current(e.startPage??0)):ut.controlAction&&mt(ut.controlAction)});const[i,r]=B.useState(!1),[s,l]=B.useState(e.initiallyShowAppBar),[,c]=B.useState(0);B.useEffect(()=>{const ut=()=>{l(!0),c(Ut=>Ut+1)};return hh.subscribe(ut),()=>{hh.unsubscribe(ut)}},[]);const[h,m]=B.useState(e.startPage??0),[k,w]=B.useState([""]),[P,E]=B.useState(!1),[z,A]=B.useState(!1),[x,S]=B.useState(""),[N,L]=B.useState("Device16x9Portrait");B.useEffect(()=>{l(e.initiallyShowAppBar)},[e.initiallyShowAppBar]),B.useEffect(()=>{s?OT():KT()},[s]),B.useEffect(()=>{f(e.paused)},[e.paused]);const[j,f]=B.useState(e.paused),[U,_]=B.useState(!1),F=He.getBloomUiLanguage(),gt=F==="en"?[F]:[F,"en"],[dt,ot]=B.useState(gt);B.useEffect(()=>{j||(Gd=!1)},[j]);const[X,$]=B.useState(!1),[o,tt]=B.useState(!1),[v,Q]=B.useState(!1),[st,ft]=B.useState(!1),[D,lt]=B.useState(!1),[pt,Ct]=B.useState(0),[St,Dt]=B.useState(9/16),Ht=[],[Vt,Gt]=B.useState(Ht),[Se,dn]=B.useState(""),Qe=B.useRef(),[be,me]=B.useState(!0),[Ue,Tt]=B.useState(!1),[Ce,Kn]=B.useState(!1),[We,T]=B.useState(0),I=()=>{T(ut=>ut+1)},[W,Z]=B.useState("");B.useEffect(()=>{Ft()},[D,We,X,e.useOriginalPageSize]),B.useEffect(()=>()=>{const ut=document.getElementById("scale-style-sheet");ut&&ut.parentNode.removeChild(ut)},[]);const nt=B.useRef(),mt=ut=>{switch(ut){case"navigate-to-next-page":nt&&nt.current&&nt.current.slideNext();break;case"navigate-to-previous-page":nt&&nt.current&&nt.current.slidePrevious();break;default:console.log("'handleControlMessage' received an unknown message.");return}},Ft=()=>{const ut=document.getElementsByClassName("swiper-slide-active")[0];let Ut=null;if(ut&&(Ut=ut.getElementsByClassName("bloom-page")[0]),!Ut||!D){window.setTimeout(I,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 Jt=pt,te=St;const Et=Te.getPageSizeClass(Ut);(e.url!==x||Et!==N)&&(S(e.url),L(Et),window.onresize=()=>{const{width:ua,height:Ta}=by();(Ta!==yy||ua!==vy)&&I()},Jt=Math.max(Ut.offsetHeight,Ut.offsetWidth),te=Math.min(Ut.offsetHeight,Ut.offsetWidth)/Jt,Dt(te),Ct(Jt));const{width:Lt,height:Qt}=by();vy=Lt,yy=Qt;const we=Lt>Qt;if(we!==X){$(we);return}let fe=0,xn=0;const re=window.getComputedStyle(document.body);re&&re.marginTop&&(fe=parseInt(re.marginTop,10)),re&&re.marginBottom&&(xn=parseInt(re.marginBottom,10));const Ha=Ut.getAttribute("class").indexOf("Landscape")>=0,fn=Ha?Jt*te:Jt,la=Ha?Jt:Jt*te;let Un=fe+xn;if(s){const ua=document.getElementById("control-bar");ua&&(Un+=ua.offsetHeight);const Ta=document.getElementById("pageNumberControl");Ta&&(Un+=Ta.offsetHeight)}const si=Qt-Un,yr=se({pageWidth:la,pageHeight:fn,desiredPageHeight:si}),Fa=le(la);let de=Math.min(yr,Fa);const Sa=fn*de;let li=Sa*te/de;Ha&&(li=Sa/te/de);const Yn=Lt/de-li;let Ca="",Wa=Math.max((Lt-la*de)/2,0);e.roundMarginToNearestK&&(Wa=Vd(Wa,e.roundMarginToNearestK));const co=Wa,lc=de,qs=30;if(Yn>100*2)Ca="largeOutsideButtons";else if(Yn>qs*2)Ca="smallOutsideButtons";else if(Lt>407&&navigator.userAgent.includes("Chrome")&&!e.hideSwiperButtons){const Ta=new RegExp(" Chrome/([0-9]+).").exec(navigator.userAgent),fo=parseInt(Ta[1]);fo&&fo<90&&(de*=.9,Wa=Math.max((Lt-la*de)/2,0),Ca="smallOutsideButtons extraScalingForChrome85Bug")}Ca!==W&&Z(Ca);let br="";if(a){const ua=(Qt-Sa-Un)/2;ua>0&&(br=`translate(0, ${ua.toFixed(0)}px) `)}qe.innerText=`.bloomPlayer {
|
|
8048
8048
|
width: ${li}px;
|
|
8049
8049
|
transform-origin: left top 0;
|
|
8050
8050
|
transform: ${br}scale(${de});
|
|
@@ -8057,4 +8057,4 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
|
|
|
8057
8057
|
}
|
|
8058
8058
|
}
|
|
8059
8059
|
.bloomPlayer-page {height: ${Sa/de}px; overflow: hidden;}`,FL(Ut,de),i||r(!0)},se=ut=>{const{pageWidth:Ut,pageHeight:qe,desiredPageHeight:Jt}=ut,te=Jt/qe;if(!e.roundPageWidthToNearestK)return te;const Et=Ut*te;return Vd(Et,e.roundPageWidthToNearestK)/Ut},le=ut=>{let Ut=document.body.offsetWidth;return e.roundPageWidthToNearestK&&(Ut=Vd(Ut,e.roundPageWidthToNearestK)),Ut/ut};B.useEffect(()=>{U&&!j&&_(!1);const ut=document.getElementById("root");ut&&(ph=Ut=>{(Ut.key===" "||Ut.key==="ArrowRight"&&U)&&(Ut.preventDefault(),Ut.stopImmediatePropagation(),f(!j),_(!1))},ut.addEventListener("keydown",tD,{capture:!0}))});const Rt=ut=>{Se!==ut&&(hs.selectNewLanguageCode(Vt,ut),dn(ut))},Ie=(ut,Ut,qe)=>{Qe.current=qe;let Jt;if(e.videoSettings){const te=JSON.parse(e.videoSettings);Jt=te.lang,me(te.imageDescriptions??!1)}e.initialLanguageCode&&(Jt=e.initialLanguageCode),Jt&&ut.map(te=>te.Code).includes(Jt)?hs.selectNewLanguageCode(ut,Jt):Jt=ut.length>0?ut[0].Code:"",dn(Jt),Gt(ut),Tt(Ut),e.videoPreviewMode&&!s&&l(!0)},_e=He.getTranslation("Audio.Play",dt,"Play"),Nn=He.getTranslation("Audio.ReadAloud",dt,"Read Aloud"),tn=o?Nn:_e,{allowToggleAppBar:ka,showBackButton:xa,initiallyShowAppBar:Ye,locationOfDistFolder:Pt,hideFullScreenButton:on,...H}=e,zt=gs({palette:{primary:{main:"#000",contrastText:"#FFF"},secondary:{main:"#FFF"}}}),Xt=ut=>{Kn(ut)},Oe=Re({root:{color:vi,height:2,padding:"15px 0"},active:{},valueLabel:{left:"calc(50% - 16px)",top:-31,"& *":{background:vi,color:"white"}},track:{height:4,opacity:.5},rail:{height:2,opacity:.5,backgroundColor:vi},mark:{backgroundColor:"transparent"},markActive:{backgroundColor:"transparent"},markLabel:{top:20,fontSize:"0.6rem",color:vi},markLabelActive:{top:20,fontSize:"0.6rem",color:vi}})(PB),De=gs({direction:"rtl"}),ve=wt.createElement(Oe,{valueLabelDisplay:"on",min:1,max:k.length,step:1,disabled:z,defaultValue:h+1,onChangeCommitted:(ut,Ut)=>{Ut-1!=h&&(m(Ut-1),Qe.current&&Qe.current(Ut-1))},valueLabelFormat:(ut,Ut)=>k[ut-1],marks:[{value:k.length,label:k.length.toString()}]});return wt.createElement("div",{className:"reactRoot"},U&&wt.createElement(wt.Fragment,null,wt.createElement("div",{className:"bigButtonOverlay"},wt.createElement(Gl,{theme:zt},wt.createElement(Ma,{color:"secondary",onClick:()=>{_(!1),f(!1)}},wt.createElement(Jp,{titleAccess:tn,preserveAspectRatio:"xMidYMid meet"})))),wt.createElement("div",{className:"behindBigButtonOverlay"})),wt.createElement(JI,{getBackButtonState:()=>{var ut;return(ut=nt.current)!=null&&ut.CanGoBack()?_o.showArrow:xa?window===window.top?_o.showArrow:_o.showEllipsis:_o.showNothing},visible:s,paused:j,pausedChanged:ut=>f(ut),playLabel:tn,preferredLanguages:dt,backClicked:()=>{var ut;(ut=nt.current)!=null&&ut.HandleBackButtonClickedIfHavePlayerHistory()||RT()},showPlayPause:o||v||st,bookLanguages:Vt,activeLanguageCode:Se,onLanguageChanged:Rt,canShowFullScreen:!e.hideFullScreenButton,extraButtons:e.extraButtons,bookHasImageDescriptions:Ue,readImageDescriptions:be,onReadImageDescriptionToggled:()=>me(!be),nowReadingImageDescription:Ce,videoPreviewMode:e.videoPreviewMode}),wt.createElement(iI,{getBookInstanceId:()=>{var ut;return((ut=nt.current)==null?void 0:ut.getBookInstanceId())??""}}),wt.createElement(Te,{ref:nt,url:e.url,landscape:X,paused:j,preferredUiLanguages:dt,pageStylesAreNowInstalled:()=>{lt(!0)},locationOfDistFolder:e.locationOfDistFolder,reportBookProperties:ut=>{const Ut={landscape:ut.landscape,canRotate:ut.canRotate};IT(Ut),ot([F].concat(ut.preferredLanguages)),w(ut.pageNumbers),E(ut.isRtl),ut.internalUrl!=Ud&&(Ud&&I(),Ud=ut.internalUrl)},controlsCallback:Ie,setForcedPausedCallback:ut=>{ut?(f(ut),_(!0)):_(!1)},reportPageProperties:ut=>{tt(ut.hasAudio),Q(ut.hasMusic),ft(ut.hasVideo)},onContentClick:ut=>{e.allowToggleAppBar&&(l(!s),window.setTimeout(I,300+50))},activeLanguageCode:Se,useOriginalPageSize:e.useOriginalPageSize,hideSwiperButtons:e.hideSwiperButtons,autoplay:t,skipActivities:e.skipActivities,outsideButtonPageClass:W,extraClassNames:i?"":"hidePlayer",shouldReadImageDescriptions:be,imageDescriptionCallback:Xt,pageChanged:ut=>{ut!=h&&m(ut)},hidingNavigationButtonsCallback:ut=>{ut!=z&&A(ut)},shouldReportSoundLog:e.shouldReportSoundLog,startPageIndex:e.startPage,autoplayCount:e.autoplayCount}),s&&!e.videoPreviewMode&&wt.createElement("div",{id:"pageNumberControl",className:"MuiToolbar-gutters"},P?wt.createElement(Gl,{theme:De},ve):ve))};function nD(){const e=pa("extraButtons");if(!e)return[];const t=decodeURIComponent(e);try{return JSON.parse(t)}catch(n){return console.error("Failed to parse extra button info "+JSON.stringify(n)),$T("error decoding extraButtons param "+e+": "+n),[]}}function aD(){bC(parseFloat(pa("defaultDuration","3.0")));const e=pa("autoplay","motion"),t=pa("start-page"),n=QI(t),a=n?parseInt(n):void 0,i=pa("autoplay-count"),r=t?parseInt(i):void 0,s=Wn("paused",!1);qi.render(wt.createElement(Gl,{theme:Zk},wt.createElement(eD,{url:pa("url"),allowToggleAppBar:Wn("allowToggleAppBar",!1),showBackButton:Wn("showBackButton",!1),initiallyShowAppBar:Wn("initiallyShowAppBar",!0),centerVertically:Wn("centerVertically",!0),initialLanguageCode:pa("lang"),videoSettings:pa("videoSettings"),paused:s,locationOfDistFolder:"",useOriginalPageSize:Wn("useOriginalPageSize",!1),hideFullScreenButton:Wn("hideFullScreenButton",!1),autoplay:e,skipActivities:Wn("skipActivities",!1),videoPreviewMode:Wn("videoPreviewMode",!1),hideSwiperButtons:Wn("hideNavButtons",!1),extraButtons:nD(),shouldReportSoundLog:Wn("reportSoundLog",!1),startPage:a,autoplayCount:r,roundPageWidthToNearestK:am("roundPageWidthToNearestK"),roundMarginToNearestK:am("roundMarginToNearestK")})),document.getElementById("root"))}let Ud="";aD();
|
|
8060
|
-
//# sourceMappingURL=bloomPlayer.
|
|
8060
|
+
//# sourceMappingURL=bloomPlayer.D5vTzfdn.js.map
|
package/dist/bloomplayer.htm
CHANGED
|
@@ -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.
|
|
21
|
+
<script src="bloomPlayer.D5vTzfdn.js"></script>
|
|
22
22
|
</body>
|
|
23
23
|
|
|
24
24
|
|