(function(n){"use strict";function nr(n,t){var i=Object.create(n),r;for(r in t)i[r]=t[r];return t.toString!==Object.prototype.toString&&(i.toString=t.toString),i}function g(n){return n instanceof Array?new dt(n):n.iterator()}function b(t,i){if(i==null)return null;i.__id__==null&&(i.__id__=n.$haxeUID++);var r;return t.hx__closures__==null?t.hx__closures__={}:r=t.hx__closures__[i.__id__],r==null&&(r=i.bind(t),t.hx__closures__[i.__id__]=r),r}var et=function(){return i.__string_rec(this,"")},yt=yt||{},ft,oi=function(n,t){this.r=new RegExp(n,t.split("u").join(""))},nt,v,h,s,r,a,o,p,si,k,ot,ut,hi,tt,pt,ci,y,it,li,ai,vi,lt,c,ni,w,ti,d,at,wt,ii,st,yi,pi,bt,vt,ct,ri,kt,dt,i,ht,wi,bi,ki,ui,rt,t,fi,gi,u,e,gt,l,ei,f,tr,di;oi.__name__=!0;oi.prototype={match:function(n){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(n),this.r.s=n,this.r.m!=null},__class__:oi};nt=function(){};nt.__name__=!0;nt.cca=function(n,t){var i=n.charCodeAt(t);return i!=i?undefined:i};nt.substr=function(n,t,i){if(i==null)i=n.length;else if(i<0)if(t==0)i=n.length+i;else return"";return n.substr(t,i)};nt.now=function(){return Date.now()};v=function(){};v.__name__=!0;v.array=function(n){for(var t=[],i=g(n),r;i.hasNext();)r=i.next(),t.push(r);return t};v.list=function(n){for(var t=new st,i=g(n),r;i.hasNext();)r=i.next(),t.add(r);return t};v.map=function(n,t){for(var i=new st,r=g(n),u;r.hasNext();)u=r.next(),i.add(t(u));return i};v.mapi=function(n,t){for(var i=new st,f=0,r=g(n),u;r.hasNext();)u=r.next(),i.add(t(f++,u));return i};v.flatten=function(n){for(var i=new st,r=g(n),u,t,f;r.hasNext();)for(u=r.next(),t=g(u);t.hasNext();)f=t.next(),i.add(f);return i};v.flatMap=function(n,t){return v.flatten(v.map(n,t))};v.has=function(n,t){for(var i=g(n),r;i.hasNext();)if(r=i.next(),r==t)return!0;return!1};v.exists=function(n,t){for(var i=g(n),r;i.hasNext();)if(r=i.next(),t(r))return!0;return!1};v.foreach=function(n,t){for(var i=g(n),r;i.hasNext();)if(r=i.next(),!t(r))return!1;return!0};v.iter=function(n,t){for(var i=g(n),r;i.hasNext();)r=i.next(),t(r)};v.filter=function(n,t){for(var r=new st,u=g(n),i;u.hasNext();)i=u.next(),t(i)&&r.add(i);return r};v.fold=function(n,t,i){for(var r=g(n),u;r.hasNext();)u=r.next(),i=t(u,i);return i};v.count=function(n,t){var i=0,r,e,u,f;if(t==null)for(r=g(n);r.hasNext();)e=r.next(),++i;else for(u=g(n);u.hasNext();)f=u.next(),t(f)&&++i;return i};v.empty=function(n){return!g(n).hasNext()};v.indexOf=function(n,t){for(var i=0,r=g(n),u;r.hasNext();){if(u=r.next(),t==u)return i;++i}return-1};v.find=function(n,t){for(var r=g(n),i;r.hasNext();)if(i=r.next(),t(i))return i;return null};v.concat=function(n,t){for(var u=new st,i=g(n),r;i.hasNext();)r=i.next(),u.add(r);for(i=g(t);i.hasNext();)r=i.next(),u.add(r);return u};Math.__name__=!0;h=function(){};h.__name__=!0;h.field=function(n,t){try{return n[t]}catch(i){return null}};h.getProperty=function(n,t){var i,r;return n==null?null:(n.__properties__?(i=n.__properties__["get_"+t],r=i):r=!1,r?n[i]():n[t])};h.fields=function(n){var i=[],r,t;if(n!=null){r=Object.prototype.hasOwnProperty;for(t in n)t!="__id__"&&t!="hx__closures__"&&r.call(n,t)&&i.push(t)}return i};h.isFunction=function(n){return typeof n=="function"?!(n.__name__||n.__ename__):!1};h.compareMethods=function(n,t){return n==t?!0:!h.isFunction(n)||!h.isFunction(t)?!1:n.scope==t.scope&&n.method==t.method?n.method!=null:!1};s=function(){};s.__name__=!0;s.string=function(n){return i.__string_rec(n,"")};s.parseInt=function(n){var i,e,r,t,u,f;if(n!=null)for(i=0,e=n.length;i<e;)if(r=i++,t=n.charCodeAt(r),t<=8||t>=14&&t!=32&&t!=45)return u=n.charCodeAt(r+1),f=parseInt(n,u==120||u==88?16:10),isNaN(f)?null:f;return null};r=function(){};r.__name__=!0;r.startsWith=function(n,t){return n.length>=t.length?n.lastIndexOf(t,0)==0:!1};r.isSpace=function(n,t){var i=nt.cca(n,t);return i>8&&i<14?!0:i==32};r.ltrim=function(n){for(var i=n.length,t=0;t<i&&r.isSpace(n,t);)++t;return t>0?nt.substr(n,t,i-t):n};r.rtrim=function(n){for(var i=n.length,t=0;t<i&&r.isSpace(n,i-t-1);)++t;return t>0?nt.substr(n,0,i-t):n};r.trim=function(n){return r.ltrim(r.rtrim(n))};r.replace=function(n,t,i){return n.split(t).join(i)};a=function(){};a.__name__=!0;a.handle=function(n,i){var r,u,f,e,s,h,c,l;switch(n){case"bookPurchased":o.lock();r=i;u=!0;new ut("infoBookPurchased",function(){r(u)});break;case"infoEndExcerpt":o.lock();new ut("endOfExcerpt");break;case"infoLoanExpired":window.location.href="/home/message/TokenExpired";break;case"infoTransaction":case"none":t.setLastCFI(a.lastCFIRequested);i!=null&&i(!1);return;case"reqConsent":o.lock();f=i;e=!0;new ut(null,function(){f(e)});break;case"reqCredit":o.lock();s=i;h=!0;new ut("creditWallet",function(){s(h)});break;case"reqOrganisation":o.lock();c=i;l=!0;new ut("chooseOrganisation",function(){c(l)});break;case"recoverableError":case"unrecoverableError":console.log("src/display/ActionCodeHandler.hx:53:","Action not handled: "+n)}};a.buyPage=function(n,i){if(!a.requestInProgress){a.requestInProgress=!0;var r={pageNumber:n==null?"null":""+n,accessType:s.string(t.getOptions().accessType)};u.request("buyPage",r,null,function(t){a.requestInProgress=!1;var r=JSON.parse(t);a.handleAnswer(r,function(t){t?a.buyPage(n,i):i()})},function(n){n=="Http Error #0"&&ut.onOffline();a.requestInProgress=!1})}};a.handleAnswer=function(n,i){if(Object.prototype.hasOwnProperty.call(n,"user")){var r=f.getUser();r.identified=n.user!=null;r.identified&&(r.walletBalance=n.user.walletBalance,r.organisationName=n.user.organisationName,r.login=n.user.login);r.onUpdate()}if(n.currentViewSpent>0)ti.onSpent(n.currentViewSpent);n.page!=null&&(window.document.querySelector(".paginationreader").style.display=n.page.total==0?"none":"block",t.getPageNav().update(n.page));f.getUser().userBookInfo.bookSpentAmount=n.bookSpentAmount;a.handle(n.codeAction,i)};a.reqLastPosition=function(n){if(!a.requestInProgress){a.requestInProgress=!0;var i={CFIBegin:n.start.cfi,CFIEnd:n.end.cfi,accessType:s.string(t.getOptions().accessType)};a.lastCFIRequested=n.start.cfi;u.request("recLastPosition",i,null,function(n){a.requestInProgress=!1;var t=JSON.parse(n);a.handleAnswer(t)},function(n){n=="Http Error #0"&&ut.onOffline();a.requestInProgress=!1})}};o=function(){};o.__name__=!0;o.isLocked=function(){return o.locked};o.lock=function(){var n,t;o.locked=!0;n=window.document.getElementById("overlay");n==null&&(n=window.document.createElement("div"),n.id="overlay",window.document.body.appendChild(n));n.style.display="block";t=window.document.getElementById("viewer");o.oldFilterValue=t.style.filter;t.style.filter="blur(5px)"};o.unlock=function(){var n,t;o.locked=!1;n=window.document.getElementById("overlay");n!=null&&(n.style.display="none");t=window.document.getElementById("viewer");t.style.filter=o.oldFilterValue};p=function(){};p.__name__=!0;p.displayResults=function(n,i,r,u){var o="<h2>"+r+t.i18n.tr("BookSearch/pageFound")+"<\/h2>",d=p.curPage>0,ft=Math.ceil(r/10),a=ft>p.curPage+1,v=Object.create(null),s,e,f,c,l,y,h,w,ut;if(u==null)o="<p class='noresult'>"+t.i18n.tr("BookSearch/noResults")+"<\/p>";else{for(s=Object.create(null),e=0;e<u.length;)f=u[e],++e,Object.prototype.hasOwnProperty.call(v,f.chapterName)||(c=t.getChapterLabelFromFilename(f.chapterName),c==null&&(c=""),v[f.chapterName]=c),l=v[f.chapterName],Object.prototype.hasOwnProperty.call(s,l)||(s[l]=new ii),h=s[l],h.h[f.pageNumber]={results:f.result,font:f.fontName,chapterName:f.chapterName},p.loadFont(f.fontName);a&&(o+="<a id='search-nextpage-top' class=\"btn btnPage PageSuiv  pull-right\">Suiv<\/a>");d&&(o+="<a id='search-prevpage' class=\" btn btnPage PagePrev\">prec<\/a>");for(var g=s,ot=g,nt=Object.keys(g),et=nt.length,tt=0;tt<et;)for(y=nt[tt++],o+="<h3>"+y+"<\/h3>",h=s[y],w=h.keys();w.hasNext();){for(var b=w.next(),it="",k=h.h[b],e=0,rt=k.results;e<rt.length;)ut=rt[e],++e,it+="\r\n\t\t\t\t\t\t\t<div style=\"font-family:'"+k.font+'\'" class="highlight" data-page="'+b+'" data-chapter="'+k.chapterName+'">&bull; '+ut+"<\/div>\r\n\t\t\t\t\t\t";o+='\r\n\t\t\t\t\t\t<div class="result">\r\n\t\t\t\t\t\t\t<p>Page '+b+'<\/p>\r\n\t\t\t\t\t\t\t<div class="details">\r\n\t\t\t\t\t\t\t\t'+it+"\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t"}a&&(o+="<div class='col-lg-12 nopadding text-right'><a id='search-nextpage' class=\"btnPage btn PageSuiv\">Suiv<\/a><\/div>")}n.innerHTML=o;window.document.getElementById("searchInBookView").scrollTop=0;a&&(n.querySelector("a#search-nextpage-top").addEventListener("click",function(){p.search(i,n,p.curPage+1)}),n.querySelector("a#search-nextpage").addEventListener("click",function(){p.search(i,n,p.curPage+1)}));d&&n.querySelector("a#search-prevpage").addEventListener("click",function(){p.search(i,n,p.curPage-1)})};p.loadFont=function(n){var i=window.document.getElementById(n),r;i==null&&(r=t.getOptions().bookPath,i=window.document.createElement("style"),i.appendChild(window.document.createTextNode("\r\n\t\t\t\t@font-face {font-family:'"+n+"';src:url('"+r+n+"');}\r\n\t\t\t")),i.id=n,window.document.head.appendChild(i))};p.searchWithInput=function(n,t){var i=n.value;p.search(i,t,0)};p.search=function(n,t,i){p.curPage=i;u.request("searchInBook",{query:n,searchOnlyInAcquiredContent:"false",page:i==null?"null":""+i},null,function(i){var r=JSON.parse(i);p.displayResults(t,n,r.total,r.searchResult)})};p.handleResultClick=function(u){var e,h;if(!o.isLocked()){var c=u.dataset.chapter,l=s.parseInt(u.dataset.page),f=null;f=function(n,t){var e=n.textContent,s,h,u;if(e.indexOf(t)==-1)return null;for(var r=[],o=0,c=n.childNodes;o<c.length;)(s=c[o],++o,s instanceof HTMLElement)&&(h=f(i.__cast(s,HTMLElement),t),h!=null&&(r=r.concat(h)));if(r.length==0){for(u=e.indexOf(t);u!=-1;)u=e.indexOf(t,u+1),r.push(n);return r}return r};e=function(){for(var vt=i.__cast(window.document.getElementById("viewer").querySelector("iframe"),HTMLIFrameElement),d=new RegExp("\\s","g".split("u").join("")),l=vt.contentDocument.body,s=l.querySelector(".highlight"),ft,w,b,ut,h,ct,k,lt,c;s!=null;)ft=window.document.createTextNode(s.innerText),s.parentElement.insertBefore(ft,s),s.parentElement.removeChild(s),s=l.querySelector(".highlight");for(var g=nt.substr(u.innerText,2,null).replace(d,""),tt=[],it=u.querySelectorAll("em"),et=it[it.length-1],a=it[0];a!=et;)tt.push(a.textContent),a=a.nextSibling;tt.push(et.textContent);var v=tt.join(""),y=v.replace(d,""),p=l.innerText.replace(d,""),ot=p.indexOf(g),rt;for(ot==-1?(n.console.warn("Unable to find text content ("+g+") with full search, fallback with HL search."),console.log("src/display/BookSearch.hx:255:",p),rt=p.indexOf(y)):rt=ot+g.indexOf(y),w=0,b=-1;b<rt;)b=p.indexOf(y,b+1),++w;if(n.console.info("Occurence #"+w),ut=f(l,v),h=ut[w-1],h==null){console.log("src/display/BookSearch.hx:278:",ut);n.console.warn("Unable to find search tag");o.unlock();return}for(var st=h,e=0,ht=0,yt=h.childNodes.length;ht<yt;)if(ct=ht++,k=h.childNodes[ct],k instanceof Text){if(lt=i.__cast(k,Text),e=lt.textContent.indexOf(y),e>0){st=k;break}e=0}c=t.getRendition().getContents()[0].cfiFromNode(st);e>0&&(e-=15,e<0&&(e=0),c=nt.substr(c,0,c.length-1)+":"+e+")");t.getRendition().display(c);at.delay(function(){o.unlock()},200);h.innerHTML=r.replace(h.innerHTML,v,"<span class='highlight' style='display:inline-block;background:#fff358;padding:0 2px;font-weight:bold;text-indent:0'>"+v+"<\/span>")};h=c;t.getChapterHref()==h?(o.lock(),e()):a.buyPage(l,function(){o.lock();t.getRendition().display(h);t.getRendition().once("rendered",function(){e()})})}};si=function(){this.bookmarks=[];var n=this;this.loadBookmarks();this.addBookmarkElem=i.__cast(window.document.getElementById("bookmark"),HTMLAnchorElement);this.addBookmarkElem.addEventListener("click",function(){n.addBookmarkElem.classList.contains("icon-bookmark-empty")?(n.setBookmark(t.getRendition().currentLocation().start.cfi,t.getChapterLabel(),t.getPageNav().getCurrentPage()),n.addBookmarkElem.classList.remove("icon-bookmark-empty"),n.addBookmarkElem.classList.add("icon-bookmark")):(n.removeBookmark(t.getRendition().currentLocation().start.cfi),n.addBookmarkElem.classList.remove("icon-bookmark"),n.addBookmarkElem.classList.add("icon-bookmark-empty"))})};si.__name__=!0;si.prototype={isBookmarked:function(n){for(var t=!1,i=0,r=this.bookmarks,u;i<r.length;)if(u=r[i],++i,u.bookmarkCFI==n){t=!0;break}t&&this.addBookmarkElem.classList.contains("icon-bookmark-empty")?(this.addBookmarkElem.classList.remove("icon-bookmark-empty"),this.addBookmarkElem.classList.add("icon-bookmark")):t||this.addBookmarkElem.classList.contains("icon-bookmark-empty")||(this.addBookmarkElem.classList.remove("icon-bookmark"),this.addBookmarkElem.classList.add("icon-bookmark-empty"))},loadBookmarks:function(){var n=this,i={accessType:s.string(t.getOptions().accessType)};u.request("loadBookmark",i,null,function(i){var c,e,l,r,f,o,s,h;for(n.bookmarks=JSON.parse(i).bookmarks,c=window.document.getElementById("bookmarks"),c.innerHTML="",e=0,l=n.bookmarks;e<l.length;){r=[l[e]];++e;var y="Page "+r[0].bookmarkPage,a=window.document.createElement("li"),u=window.document.createElement("a"),v=window.document.createElement("span");v.className="icon-bookmark-empty";f=window.document.createElement("div");f.className="bookmarklabel";o=window.document.createElement("span");o.className="pagenum";o.textContent=y;s=window.document.createElement("span");s.className="chapterName";s.textContent=r[0].bookmarkChapterName;h=window.document.createElement("span");h.className="glyphicon glyphicon-remove remove";h.title=t.i18n.tr("BookmarkManager/DeleteBookmark");f.append(o);f.append(s);u.append(v);u.append(f);u.append(h);u.onclick=function(n){return function(){t.navigateToCFI(n[0].bookmarkCFI)}}(r);a.append(u);a.querySelector("span.remove").addEventListener("click",function(t){return function(i){i.preventDefault();n.removeBookmark(t[0].bookmarkCFI)}}(r));c.appendChild(a)}})},removeBookmark:function(n){var i=this,r={accessType:s.string(t.getOptions().accessType),CFI:n};u.request("removeBookmark",r,null,function(){i.loadBookmarks()})},setBookmark:function(n,i,r){var f=this,e={accessType:s.string(t.getOptions().accessType),CFI:n,bookmarkChapterName:i,bookmarkPage:r==null?"null":""+r};u.request("addBookmark",e,null,function(t){var u=JSON.parse(t);u.responseCode=="ok"?f.loadBookmarks():u.responseCode=="reqAuthentication"&&(y.show(!0),new pt(k.NOT_BUYING,0,null,function(){y.hide();f.setBookmark(n,i,r)}))})},__class__:si};k=yt["display.BuyMode"]={__ename__:!0,__constructs__:null,PAGE_BY_PAGE:{_hx_name:"PAGE_BY_PAGE",_hx_index:0,__enum__:"display.BuyMode",toString:et},FULL_BOOK:{_hx_name:"FULL_BOOK",_hx_index:1,__enum__:"display.BuyMode",toString:et},NOT_BUYING:{_hx_name:"NOT_BUYING",_hx_index:2,__enum__:"display.BuyMode",toString:et}};k.__constructs__=[k.PAGE_BY_PAGE,k.FULL_BOOK,k.NOT_BUYING];ot=yt["display.PayCCReason"]={__ename__:!0,__constructs__:null,CREDIT_WALLET:{_hx_name:"CREDIT_WALLET",_hx_index:0,__enum__:"display.PayCCReason",toString:et},PURCHASE_BOOK:{_hx_name:"PURCHASE_BOOK",_hx_index:1,__enum__:"display.PayCCReason",toString:et}};ot.__constructs__=[ot.CREDIT_WALLET,ot.PURCHASE_BOOK];ut=function(n,t){this.acceptedBookPrice=0;this.acceptedPagePrice=0;this.startView=n;this.completedCB=t;n==null?this.showChooseBuyMode():n=="endOfExcerpt"?this.showEndExcerpt():n=="creditWallet"?this.showNeedToCreditWallet():n=="chooseOrganisation"?this.showNeedChooseOrganisation():n=="rechargeWallet"?this.showRechargeWallet():n=="buyBook"?this.chooseBuyMode(k.FULL_BOOK):n=="infoBookPurchased"&&this.showBookPurchased()};ut.__name__=!0;ut.onOffline=function(){o.lock();var n='\r\n<div class="modal-body">\r\n\t<h2>'+t.i18n.tr("BuyingTunnel/NotConnectedinternet")+"<\/h2>\r\n\t<h4>"+t.i18n.tr("BuyingTunnel/RefreshWebpage")+'<\/h4>\r\n<\/div>\r\n<div class="modal-footer">\r\n\t<a class="btn btn-primary">'+t.i18n.tr("BuyingTunnel/RefreshBrowser");window.document.getElementById("modal-content").innerHTML=n+"<\/a>\r\n<\/div>\r\n\t\t";window.document.getElementById("modal-content").querySelector("a").addEventListener("click",function(){window.location.reload()});y.show()};ut.prototype={showNeedToCreditWallet:function(){var n=this;c.load("need_to_credit_wallet.html","modal-content",function(i){var u,s,o,h;i.querySelector(".back-arrow").addEventListener("click",function(){n.goBack()});y.show();u=i.querySelector("#buy-full-book");s=i.querySelector(".buy-page-per-page");e.getBookInfo(function(n){var e=f.getUser().userBookInfo.bookSpentAmount,o=n.bookPrice-e,i=r.replace(s.innerHTML,"%price%",l.formatFloat(n.bookPagePrice));s.innerHTML=r.replace(i,"%country%",n.bookPriceCountry);i=r.replace(u.innerHTML,"%price%",l.formatFloat(o));u.innerHTML=r.replace(i,"%country%",n.bookPriceCountry);e>0&&(i=t.i18n.tr("BuyingTunnel/AmountsAcquired")+l.formatFloat(e),u.querySelector("small").innerHTML=i+" &euro;")});o=i.querySelector("h4").innerHTML;h=l.formatFloat(f.getUser().walletBalance);i.querySelector("h4").innerHTML=r.replace(o,"%credit%",h);i.querySelector("#continue").addEventListener("click",b(n,n.showRechargeWallet));var c=b(n,n.chooseBuyMode),a=k.FULL_BOOK,o=function(){c(a)};u.addEventListener("click",o)})},goBack:function(){y.hide();o.unlock();t.navigateToCFI(t.getLastCFI())},showEndExcerpt:function(){c.load("end_excerpt.html","modal-content",function(n){y.show();var u=n.querySelector(".modal-header .title"),t=n.querySelector("#buy-full-book");e.getBookInfo(function(f){for(var c=[],o=0,a=f.bookMeta.author,v,s,y,h;o<a.length;)v=a[o],++o,c.push(v.LastName);u.innerText=f.bookMeta.title+" - "+f.bookMeta.authorString;i.__cast(n.querySelector(".cover"),HTMLImageElement).src=e.getCoverUrl(f,100);n.querySelector(".titleBook").innerText=f.bookMeta.title;n.querySelector(".author").innerHTML=c.join("<br />");n.querySelector(".editor").innerHTML=f.bookMeta.publisher;f.bookBuyOnStoreUrl!=null&&(s="",s=f.bookPriceCurrency=="GBP"?"£"+l.formatFloat(f.bookPrice):l.formatFloat(f.bookPrice)+" €",y=r.replace(t.innerHTML,"%price%",s),t.innerHTML=r.replace(y,"%country%",f.bookPriceCountry),h=n.querySelector("#buy-full-book"),h.style.display="block",h.href=f.bookBuyOnStoreUrl)})})},showChooseBuyMode:function(n,t){t==null&&(t=!1);var u=this;c.load("choose_buy_mode.html","modal-content",function(o){var a,s,p;y.show();var h=o.querySelector("#buy-page-per-page"),w=o.querySelector(".modal-header .title"),c=o.querySelector("#buy-full-book");if(t)for(a=o.querySelectorAll(".NotDebited"),s=0;s<a.length;)p=a[s],++s,i.__cast(p,HTMLParagraphElement).style.display="block";o.querySelector(".back-arrow").addEventListener("click",function(){u.goBack()});e.getBookInfo(function(t){var a,v,e,s;if(w.innerText=t.bookMeta.title+" - "+t.bookMeta.authorString,t.bookAvailableInUserCountry){var y=f.getUser().userBookInfo.bookSpentAmount,p=t.bookPrice-y,e=r.replace(h.innerHTML,"%price%",l.formatFloat(t.bookPagePrice));h.innerHTML=r.replace(e,"%country%",t.bookPriceCountry);e=r.replace(c.innerHTML,"%price%",l.formatFloat(p));c.innerHTML=r.replace(e,"%country%",t.bookPriceCountry);u.acceptedPagePrice=t.bookPagePrice;u.acceptedBookPrice=t.bookPrice;n&&(s=i.__cast(o.querySelector(".pricechange"),HTMLDivElement),s.innerHTML=r.replace(s.innerHTML,"%country%",t.bookPriceCountry),s.style.display="flex")}else a=i.__cast(o.querySelector(".bookNotAvailableInCountry"),HTMLDivElement),v=i.__cast(o.querySelector(".bookAvailableInCountry"),HTMLDivElement),a.style.display="flex",v.style.display="none"});var s=b(u,u.chooseBuyMode),d=k.PAGE_BY_PAGE,v=function(){s(d)};h.addEventListener("click",v);var g=b(u,u.chooseBuyMode),nt=k.FULL_BOOK,v=function(){g(nt)};c.addEventListener("click",v)})},showNeedChooseOrganisation:function(){var n=this;ei.getOrganisationList(function(i){n.listOrganisations=i;c.load("choose_organisation.html","modal-content",function(i){for(var e=n.listOrganisations,o=window.document.getElementById("OrganisationList"),u=0,r,i;u<e.length;)r=[e[u]],++u,i=window.document.createElement("div"),i.className="col-lg-4 choosewalletuser",i.innerHTML='\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t<div class="chooseWallet">\r\n\t\t\t\t\t\t\t<span class="OrganisationName">'+r[0].OrganisationName+'<\/span>\r\n\t\t\t\r\n\t\t\t\t\t\t\tCrédit disponible : <span class="AmountWalletOrga">'+r[0].WalletBalance+"<\/span> "+r[0].Currency+'\r\n\t\t\t\t\t\t\t<br /><br /><br /><div class="Btnchoosewallet"> '+t.i18n.tr("BuyingTunnel/Ichoose")+" <\/div><br />\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t",i.querySelector("div.chooseWallet").addEventListener("click",function(t){return function(){ei.setChoosenOrganisation(t[0].OrganisationId,function(){return function(t){var i=f.getUser();i.walletBalance=t;n.resumeReading()}}())}}(r)),o.appendChild(i);y.show()})})},chooseBuyMode:function(n){var t=this;this.buyMode=n;f.getUser().identified?this.onAuthed():e.getBookInfo(function(n){var i=t.buyMode==k.PAGE_BY_PAGE?n.bookPagePrice:n.bookPrice;new pt(t.buyMode,i,function(){t.startView=="buyBook"?t.resumeReading():t.showChooseBuyMode()},b(t,t.onAuthed))})},showBookPurchased:function(){var n=this;e.getBookInfo(function(u){n.bookInfos=u;c.load("infos-bookPurchased.html","modal-content",function(f){y.show();var e=i.__cast(f.querySelector(".modal-body"),HTMLDivElement);e.innerHTML=r.replace(e.innerHTML,"%titre%",u.bookMeta.title);e.innerHTML=r.replace(e.innerHTML,"%storeName%",t.getOptions().storeName);f.querySelector("#resume-reading").addEventListener("click",b(n,n.resumeReading))})})},sendUserConsent:function(n){u.request("userConsent",{accessType:s.string(u.getAccessType()),bookPagePrice:s.string(this.acceptedPagePrice)},null,function(t){var i=JSON.parse(t);n(i.responseCode)})},onAuthed:function(n){var t=this;if(n){this.resumeReading();return}this.buyMode==k.PAGE_BY_PAGE?this.sendUserConsent(function(n){n==1?t.checkWalletBalance():n==2?t.showChooseBuyMode(!0):n==3&&t.resumeReading()}):this.checkWalletBalance()},checkWalletBalance:function(){var n=this;e.getBookInfo(function(t){n.bookInfos=t;var r=n.buyMode==k.PAGE_BY_PAGE?n.getActualBookPrice(n.bookInfos):.01,i=f.getUser().walletBalance;n.buyMode==k.PAGE_BY_PAGE?i>=n.bookInfos.bookPagePrice?n.resumeReading():n.showRechargeWallet():i>=r?n.showPayChoice():(n.acceptedBookPrice==0&&(n.acceptedBookPrice=t.bookPrice),n.showPayCC(n.getActualBookPrice(t),ot.PURCHASE_BOOK,t.bookPrice!=n.acceptedBookPrice))})},resumeReading:function(){y.hide();o.unlock();this.completedCB!=null?this.completedCB():t.onPageChanged()},showConfirmPay:function(){var n=this;e.getBookInfo(function(u){n.bookInfos=u;c.load("confirm_pay.html","modal-content",function(f){var e=i.__cast(f.querySelector(".modal-body"),HTMLDivElement);e.innerHTML=r.replace(e.innerHTML,"%titre%",u.bookMeta.title);e.innerHTML=r.replace(e.innerHTML,"%storeName%",t.getOptions().storeName);f.querySelector("#resume-reading").addEventListener("click",b(n,n.resumeReading))})})},showConfirmPayWallet:function(){var n=this;c.load("confirm_pay_Wallet.html","modal-content",function(t){t.querySelector("#resume-reading").addEventListener("click",b(n,n.resumeReading))})},showSharedWalletInfo:function(){var n=this;c.load("infos_sharedWallet.html","modal-content",function(t){y.show();t.querySelector(".back-arrow").addEventListener("click",function(){n.resumeReading()});var i=t.querySelector("h4").innerHTML,u=l.formatFloat(f.getUser().walletBalance);t.querySelector("h4").innerHTML=r.replace(i,"%credit%",u);t.querySelector("h4").innerHTML=r.replace(t.querySelector("h4").innerHTML,"%organisationName%",f.getUser().organisationName)})},showRechargeWallet:function(){var n=this;f.getUser().organisationName!=null?this.showSharedWalletInfo():c.load("recharge_wallet.html","modal-content",function(t){var s,h,u,e,c,o;for(y.show(),t.querySelector(".back-arrow").addEventListener("click",function(){n.startView=="rechargeWallet"?n.resumeReading():n.showChooseBuyMode()}),s=t.querySelector("h4").innerHTML,h=l.formatFloat(f.getUser().walletBalance),t.querySelector("h4").innerHTML=r.replace(s,"%credit%",h),u=0,e=t.querySelectorAll(".recharge");u<e.length;)c=e[u],++u,o=[i.__cast(c,HTMLAnchorElement)],o[0].addEventListener("click",function(t){return function(){var i=parseFloat(t[0].dataset.amount);n.showPayCC(i,ot.CREDIT_WALLET,!1)}}(o))})},showPayCCWithWallet:function(n,o){var s=this;c.load("pay_cc_with_wallet.html","modal-content",function(h){y.show();var a=f.getUser().userBookInfo.bookSpentAmount,c=n-o;e.getBookInfo(function(v){var p=h.querySelector(".modal-body").innerHTML,y;p=r.replace(r.replace(r.replace(r.replace(r.replace(r.replace(r.replace(p,"%book_price%",l.formatFloat(v.bookPrice)),"%wallet_balance%",l.formatFloat(o)),"%book_spent_price%",l.formatFloat(a)),"%reminder%",l.formatFloat(c)),"%login%",f.getUser().login),"%author%",v.bookMeta.authorString),"%title%",v.bookMeta.title);h.querySelector(".modal-body").innerHTML=p;i.__cast(h.querySelector("img.cover"),HTMLImageElement).src=e.getCoverUrl(v,100);h.querySelector(".back-arrow").addEventListener("click",function(){s.showPayChoice()});h.querySelector(".passwordForgot").addEventListener("click",function(){window.open(t.getOptions().passwordAssistance,"_blank")});a>0&&(h.querySelector("#alreadypaid").style.display="block");y=!1;h.querySelector("#continue").addEventListener("click",function(){var o,r,a,v,l;if(!y){for(w.dismissErrors(h),o=["cbnum","expmonth","expyear","cvv","holdername","password"],r=0;r<o.length;)if(a=o[r],++r,v=i.__cast(h.querySelector("[name="+a+"]"),HTMLInputElement),v.value.length==0){w.addError(h.querySelector("button"),t.i18n.tr("BuyingTunnel/AllFieldsRequired"));return}if(l=i.__cast(h.querySelector("[name=cbnum]"),HTMLInputElement).value,!gt.check(l)){w.addError(h.querySelector("[name=cbnum]"),t.i18n.tr("BuyingTunnel/InvalidNumberCreditCard"));return}var b=i.__cast(h.querySelector("[name=expmonth]"),HTMLInputElement).value,k=i.__cast(h.querySelector("[name=expyear]"),HTMLInputElement).value,d=i.__cast(h.querySelector("[name=cvv]"),HTMLInputElement).value,g=i.__cast(h.querySelector("[name=holdername]"),HTMLInputElement).value,p=i.__cast(h.querySelector("[name=password]"),HTMLInputElement).value;u.request("authenticateUser",{email:f.getUser().login,password:p},null,function(i){var r=JSON.parse(i);if(!r.authenticated){h.querySelector("[name=password]").classList.add("error");w.addError(h.querySelector("[name=password]"),t.i18n.tr("BuyingTunnel/WrongPassword"));return}y=!0;h.querySelector("#continue").classList.add("loading");u.request("creditWallet",{creditCardNumber:l,creditCardMonth:b,creditCardYear:k,creditCardCVV:d,creditCardHolderName:g,walletCreditAmount:c==null?"null":""+c},null,function(t){y=!1;h.querySelector("#continue").classList.remove("loading");var i=JSON.parse(t);i.responseCode==1&&(f.getUser().walletBalance=i.walletBalance,e.refreshBookInfo(),u.request("purchaseByWallet",{password:p,expectedPaidAmount:n==null?"null":""+n},null,function(n){var t=JSON.parse(n),i=f.getUser();if(i.walletBalance=t.walletBalance,i.onUpdate(),t.responseCode==0){h.querySelector("input[name=password]").classList.add("error");return}s.showConfirmPay()}))})})}})})})},getActualBookPrice:function(n){return n.bookPrice-f.getUser().userBookInfo.bookSpentAmount},showPayBookByWallet:function(n,o){var s=this;c.load("pay_wallet.html","modal-content",function(h){var c=f.getUser().userBookInfo.bookSpentAmount,a=o-n;c>0&&(h.querySelector("#alreadypaid").style.display="block");h.querySelector(".passwordForgot").addEventListener("click",function(){window.open(t.getOptions().passwordAssistance,"_blank")});e.getBookInfo(function(t){var u=h.querySelector(".modal-body").innerHTML;u=r.replace(r.replace(r.replace(r.replace(r.replace(r.replace(r.replace(u,"%book_price%",l.formatFloat(t.bookPrice)),"%wallet_balance%",l.formatFloat(o)),"%book_spent_price%",l.formatFloat(c)),"%login%",f.getUser().login),"%reminder%",l.formatFloat(n)),"%author%",t.bookMeta.authorString),"%title%",t.bookMeta.title);h.querySelector(".modal-body").innerHTML=u;i.__cast(h.querySelector("img.cover"),HTMLImageElement).src=e.getCoverUrl(t,100)});h.querySelector(".back-arrow").addEventListener("click",function(){s.showPayChoice()});h.querySelector("#continue").addEventListener("click",function(){var t=i.__cast(h.querySelector("input[name=password]"),HTMLInputElement).value;u.request("purchaseByWallet",{password:t,expectedPaidAmount:n==null?"null":""+n},null,function(n){var t=JSON.parse(n),i=f.getUser();if(i.walletBalance=t.walletBalance,i.onUpdate(),t.responseCode==0){h.querySelector("input[name=password]").classList.add("error");return}s.showConfirmPayWallet()})})})},showPayCC:function(n,o,s){var h=this;c.load("pay_cc.html","modal-content",function(c){y.show();e.getBookInfo(function(a){var k=f.getUser().userBookInfo.bookSpentAmount,p=c.querySelector(".modal-body").innerHTML,b,v,y;p=r.replace(r.replace(r.replace(r.replace(r.replace(r.replace(p,"%book_price%",l.formatFloat(a.bookPrice)),"%book_spent_price%",l.formatFloat(k)),"%reminder%",l.formatFloat(n)),"%login%",f.getUser().login),"%author%",a.bookMeta.authorString),"%title%",a.bookMeta.title);c.querySelector(".modal-body").innerHTML=p;k>0&&o==ot.PURCHASE_BOOK&&(c.querySelector("#alreadypaid").style.display="block");c.querySelector(".modal-body").innerHTML=p;i.__cast(c.querySelector("img.cover"),HTMLImageElement).src=e.getCoverUrl(a,100);s&&(b=i.__cast(c.querySelector(".pricechange"),HTMLDivElement),b.innerHTML=r.replace(b.innerHTML,"%country%",a.bookPriceCountry),b.style.display="flex");o==ot.CREDIT_WALLET?(c.querySelector(".infos div h4").innerText="Montant à créditer",c.querySelector(".infos .bookprice").style.display="none",c.querySelector(".modal-header img").style.display="none",c.querySelector(".infos .Product").style.display="none",c.querySelector(".infos h3").innerHTML=r.replace(c.querySelector(".infos h3").innerHTML,"payer","créditer"),c.querySelector(".changeamount").addEventListener("click",function(){h.showRechargeWallet()})):(c.querySelector(".infos .buttons").style.display="none",c.querySelector(".modal-header .icon-wallet").style.display="none",c.querySelector(".changeamount").style.display="none");c.querySelector(".back-arrow").addEventListener("click",function(){switch(o._hx_index){case 0:h.showRechargeWallet();break;case 1:h.startView=="buyBook"?h.resumeReading():f.getUser().walletBalance>0?h.showPayChoice():h.showChooseBuyMode()}});switch(o._hx_index){case 0:v=t.i18n.tr("BuyingTunnel/PurchaseCreditWallet");break;case 1:v=t.i18n.tr("BuyingTunnel/PurchaseCard")}c.querySelector("h2").innerText=v;switch(o._hx_index){case 0:v=t.i18n.tr("BuyingTunnel/AddCreditWallet");break;case 1:v=""}c.querySelector(".modal-header p").innerText=v;y=!1;c.querySelector("#continue").addEventListener("click",function(){var s,r,a,v;if(!y){for(w.dismissErrors(c),s=["cbnum","expmonth","expyear","cvv","holdername"],r=0;r<s.length;)if(a=s[r],++r,v=i.__cast(c.querySelector("[name="+a+"]"),HTMLInputElement),v.value.length==0){w.addError(c.querySelector("button"),t.i18n.tr("BuyingTunnel/AllFieldsRequired"));return}var l=i.__cast(c.querySelector("[name=cbnum]"),HTMLInputElement).value,p=i.__cast(c.querySelector("[name=expmonth]"),HTMLInputElement).value,b=i.__cast(c.querySelector("[name=expyear]"),HTMLInputElement).value,k=i.__cast(c.querySelector("[name=cvv]"),HTMLInputElement).value,d=i.__cast(c.querySelector("[name=holdername]"),HTMLInputElement).value;if(!gt.check(l)){w.addError(c.querySelector("[name=cbnum]"),t.i18n.tr("BuyingTunnel/InvalidNumberCreditCard"));return}y=!0;c.querySelector("#continue").classList.add("loading");o==ot.CREDIT_WALLET?u.request("creditWallet",{creditCardNumber:l,creditCardMonth:p,creditCardYear:b,creditCardCVV:k,creditCardHolderName:d,walletCreditAmount:n==null?"null":""+n},null,function(n){var i,r;if(y=!1,c.querySelector("#continue").classList.remove("loading"),i=JSON.parse(n),i.responseCode==1){r=f.getUser();r.walletBalance=i.walletBalance;r.onUpdate();e.refreshBookInfo();switch(o._hx_index){case 0:h.showConfirmPayWallet();break;case 1:h.showConfirmPay()}}if(i.responseCode==2){w.addError(c.querySelector("button"),t.i18n.tr("BuyingTunnel/IncorrectInfo"));return}i.responseCode==3&&(e.refreshBookInfo(),e.getBookInfo(function(){h.showChooseBuyMode(!0,!0)}))}):u.request("purchaseByCreditCard",{creditCardNumber:l,creditCardMonth:p,creditCardYear:b,creditCardCVV:k,creditCardHolderName:d,expectedPaidAmount:n==null?"null":""+n},null,function(n){y=!1;c.querySelector("#continue").classList.remove("loading");var t=JSON.parse(n);t.responseCode==1?h.showConfirmPay():t.responseCode==3&&(e.refreshBookInfo(),e.getBookInfo(function(n){h.showPayCC(h.getActualBookPrice(n),ot.PURCHASE_BOOK,!0)}))})}})})})},showPayChoice:function(){var n=this;c.load("pay_choice.html","modal-content",function(t){y.show();t.querySelector("a.back-arrow").addEventListener("click",function(){n.startView=="buyBook"?n.resumeReading():n.showChooseBuyMode()});var i=t.querySelector("#pay-by-wallet"),r=t.querySelector("#pay-by-cc");e.getBookInfo(function(t){t.bookPrice-t.bookSpentAmount>f.getUser().walletBalance?i.style.display="none":i.addEventListener("click",function(){f.getUser().walletBalance>=n.getActualBookPrice(t)?n.showPayBookByWallet(n.getActualBookPrice(t),f.getUser().walletBalance):n.showPayCCWithWallet(n.getActualBookPrice(t),f.getUser().walletBalance)});r.addEventListener("click",function(){n.showPayCC(n.getActualBookPrice(t),ot.PURCHASE_BOOK,!1)})})})},__class__:ut};hi=function(n,t){this.rendition=t;this.rtl=n.package.metadata.direction=="rtl";window.document.addEventListener("keyup",b(this,this.handleKeyEvent));t.on("keyup",b(this,this.handleKeyEvent))};hi.__name__=!0;hi.prototype={handleKeyEvent:function(n){if(!o.isLocked()){var t=n.keyCode,i=window.document.activeElement;i.nodeName!="INPUT"&&(t==37?this.rtl?it.changePage(!0):it.changePage(!1):t==39&&(this.rtl?it.changePage(!1):it.changePage(!0)))}},__class__:hi};tt=function(){};tt.__name__=!0;tt.showLoader=function(){tt.loaderVisible||(tt.loaderVisible=!0,tt.loaderTimeout=window.setTimeout(tt.displayLoader,100))};tt.displayLoader=function(){window.document.getElementById("loader").style.display="block"};tt.hideLoader=function(){tt.loaderVisible=!1;tt.loaderTimeout!=null&&window.clearTimeout(tt.loaderTimeout);window.document.getElementById("loader").style.display="none"};pt=function(n,t,i,r){this.callbackAuthed=r;this.callbackBack=i;this.price=t;this.buyMode=n;this.loadLoginScreen()};pt.__name__=!0;pt.prototype={loadRegisterScreen:function(){var n=this;c.load("register.html","modal-content",function(h){var d,c,a,v,p,l,g,nt,tt,b;if(n.mainElem=h,h.querySelector("a.login").addEventListener("click",function(t){t.preventDefault();n.loadLoginScreen()}),h.querySelector("label[for=accept-cgs] a").addEventListener("click",function(){window.open(t.getOptions().TOS,"_blank")}),d=$(h.querySelector("#country")),d.countrySelect({defaultCountry:"fr",preferredCountries:["fr","be","ca","ch"]}),c=h.querySelector(".mode"),n.buyMode!=k.NOT_BUYING)for(a=t.i18n.tr("LoginScreen/BuyAllTheBook"),v=s.string(n.price)+" &euro;",n.buyMode==k.PAGE_BY_PAGE&&(a=t.i18n.tr("LoginScreen/PurchasePerPage"),v=s.string(n.price)+" &euro;<span>/Page<\/span>"),c.innerHTML=r.replace(r.replace(c.innerHTML,"%price",v),"%mode",a),p=h.querySelectorAll(".back-arrow"),l=0;l<p.length;)g=p[l],++l,nt=h.parentElement,nt.classList.contains("neutralDiv")||g.addEventListener("click",n.callbackBack);else tt=h.querySelector(".neutralDiv"),c.style.display="none",tt.style.display="flex",h.querySelector(".close-back-arrow").addEventListener("click",function(){y.hide();o.unlock()});b=h.querySelector(".storeName");b.innerHTML=r.replace(b.innerHTML,"%storeName",t.getOptions().storeName);h.querySelector("#register-submit").addEventListener("click",function(){var s=i.__cast(h.querySelector("input[name=email]"),HTMLInputElement).value,c=i.__cast(h.querySelector("input[name=lastname]"),HTMLInputElement).value,l=i.__cast(h.querySelector("input[name=firstname]"),HTMLInputElement).value,a=i.__cast(h.querySelector("input[name=companyName]"),HTMLInputElement).value,o=i.__cast(h.querySelector("input[name=password]"),HTMLInputElement).value,v=i.__cast(h.querySelector("input[name=confirm-password]"),HTMLInputElement).value,y=i.__cast(h.querySelector("input[name=accept-cgs]"),HTMLInputElement).checked,p=i.__cast(h.querySelector("#country_code"),HTMLInputElement).value,r;(w.dismissErrors(n.mainElem),r=!1,s.length==0&&(w.addError(h.querySelector("input[name=email]"),t.i18n.tr("LoginScreen/NeedValidemail")),r=!0),o.length<6&&!r&&(w.addError(h.querySelector("input[name=password]"),t.i18n.tr("LoginScreen/NbrCharactersPassword")),r=!0),o!=v&&(w.addError(h.querySelector("input[name=confirm-password]"),t.i18n.tr("LoginScreen/PasswordNotMatch")),r=!0),y||(w.addError(h.querySelector("input[name=accept-cgs] + label"),t.i18n.tr("LoginScreen/AcceptCGS")),r=!0),r)||u.request("registerUser",{email:s,password:o,lastname:c,firstname:l,companyName:a,countryCode:p},null,function(i){var r=JSON.parse(i),u;if(r.responseCode==2){w.addError(h.querySelector("input[name=email]"),t.i18n.tr("LoginScreen/InvalidEmailAddress"));return}if(r.responseCode==0){w.addError(h.querySelector("input[name=email]"),t.i18n.tr("LoginScreen/EmailAddressAlreadyRegistered"));return}e.refreshBookInfo();u=f.getUser();u.userBookInfo.bookAcquired=r.bookAcquired;u.identified=!0;u.userBookInfo.bookSpentAmount=r.bookSpentAmount;u.walletBalance=r.user.walletBalance;u.organisationName=r.user.organisationName;u.login=r.user.login;u.onUpdate();n.callbackAuthed(r.bookAcquired)})});y.show()})},loadLoginScreen:function(){var n=this;c.load("auth.html","modal-content",function(f){var e,l,a,v,h,d,g,nt,p,c;if(n.mainElem=f,f.querySelector("a.register").addEventListener("click",function(t){t.preventDefault();n.loadRegisterScreen()}),e=f.querySelector(".mode"),n.buyMode!=k.NOT_BUYING)for(l=t.i18n.tr("LoginScreen/BuyAllTheBook"),a=s.string(n.price)+" &euro;",n.buyMode==k.PAGE_BY_PAGE&&(l=t.i18n.tr("LoginScreen/PurchasePerPage"),a=s.string(n.price)+" &euro;<span>/Page<\/span>"),e.innerHTML=r.replace(r.replace(e.innerHTML,"%price",a),"%mode",l),v=f.querySelectorAll(".back-arrow"),h=0;h<v.length;)d=v[h],++h,g=f.parentElement,g.classList.contains("neutralDiv")||d.addEventListener("click",n.callbackBack);else nt=f.querySelector(".neutralDiv"),e.style.display="none",nt.style.display="flex",f.querySelector(".close-back-arrow").addEventListener("click",function(){y.hide();o.unlock()});p=f.querySelector(".storeName");p.innerHTML=r.replace(p.innerHTML,"%storeName",t.getOptions().storeName);c=function(){w.dismissErrors(n.mainElem);var r=i.__cast(n.mainElem.querySelector("input[name=email]"),HTMLInputElement).value,f=i.__cast(n.mainElem.querySelector("input[name=password]"),HTMLInputElement).value;if(r.length==0){w.addError(n.mainElem.querySelector("input[name=email]"),t.i18n.tr("LoginScreen/IncorrectLogin"));return}if(f.length<6){w.addError(n.mainElem.querySelector("input[name=password]"),t.i18n.tr("LoginScreen/IncorrectPassword"));return}u.request("authenticateUser",{email:r,password:f},null,b(n,n.handleAuth))};f.querySelector("input[name=email]").addEventListener("keypress",function(n){n.which==13&&c()});f.querySelector("input[name=password]").addEventListener("keypress",function(n){n.which==13&&c()});n.mainElem.querySelector("#auth-submit").addEventListener("click",c);n.mainElem.querySelector(".submit a").addEventListener("click",function(){window.open(t.getOptions().passwordAssistance,"_blank")});y.show()})},handleAuth:function(n){var i=JSON.parse(n),r=f.getUser();r.identified=i.authenticated;r.userBookInfo.bookAcquired=i.bookAcquired;r.userBookInfo.bookSpentAmount=i.bookSpentAmount;i.authenticated?(e.refreshBookInfo(),r.walletBalance=i.user.walletBalance,r.organisationName=i.user.organisationName,r.login=i.user.login,r.onUpdate(),this.callbackAuthed(i.bookAcquired)):w.addError(this.mainElem.querySelector("input[name=email]"),t.i18n.tr("LoginScreen/AuthenticationFailed"))},__class__:pt};ci=function(){var n=this,r,a,v,h,w;for(this.slider=i.__cast(window.document.getElementById("slider"),HTMLAnchorElement),this.opennavOption=i.__cast(window.document.getElementById("opennavOption"),HTMLAnchorElement),this.sidebar=i.__cast(window.document.getElementById("sidebar"),HTMLDivElement),this.sidebarOverlay=i.__cast(window.document.getElementById("sidebarOverlay"),HTMLDivElement),this.menuElem=i.__cast(window.document.getElementById("menu"),HTMLDivElement),this.slider.addEventListener("click",b(this,this.open)),this.sidebarOverlay.addEventListener("click",b(this,this.close)),r=0,a=this.menuElem.querySelectorAll("a");r<a.length;)v=a[r],++r,h=[i.__cast(v,HTMLAnchorElement)],w=[h[0].dataset.elem],h[0].addEventListener("click",function(r,h){return function(){if(n.menuElem.querySelector(".active")!=null&&n.menuElem.querySelector(".active").classList.remove("active"),r[0]=="close"?n.close():n.sidebar.classList.add("open"),r[0]=="user"&&c.load("user.html","userView",function(i){return function(r){r.querySelector("a").addEventListener("click",function(){return function(){u.request("logOutUser",null,null,function(){return function(){var i=f.getUser();i.identified=!1;i.login="";i.walletBalance=0;i.onUpdate();n.close();t.navigateToCFI(t.getFirstCFI());o.unlock();new pt(k.NOT_BUYING,0,null,function(){return function(){y.hide()}}())}}())}}());r.querySelector("p").innerHTML=f.getUser().login;n.showView("userView",i[0])}}(h)),r[0]=="bookmarks")n.showView("bookmarksView",h[0]);else if(r[0]=="toc")n.showView("tocView",h[0]);else if(r[0]=="info"){var a=t.getOptions().accessType==2&&t.getOptions().storeId!=0?"infos-pickandread.html":"infos-general.html";c.load(a,"infoView",function(t){return function(){n.showView("infoView",t[0])}}(h))}else r[0]=="searchInBook"?c.load("searchInBook.html","searchInBookView",function(t){return function(r){var u=r.querySelector(".results"),f=i.__cast(r.querySelector("input"),HTMLInputElement),e=f,o=u;r.querySelector("button").addEventListener("click",function(){return function(){p.searchWithInput(e,o)}}());f.addEventListener("keyup",function(){return function(n){(n.keyCode==37||n.keyCode==39)&&n.preventDefault();n.keyCode==13&&p.searchWithInput(f,u)}}());u.addEventListener("click",function(){return function(n){var t=i.__cast(n.target,HTMLElement),r;t.nodeName=="EM"&&(t=t.parentElement);t.classList.contains("highlight")&&(r=u.querySelector(".current"),r!=null&&r.classList.remove("current"),t.classList.add("current"),p.handleResultClick(i.__cast(t,HTMLDivElement)))}}());n.showView("searchInBookView",t[0])}}(h)):r[0]=="params"?c.load("parameters.html","paramsView",function(r){return function(u){var f,e,s,o;for(u.querySelector(".sizeup").addEventListener("click",function(){return function(){t.increaseSize()}}()),u.querySelector(".sizedown").addEventListener("click",function(){return function(){t.decreaseSize()}}()),f=0,e=u.querySelectorAll(".margin");f<e.length;)s=e[f],++f,o=[i.__cast(s,HTMLButtonElement)],o[0].addEventListener("click",function(n){return function(){var i=n[0].dataset.margin;t.setMargin(i);rt.save(t.getOptions().isbn,"margin",i)}}(o));u.querySelector(".revert").addEventListener("click",function(){return function(){t.setTheme("revert");rt.save("global","theme","revert")}}());u.querySelector(".sepia").addEventListener("click",function(){return function(){t.setTheme("sepia");rt.save("global","theme","sepia")}}());u.querySelector(".normal").addEventListener("click",function(){return function(){t.setTheme("normal");rt.save("global","theme","normal")}}());n.showView("paramsView",r[0])}}(h)):r[0]=="bookinfo"&&c.load("bookinfo.html","bookView",function(r){return function(u){e.getBookInfo(function(r){return function(f){for(var y=[],a=0,p=f.bookMeta.author,w,v,c,h;a<p.length;)w=p[a],++a,y.push(w.LastName);i.__cast(u.querySelector(".cover"),HTMLImageElement).src=e.getCoverUrl(f,100);u.querySelector(".titleBook").innerText=f.bookMeta.title;u.querySelector(".author").innerHTML=y.join("<br />");u.querySelector(".editor").innerHTML=f.bookMeta.publisher;u.querySelector(".pagenum").innerText=s.string(f.bookMeta.totalPages);u.querySelector(".releasedate").innerText=f.bookMeta.publicationDate;v=t.getOptions().accessType;(v==2||v==3)&&f.bookAvailableInUserCountry?(c="",c=f.bookPriceCurrency=="GBP"?" &pound":" &euro;",h=l.formatFloat(f.bookPagePrice),u.querySelector(".pageprice").innerHTML=h+c,h=l.formatFloat(f.bookPrice),u.querySelector(".bookprice").innerHTML=h+c,f.bookPrice-f.bookSpentAmount==0?u.querySelector("div.buybook").style.display="none":f.bookSpentAmount==0&&f.bookBuyOnStoreUrl!=null?u.querySelector("a.buybook").addEventListener("click",function(){return function(){window.location.href=f.bookBuyOnStoreUrl}}()):u.querySelector("a.buybook").addEventListener("click",function(){return function(){n.close();o.lock();new ut("buyBook")}}())):(u.querySelector(".priceinfo").style.display="none",u.querySelector("div.buybook").style.display="none");n.showView("bookView",r[0])}}(r))}}(h))}}(w,h));this.opennavOption.addEventListener("click",function(){var t=window.document.querySelector("a[data-elem='params']"),i=new MouseEvent("click",{bubbles:!0,cancelable:!0});n.open();n.menuElem.querySelector(".active")!=null&&n.menuElem.querySelector(".active").classList.remove("active");t.dispatchEvent(i)})};ci.__name__=!0;ci.prototype={showView:function(n,t){this.sidebar.querySelector(".view.active").classList.remove("active");this.sidebar.querySelector("#"+n).classList.add("active");t.classList.add("active")},open:function(){this.sidebarOverlay.style.display="block";this.sidebar.classList.add("open");this.showView("tocView",i.__cast(this.menuElem.querySelector("a[data-elem=toc]"),HTMLAnchorElement));this.menuElem.classList.add("open");this.menuElem.querySelector("a[data-elem=user]").style.display=f.getUser().identified?"block":"none";this.menuElem.querySelector("a[data-elem=searchInBook]").style.display=t.getOptions().accessType!=4?"block":"none"},close:function(){this.menuElem.classList.remove("open");this.sidebar.classList.remove("open");this.sidebarOverlay.style.display="none"},__class__:ci};y=function(){};y.__name__=!0;y.show=function(n){n==null&&(n=!1);var t=$(window.document.getElementById("modal"));t.modal({backdrop:n,keyboard:n});window.document.getElementById("modal").style.display="block"};y.hide=function(){var n=$(window.document.getElementById("modal"));window.document.getElementById("modal").style.display="none";window.document.querySelector(".modal-backdrop")!=null&&(window.document.querySelector(".modal-backdrop").style.display="none")};it=function(n){var t,i,r,u;this.rendition=n;this.currentPageElem=window.document.getElementById("current-page");this.totalPageElem=window.document.getElementById("total-page");this.pageProgressElem=window.document.getElementById("pageProgress");t=window.document.getElementById("prev");i=!1;t.addEventListener("click",function(){it.changePage(i)});r=window.document.getElementById("next");u=!0;r.addEventListener("click",function(){it.changePage(u)})};it.__name__=!0;it.changePage=function(n,i){if(i!=null&&i.preventDefault(),!o.isLocked())if(!v.has([2,3],t.getOptions().accessType)||(!n||it.buttonPageInfo.isNextPageFree)&&(n||it.buttonPageInfo.isPreviousPageFree))n?t.nextPage():t.prevPage();else{var r=n?it.buttonPageInfo.nextPageNumber:it.buttonPageInfo.previousPageNumber;a.buyPage(r,function(){n?t.nextPage():t.prevPage()})}};it.prototype={getCurrentPage:function(){return this.currentPage},update:function(n){it.buttonPageInfo=n;this.currentPageElem.innerText=n.begin==null?"null":""+n.begin;this.currentPageElem.innerText=n.end>n.begin?(n.begin==null?"null":""+n.begin)+"-"+(n.end==null?"null":""+n.end):n.begin==null?"null":""+n.begin;this.totalPageElem.innerText=n.total==null?"null":""+n.total;this.currentPage=n.begin;this.pageProgressElem.value=100*n.begin/n.total|0},__class__:it};li=function(n){this.additionalWidth=0;this.marginPercent=0;this.rendition=n;this.resize();window.addEventListener("resize",b(this,this.resize))};li.__name__=!0;li.prototype={resize:function(){var n=this.getOptimalSize(),t,i;n.width+=this.additionalWidth==0?Math.floor(n.width/12):this.additionalWidth;t=window.document.getElementById("viewer");t.style.maxWidth=n.width+"px";t.style.width=n.width+"px";t.style.height=n.height+"px";t.style.marginLeft=Math.round(-n.width/2)+"px";i=t.querySelector(".epub-container");i!=null&&(i.style.width=n.width+"px",i.style.height=n.height+"px");this.rendition.resize(n.width,n.height)},setAdditionalWidth:function(n){this.additionalWidth=n},getMargin:function(n){return this.marginPercent==0?n<768?4:n>1366?10:7:this.marginPercent},setMargin:function(n){this.marginPercent=n;this.resize()},getOptimalSize:function(){var n=window.innerWidth>0?window.innerWidth:window.screen.width,i=window.innerHeight>0?window.innerHeight:window.screen.height,r=window.document.getElementById("titlebar").offsetHeight,u=window.document.getElementById("footerbar").offsetHeight+20,t=Math.floor(n>1500?1350:n-n*this.getMargin(n)/50),f=i-r-u;return isNaN(t)||t%2==0||++t,{width:t,height:f}},__class__:li};ai=function(n){this.xDown=null;n.addEventListener("touchstart",b(this,this.handleTouchStart));n.addEventListener("touchmove",b(this,this.handleTouchMove))};ai.__name__=!0;ai.prototype={handleTouchStart:function(n){this.xDown=n.touches[0].clientX},handleTouchMove:function(n){if(this.xDown!=null){var t=n.touches[0].clientX,i=this.xDown-t;i>0?this.changePage(!0):this.changePage(!1);this.xDown=null}},changePage:function(n){o.isLocked()||(n?t.nextPage():t.prevPage())},__class__:ai};vi=function(){};vi.__name__=!0;vi.__isInterface__=!0;lt=function(){this.h=Object.create(null)};lt.__name__=!0;lt.__interfaces__=[vi];lt.prototype={__class__:lt};c=function(){};c.__name__=!0;c.load=function(n,t,i){if(Object.prototype.hasOwnProperty.call(c.cache.h,n)){c.onContent(t,i,c.cache.h[n]);return}var r=new vt("templates/"+n+"?v=b03f3fedfada9a2797181f586cb8d9d5");r.onData=function(r){c.cache.h[n]=r;c.onContent(t,i,r)};r.request(!1)};c.onContent=function(n,t,i){var u=window.document,r=u.getElementById(n);r==null&&(r=u.createElement("div"),r.id=n,u.body.appendChild(r));r.innerHTML=i;t(r)};ni=function(n,t,i){this.rendition=n;this.mainElem=window.document.getElementById("tocView");var r=this.generateTocItems(t);this.mainElem.appendChild(r);this.linkReference=i};ni.__name__=!0;ni.prototype={cleanLabel:function(n){return r.trim(r.replace(r.replace(n,"\n",""),"\t",""))},update:function(n){var t=this.mainElem.querySelector("#toc-"+n),r=this.mainElem.querySelector(".currentChapter"),u=this.mainElem.querySelector(".openChapter");r!=null&&r.classList.remove("currentChapter");t!=null&&(t.classList.add("currentChapter"),i.__cast(t.parentNode,HTMLElement).classList.add("openChapter"))},generateTocItems:function(n,t){var e,f,i,o;for(t==null&&(t=1),e=window.document.createElement("ul"),f=0;f<n.length;){i=n[f];++f;var r=window.document.createElement("li"),u=window.document.createElement("a"),s=window.document.createElement("a");r.id="toc-"+i.spinePos;r.classList.add("list_item");u.textContent=this.cleanLabel(i.label);u.href=i.href;u.classList.add("toc_link");u.addEventListener("click",b(this,this.onTocLinkClick));r.appendChild(u);i.subitems.length>0&&(o=this.generateTocItems(i.subitems,t+1),r.appendChild(o));e.appendChild(r)}return e},onTocLinkClick:function(n){var f=this,r,t,u;return n.preventDefault(),r=i.__cast(n.currentTarget,HTMLAnchorElement),t=r.getAttribute("href"),i.__cast(r.parentNode,HTMLElement).classList.add("openChapter"),Object.prototype.hasOwnProperty.call(this.linkReference.h,t)?(u=this.linkReference.h[t],a.buyPage(u.page_num,function(){f.rendition.display(t)})):this.rendition.display(t),n.preventDefault(),!1},__class__:ni};w=function(){};w.__name__=!0;w.dismissErrors=function(n){for(var t=0,r=n.querySelectorAll(".error"),f,u;t<r.length;)f=r[t],++t,u=i.__cast(f,HTMLElement),u.classList.remove("error");for(t=0,r=n.querySelectorAll(".popover");t<r.length;)f=r[t],++t,u=i.__cast(f,HTMLDivElement),u.parentNode.removeChild(u)};w.addError=function(n,t){n.classList.add("error");var i=$(n);i.popover({content:t,placement:"right",trigger:"manual"});i.attr("data-content",t).data("bs.popover").setContent();i.popover("show")};ti=function(){};ti.__name__=!0;ti.checkAlmostEmpty=function(){var n=f.getUser().walletBalance;e.getBookInfo(function(t){var r=t.bookPagePrice,u=r*5,f=n<u,i=window.document.getElementById("wallet");f?i.classList.add("almost-empty"):i.classList.remove("almost-empty")})};ti.onSpent=function(n){var t=window.document.createElement("div"),r=" - "+l.formatFloat(n),i;t.innerText=r+" €";t.classList.add("spent-anim");i=window.document.getElementById("wallet");i.appendChild(t);$(t).animate({top:-40,opacity:0},1e3,null,function(){i.removeChild(t)})};d=function(n,t,i){Error.call(this,n);this.message=n;this.__previousException=t;this.__nativeException=i!=null?i:this};d.__name__=!0;d.caught=function(n){return n instanceof d?n:n instanceof Error?new d(n.message,null,n):new wt(n,null,n)};d.thrown=function(n){return n instanceof d?n.get_native():n instanceof Error?n:new wt(n)};d.__super__=Error;d.prototype=nr(Error.prototype,{unwrap:function(){return this.__nativeException},get_native:function(){return this.__nativeException},__class__:d,__properties__:{get_native:"get_native"}});at=function(n){var t=this;this.id=setInterval(function(){t.run()},n)};at.__name__=!0;at.delay=function(n,t){var i=new at(t);return i.run=function(){i.stop();n()},i};at.prototype={stop:function(){this.id!=null&&(clearInterval(this.id),this.id=null)},run:function(){},__class__:at};wt=function(n,t,i){d.call(this,String(n),t,i);this.value=n};wt.__name__=!0;wt.__super__=d;wt.prototype=nr(d.prototype,{unwrap:function(){return this.value},__class__:wt});ii=function(){this.h={}};ii.__name__=!0;ii.__interfaces__=[vi];ii.prototype={keys:function(){var t=[],n;for(n in this.h)this.h.hasOwnProperty(n)&&t.push(n|0);return new dt(t)},__class__:ii};st=function(){this.length=0};st.__name__=!0;st.prototype={add:function(n){var t=new yi(n,null);this.h==null?this.h=t:this.q.next=t;this.q=t;this.length++},iterator:function(){return new pi(this.h)},__class__:st};yi=function(n,t){this.item=n;this.next=t};yi.__name__=!0;yi.prototype={__class__:yi};pi=function(n){this.head=n};pi.__name__=!0;pi.prototype={hasNext:function(){return this.head!=null},next:function(){var n=this.head.item;return this.head=this.head.next,n},__class__:pi};bt=function(n){this.url=n;this.headers=[];this.params=[];this.emptyOnData=b(this,this.onData)};bt.__name__=!0;bt.prototype={setHeader:function(n,t){for(var r=0,u=this.headers.length,i;r<u;)if(i=r++,this.headers[i].name==n)return this.headers[i]={name:n,value:t},this;return this.headers.push({name:n,value:t}),this},setPostData:function(n){return this.postData=n,this.postBytes=null,this},onData:function(){},onBytes:function(){},onError:function(){},onStatus:function(){},hasOnData:function(){return!h.compareMethods(b(this,this.onData),this.emptyOnData)},success:function(n){if(this.responseBytes=n,this.responseAsString=null,this.hasOnData())this.onData(this.get_responseData());this.onBytes(this.responseBytes)},get_responseData:function(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,ri.UTF8)),this.responseAsString},__class__:bt,__properties__:{get_responseData:"get_responseData"}};vt=function(n){this.async=!0;this.withCredentials=!1;bt.call(this,n)};vt.__name__=!0;vt.__super__=bt;vt.prototype=nr(bt.prototype,{request:function(t){var u=this,i,o,r,l,a,h,y,p,f,e,c;if(this.responseAsString=null,this.responseBytes=null,i=this.req=ht.createXMLHttpRequest(),o=function(){var t,r;if(i.readyState==4){try{t=i.status}catch(s){t=null}if(t==0&&ht.get_supported()&&n.location!=null){var f=n.location.protocol.toLowerCase(),e=new oi("^(?:about|app|app-storage|.+-extension|file|res|widget):$",""),o=e.match(f);o&&(t=i.response!=null?200:404)}if(t==undefined&&(t=null),t!=null)u.onStatus(t);if(t!=null&&t>=200&&t<400)u.req=null,u.success(ct.ofData(i.response));else if(t==null||t==0&&i.response==null){u.req=null;u.onError("Failed to connect or resolve host")}else if(t==null){u.req=null;r=i.response!=null?ct.ofData(i.response):null;u.responseBytes=r;u.onError("Http Error #"+i.status)}else switch(t){case 12007:u.req=null;u.onError("Unknown host");break;case 12029:u.req=null;u.onError("Failed to connect to host");break;default:u.req=null;r=i.response!=null?ct.ofData(i.response):null;u.responseBytes=r;u.onError("Http Error #"+i.status)}}},this.async&&(i.onreadystatechange=o),f=this.postData,e=this.postBytes,f==null?e==null?r=null:(l=e,r=new Blob([l.b.bufferValue])):e==null?(a=f,r=a):r=null,r!=null)t=!0;else for(f=0,e=this.params;f<e.length;){h=e[f];++f;r=r==null?"":(r==null?"null":s.string(r))+"&";var w=h.name,b=(r==null?"null":s.string(r))+encodeURIComponent(w)+"=",k=h.value;r=b+encodeURIComponent(k)}try{t?i.open("POST",this.url,this.async):r!=null?(y=this.url.split("?").length<=1,i.open("GET",this.url+(y?"?":"&")+(r==null?"null":s.string(r)),this.async),r=null):i.open("GET",this.url,this.async);i.responseType="arraybuffer"}catch(f){p=d.caught(f).unwrap();this.req=null;this.onError(p.toString());return}for(i.withCredentials=this.withCredentials,!v.exists(this.headers,function(n){return n.name=="Content-Type"})&&t&&this.postData==null&&i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f=0,e=this.headers;f<e.length;)c=e[f],++f,i.setRequestHeader(c.name,c.value);i.send(r);this.async||o(null)},__class__:vt});ct=function(n){this.length=n.byteLength;this.b=new Uint8Array(n);this.b.bufferValue=n;n.hxBytes=this;n.bytes=this.b};ct.__name__=!0;ct.ofData=function(n){var t=n.hxBytes;return t!=null?t:new ct(n)};ct.prototype={getString:function(n,t,i){var l,s,h,c,r;if(n<0||t<0||n+t>this.length)throw d.thrown(kt.OutsideBounds);i==null&&(i=ri.UTF8);var e="",f=this.b,u=n,o=n+t;switch(i._hx_index){case 0:for(l=n>0;u<o;)if(r=f[u++],r<128){if(r==0)break;e+=String.fromCodePoint(r)}else if(r<224)s=(r&63)<<6|f[u++]&127,e+=String.fromCodePoint(s);else if(r<240)h=f[u++],c=(r&31)<<12|(h&127)<<6|f[u++]&127,e+=String.fromCodePoint(c);else{var a=f[u++],v=f[u++],y=(r&15)<<18|(a&127)<<12|(v&127)<<6|f[u++]&127;e+=String.fromCodePoint(y)}break;case 1:while(u<o)r=f[u++]|f[u++]<<8,e+=String.fromCodePoint(r)}return e},__class__:ct};ri=yt["haxe.io.Encoding"]={__ename__:!0,__constructs__:null,UTF8:{_hx_name:"UTF8",_hx_index:0,__enum__:"haxe.io.Encoding",toString:et},RawNative:{_hx_name:"RawNative",_hx_index:1,__enum__:"haxe.io.Encoding",toString:et}};ri.__constructs__=[ri.UTF8,ri.RawNative];kt=yt["haxe.io.Error"]={__ename__:!0,__constructs__:null,Blocked:{_hx_name:"Blocked",_hx_index:0,__enum__:"haxe.io.Error",toString:et},Overflow:{_hx_name:"Overflow",_hx_index:1,__enum__:"haxe.io.Error",toString:et},OutsideBounds:{_hx_name:"OutsideBounds",_hx_index:2,__enum__:"haxe.io.Error",toString:et},Custom:(ft=function(n){return{_hx_index:3,e:n,__enum__:"haxe.io.Error",toString:et}},ft._hx_name="Custom",ft.__params__=["e"],ft)};kt.__constructs__=[kt.Blocked,kt.Overflow,kt.OutsideBounds,kt.Custom];dt=function(n){this.current=0;this.array=n};dt.__name__=!0;dt.prototype={hasNext:function(){return this.current<this.array.length},next:function(){return this.array[this.current++]},__class__:dt};i=function(){};i.__name__=!0;i.getClass=function(n){var t,r;return n==null?null:n instanceof Array?Array:(t=n.__class__,t!=null)?t:(r=i.__nativeClassName(n),r!=null)?i.__resolveNativeClass(r):null};i.__string_rec=function(n,t){var f,s,a,h,e,c,u,v,r;if(n==null)return"null";if(t.length>=5)return"<...>";f=typeof n;f=="function"&&(n.__name__||n.__ename__)&&(f="object");switch(f){case"function":return"<function>";case"object":if(n.__enum__){var y=yt[n.__enum__],o=y.__constructs__[n._hx_index],l=o._hx_name;return o.__params__?(t=t+"\t",l+"("+function(){for(var u=[],r=0,f=o.__params__,e;;){if(!(r<f.length))break;e=f[r];r=r+1;u.push(i.__string_rec(n[e],t))}return u}(this).join(",")+")"):l}if(n instanceof Array){for(u="[",t+="\t",s=0,a=n.length;s<a;)h=s++,u+=(h>0?",":"")+i.__string_rec(n[h],t);return u+"]"}try{e=n.toString}catch(s){return"???"}if(e!=null&&e!=Object.toString&&typeof e=="function"&&(c=n.toString(),c!="[object Object]"))return c;u="{\n";t+="\t";v=n.hasOwnProperty!=null;r=null;for(r in n)(!v||n.hasOwnProperty(r))&&r!="prototype"&&r!="__class__"&&r!="__super__"&&r!="__interfaces__"&&r!="__properties__"&&(u.length!=2&&(u+=", \n"),u+=t+r+" : "+i.__string_rec(n[r],t));return t=t.substring(1),u+("\n"+t+"}");case"string":return n;default:return String(n)}};i.__interfLoop=function(n,t){var r,u,e,o,f;if(n==null)return!1;if(n==t)return!0;if(r=n.__interfaces__,r!=null)for(u=0,e=r.length;u<e;)if(o=u++,f=r[o],f==t||i.__interfLoop(f,t))return!0;return i.__interfLoop(n.__super__,t)};i.__instanceof=function(n,t){if(t==null)return!1;switch(t){case Array:return n instanceof Array;case fr:return typeof n=="boolean";case rr:return n!=null;case ur:return typeof n=="number";case ir:return typeof n=="number"?(n|0)===n:!1;case String:return typeof n=="string";default:if(n!=null){if(typeof t=="function"){if(i.__downcastCheck(n,t))return!0}else if(typeof t=="object"&&i.__isNativeObj(t)&&n instanceof t)return!0}else return!1;return(t==er?n.__name__!=null:!1)?!0:(t==or?n.__ename__!=null:!1)?!0:n.__enum__!=null?yt[n.__enum__]==t:!1}};i.__downcastCheck=function(n,t){return n instanceof t?!0:t.__isInterface__?i.__interfLoop(i.getClass(n),t):!1};i.__cast=function(n,t){if(n==null||i.__instanceof(n,t))return n;throw d.thrown("Cannot cast "+s.string(n)+" to "+s.string(t));};i.__nativeClassName=function(n){var t=i.__toStr.call(n).slice(8,-1);return t=="Object"||t=="Function"||t=="Math"||t=="JSON"?null:t};i.__isNativeObj=function(n){return i.__nativeClassName(n)!=null};i.__resolveNativeClass=function(t){return n[t]};ht=function(){};ht.__name__=!0;ht.__properties__={get_supported:"get_supported"};ht.get_supported=function(){return typeof window!="undefined"&&typeof window.location!="undefined"?typeof window.location.protocol=="string":!1};ht.getLocalStorage=function(){var n,t;try{return n=window.localStorage,n.getItem(""),n.length==0&&(t="_hx_"+Math.random(),n.setItem(t,t),n.removeItem(t)),n}catch(i){return null}};ht.createXMLHttpRequest=function(){if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")return new ActiveXObject("Microsoft.XMLHTTP");throw d.thrown("Unable to create XMLHttpRequest object.");};wi=function(n){this.i=0;this.j=n};wi.__name__=!0;wi.prototype={hasNext:function(){return this.i<this.j.length},next:function(){return $(this.j[this.i++])},__class__:wi};bi=function(n){this.i=0;this.j=n};bi.__name__=!0;bi.prototype={hasNext:function(){return this.i<this.j.length},next:function(){return this.j[this.i++]},__class__:bi};ki=function(){this.pluralizationVar="_";this.varPrefix=":";this.depthDelimiter="/";this.trads={}};ki.__name__=!0;ki.prototype={loadFromString:function(n,t){for(var f=JSON.parse(n),r=0,e=h.fields(f),u,i;r<e.length;)u=e[r],++r,i=u,t!=null&&(i=t+i),this.update(this.trads,i,h.field(f,u))},tr:function(n,t){var u=n,i,f,e;if(n.indexOf(this.depthDelimiter)!=-1?(i=this.fetch(this.trads,new String(n)),i!=null&&(typeof i=="string"?u=s.string(i):t!=null&&Object.prototype.hasOwnProperty.call(t.h,this.pluralizationVar)&&Object.prototype.hasOwnProperty.call(i,this.pluralizationVar)&&(f=t.h[this.pluralizationVar],f!=null&&(f==0&&Object.prototype.hasOwnProperty.call(i,"0")?u=h.field(i,"0"):f==1&&Object.prototype.hasOwnProperty.call(i,"1")?u=h.field(i,"1"):Object.prototype.hasOwnProperty.call(i,this.pluralizationVar)&&(u=h.field(i,this.pluralizationVar)))))):Object.prototype.hasOwnProperty.call(this.trads,n)==!0&&(u=h.field(this.trads,n)),t!=null)for(var o=t.h,v=o,c=Object.keys(o),a=c.length,l=0;l<a;)e=c[l++],u=r.replace(u,this.varPrefix+e,s.string(t.h[e]));return u},clear:function(){this.trads={}},update:function(n,t,i){var e=t.indexOf(this.depthDelimiter),r,o,s,u,f,c;if(e==-1)if(Object.prototype.hasOwnProperty.call(n,t)==!0)for(n=h.field(n,t),r=0,o=h.fields(i);r<o.length;)s=o[r],++r,n[s]=h.field(i,s);else n[t]=i;else u=nt.substr(t,0,e),t=nt.substr(t,e+1,null),Object.prototype.hasOwnProperty.call(n,u)==!1?(c={},f=c,n[u]=f):f=h.field(n,u),this.update(f,t,i)},fetch:function(n,t){var i=t.indexOf(this.depthDelimiter),r;return i==-1?h.field(n,t):(r=nt.substr(t,0,i),t=nt.substr(t,i+1,null),Object.prototype.hasOwnProperty.call(n,r)==!1)?null:this.fetch(h.field(n,r),t)},__class__:ki};ui={};ui._new=function(){return{}};ui.set=function(n,t,i){n[t]=i};ui.get=function(n,t){return h.field(n,t)};ui.exists=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)};ui.keys=function(n){return h.fields(n)};rt=function(){};rt.__name__=!0;rt.getBook=function(n){var t=ht.getLocalStorage();return t.getItem(n)!=null?JSON.parse(t.getItem(n)):null};rt.save=function(n,t,i){var r=rt.getBook(n),u,f;r==null&&(r={});r[t]=i;u=ht.getLocalStorage();f=JSON.stringify(r);u.setItem(n,f)};rt.get=function(n,t){var i=rt.getBook(n);return i==null?null:h.field(i,t)};t=function(){var r=this,i=window._options,s,h,e,c,a,y;if(i==null)throw d.thrown("_options is not defined");t.options=i;s=new vt(i.LangFileJson);s.onData=function(n){t.i18n=new ki;t.i18n.loadFromString(n)};s.request();t.book=new ePub.Book(i.bookPath,{});t.book.request=gi.request;t.book.loaded.navigation.then(function(n){var u=n.toc,i;t.tocContent=u;r.updateChapterName(null);t.firstCFI=t.lastCFI=u[0].href;i="";t.book.package.navPath!=!1&&(i=t.book.package.navPath);t.book.package.ncxPath!=!1&&i==""&&(i=t.book.package.ncxPath);i!=""&&v.has([2,3],t.getOptions().accessType)?t.loadLinkMetadata(i,function(n){r.toc=new ni(t.rendition,u,n)}):r.toc=new ni(t.rendition,u,new lt)}).catch((ft=n.console,b(ft,ft.error)));t.book.loaded.metadata.then(function(){new hi(t.book,t.rendition)}).catch((ft=n.console,b(ft,ft.error)));t.rendition=t.book.renderTo("viewer",{});t.rendition.on("attached",function(){t.resizer=new li(t.rendition);var n=rt.get(i.isbn,"margin");n!=null&&t.setMargin(n)});h=window.location.hash;h!=""?t.rendition.display(nt.substr(h,1,null)):i.UserLastCFI!=""?t.rendition.display(i.UserLastCFI):t.rendition.display();window.addEventListener("hashchange",function(){if(!o.isLocked()){var n=window.location.hash;n!=""&&t.navigateToCFI(nt.substr(n,1,null))}});t.rendition.on("relocated",function(){var i=t.rendition.currentLocation(),n="#"+i.start.cfi;window.location.hash!=n&&window.history.pushState({},"",n)});t.rendition.on("relocated",function(){t.onPageChanged()});t.rendition.on("rendered",function(n){try{t.dispatchClickOnEmptyness();r.updateChapterName(n);r.toc.update(n.index)}catch(i){var u=d.caught(i).unwrap();console.log("src/reader/Main.hx:390:",u)}});t.rendition.on("layout",function(n){var t=window.document.getElementById("divider").classList;n.divisor>1?t.add("show"):t.remove("show")});t.applySize();t.book.loaded.metadata.then(function(n){window.document.getElementById("book-title").innerText=n.title;window.document.getElementById("book-author").innerText=n.creator;var t=n.title+" - ";window.document.title=t+n.creator}).catch((ft=n.console,b(ft,ft.error)));u.configure(i.ssid,i.apiPath,i.isbn,i.storeId,t.ACCESS_MODE);t.pageNav=new it(t.rendition);t.bookmarkManager=new si;new ci;fi.init(t.rendition);f.getUser().addUpdateListener(function(n){var t=l.formatFloat(n.walletBalance),i=n.identified?"block":"none";window.document.getElementById("wallet").style.display=i;window.document.getElementById("walletAmount").innerText=t});f.getUser().addUpdateListener(function(){ti.checkAlmostEmpty()});window.document.getElementById("wallet").addEventListener("click",function(){o.lock();new ut("rechargeWallet")});n.navigator.userAgent.toLowerCase().indexOf("iphone")!=-1?window.document.getElementById("fullscreen").style.display="none":window.document.getElementById("fullscreen").addEventListener("click",function(){screenfull.isEnabled&&(screenfull.isFullscreen?screenfull.exit():screenfull.request())});window.document.getElementById("return")!=null&&window.document.getElementById("return").addEventListener("click",function(){u.request("ReturnLoan",null,null,function(n){var t="",r;i.ReturnUrl!=null&&(r=i.ReturnUrl,t+="?ref="+encodeURIComponent(r));window.location.href=n=="0"?"/home/message/LoanDownloadMustBeReturn"+t:"/home/message/LoanReturned"+t})});i.user!=null&&(e=f.getUser(),e.identified=!0,e.login=i.user.login,e.walletBalance=i.user.walletBalance,e.onUpdate());c=rt.get(i.isbn,"size");c!=null&&(t.currentSize=parseFloat(c),t.applySize());a=rt.get("global","theme");a!=null&&t.setTheme(a);i.accessType==1&&(y=new at(1e4),y.run=function(){u.request("keepAlive")});i.startupAction=="Buy"&&(o.lock(),new ut("buyBook"))};t.__name__=!0;t.getOptions=function(){return t.options};t.increaseSize=function(){t.currentSize+=.1;rt.save(t.options.isbn,"size",s.string(t.currentSize));t.applySize()};t.decreaseSize=function(){t.currentSize-=.1;t.currentSize<.5&&(t.currentSize=.5);rt.save(t.options.isbn,"size",s.string(t.currentSize));t.applySize()};t.applySize=function(){t.rendition.themes.fontSize(""+t.currentSize+"em");t.rendition.themes.default({"*":{"line-height":"1.5em !important",position:"static !important"},body:{padding:"0 !important"}});t.rendition.themes.override("padding-left","0",!0);t.rendition.themes.override("padding-right","0",!0)};t.setTheme=function(n){var t=window.document.getElementById("viewer");t.style.filter="";n=="revert"?(window.document.body.classList.remove("theme-sepia"),window.document.body.classList.add("theme-revert"),t.style.filter="invert(100%)"):n=="sepia"?(window.document.body.classList.remove("theme-revert"),window.document.body.classList.add("theme-sepia")):(window.document.body.classList.remove("theme-sepia"),window.document.body.classList.remove("theme-revert"))};t.setMargin=function(n){n=="big"?(t.rendition.manager.settings.gap=150,t.resizer.setAdditionalWidth(150),t.resizer.setMargin(10)):n=="medium"?(t.rendition.manager.settings.gap=70,t.resizer.setAdditionalWidth(70),t.resizer.setMargin(7)):n=="small"&&(t.rendition.manager.settings.gap=20,t.resizer.setAdditionalWidth(20),t.resizer.setMargin(4));t.rendition.manager.updateLayout()};t.getChapterLabel=function(){return t.chapterLabel};t.getChapterHref=function(){return t.chapterHref};t.getPageNav=function(){return t.pageNav};t.getFirstCFI=function(){return t.firstCFI};t.setLastCFI=function(n){t.lastCFI=n};t.getLastCFI=function(){return t.lastCFI};t.getRendition=function(){return t.rendition};t.getBook=function(){return t.book};t.getChapterHrefFromFilename=function(n){var i=null;return i=function(t){for(var u=0,r,f,e;u<t.length;){if(r=t[u],++u,r.subitems!=null&&(f=i(r.subitems),f!=null))return f;if(e=r.href.split("/"),e[e.length-1]==n)return r.href}return null},i(t.tocContent)};t.getChapterLabelFromFilename=function(n){var i=null;return i=function(t){for(var u=0,r,f,e;u<t.length;){if(r=t[u],++u,r.subitems!=null&&(f=i(r.subitems),f!=null))return f;if(e=r.href.split("/"),e[e.length-1]==n)return r.label}return null},i(t.tocContent)};t.navigateToCFI=function(n){tt.showLoader();t.rendition.display(n)};t.nextPage=function(){tt.showLoader();t.rendition.next()};t.prevPage=function(){tt.showLoader();t.rendition.prev()};t.cancelEvent=function(n){return n.preventDefault(),!1};t.dispatchClickOnEmptyness=function(){var t=i.__cast(window.document.getElementById("viewer").querySelector("iframe"),HTMLIFrameElement),n=null;n=function(t){if(t==null)return!1;if(t.nodeName=="A")return t.getAttribute("href")!=null?!0:!1;var i=t.parentElement;return i!=null?n(i):!1};t.contentWindow.addEventListener("click",function(t){var u=!1,e=t.target,i,r,f;if(!n(e)){for(i=0,r=h.fields(t.target);i<r.length;)if(f=r[i],++i,f=="onclick"){u=!0;break}u||window.parent.postMessage({eventType:"click"},"*")}})};t.patchImages=function(){var o=i.__cast(window.document.getElementById("viewer").querySelector("iframe"),HTMLIFrameElement),n=o.contentDocument,f=n.querySelectorAll("img"),r,e,u;for(n.body.addEventListener("copy",t.cancelEvent),n.body.addEventListener("cut",t.cancelEvent),new ai(n),r=0;r<f.length;)e=f[r],++r,u=[i.__cast(e,HTMLImageElement)],u[0].style.cursor="pointer",u[0].addEventListener("click",function(n){return function(){var t=n[0].src;window.document.querySelector(".modal-dialog").classList.add("modal-lg");window.document.getElementById("modal-content").innerHTML='\r\n\t\t\t\t\t<div class="modal-header">\r\n\t\t\t\t\t\t<button type="button" class="close" data-dismiss="modal">&times;<\/button>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<div class="modal-body">\r\n\t\t\t\t\t\t<img src="'+t+'" width="100%" />\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t';y.show(!0)}}(u));v.has([2,3],t.getOptions().accessType)&&t.patchLinks(n)};t.loadLinkMetadata=function(n,i){var r=n.split("."),f;r.pop();f=r.join(".")+"-metadata.json";u.request(t.book.resolve(f),null,null,function(n){for(var u=JSON.parse(n),f=new lt,t=0,e=h.fields(u),r;t<e.length;)r=e[t],++t,f.h[r]=h.field(u,r);i(f)})};t.patchLinks=function(n){t.loadLinkMetadata(t.chapterHref,function(r){for(var s=!1,h=r.h,v=h,c=Object.keys(h),y=c.length,l=0,f,o,u,e;l<y;){u=v[c[l++]];s=!0;break}if(s)for(f=0,o=n.querySelectorAll("a[href]");f<o.length;)u=o[f],++f,e=[i.__cast(u,HTMLAnchorElement)],e[0].onclick=null,e[0].addEventListener("click",function(n){return function(i){var u=n[0].getAttribute("href"),f;return Object.prototype.hasOwnProperty.call(r.h,u)?(f=r.h[u],a.buyPage(f.page_num,function(){return function(){t.rendition.display(u)}}())):t.rendition.display(u),i.preventDefault(),!1}}(e))})};t.onPageChanged=function(){if(!o.isLocked()){tt.hideLoader();var n=t.rendition.currentLocation();t.getOptions().accessType==4?window.document.querySelector(".TitleBookProgress").style.display="none":a.reqLastPosition(n);t.bookmarkManager.isBookmarked(n.start.cfi)}};t.main=function(){window.document.addEventListener("DOMContentLoaded",function(){new t})};t.prototype={updateChapterName:function(n){var u;if(t.tocContent!=null&&n!=null){t.chapterHref=n.href;for(var i="",f=0,e=t.tocContent.length;f<e;)if(u=f++,u==n.index){i=t.tocContent[u].label;break}window.document.getElementById("chapter-title").innerText=r.replace(i,"\n","");t.chapterLabel=i}},__class__:t};fi=function(){};fi.__name__=!0;fi.check=function(){var n=window.document.createElement("div");return n.innerHTML='<math><mspace height="20px" width="20px"><\/mspace><\/math>',window.document.body.appendChild(n),n.firstChild.firstChild.getBoundingClientRect().height==20};fi.init=function(n){if(!fi.check())n.on("rendered",function(){var t=i.__cast(window.document.getElementById("viewer").querySelector("iframe"),HTMLIFrameElement),n;t.contentDocument.querySelectorAll("math").length>0&&(n=window.document.createElement("script"),n.src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML",t.contentDocument.querySelector("head").appendChild(n))})};gi=function(){};gi.__name__=!0;gi.request=function(n,i){(i==!1||i==null)&&(i=n.split(".").pop());var r=new ePub.utils.defer;return u.request(n,null,null,function(t){i=="xml"||i=="opf"||i=="ncx"?t=(new DOMParser).parseFromString(t,"application/xml"):i=="xhtml"?t=(new DOMParser).parseFromString(t,"application/xhtml+xml"):i=="html"||i=="htm"?t=(new DOMParser).parseFromString(t,"text/html"):console.log("src/reader/Overrides.hx:33:","UNKNOWN TYPE FOR RESSOURCE "+n+" : "+s.string(i));r.resolve(t)},function(n){r.reject(n);n=="Http Error #500"&&t.getRendition().display(t.getFirstCFI())}),r.promise};u=function(){};u.__name__=!0;u.configure=function(n,t,i,r,f){u.session_id=n;u.base_path=t;u.isbn=i;u.storeId=r;u.accessType=f};u.getStoreId=function(){return u.storeId};u.getAccessType=function(){return u.accessType};u.request=function(n,t,i,f,e){var c,l,a,v;i==null&&(i="POST");r.startsWith(n,"http")||(n=u.base_path+n);var o=new vt(n),y={sessionId:u.session_id,tNow:(new Date).getTime()},p=KJUR.jws.JWS.sign("HS256",JSON.stringify({alg:"HS256",typ:"JWT"}),JSON.stringify(y),{b64:"ZOlteXN0aWZpY2F0ZXVycw=="}),s=[];if(t!=null)for(c=0,l=h.fields(t);c<l.length;)a=l[c],++c,v=h.getProperty(t,a),s.push(a+"="+encodeURIComponent(v));s.push("kojtne="+p);s.push("ISBN="+u.isbn);s.push("storeId="+u.storeId);o.setPostData(s.join("&"));o.setHeader("Content-type","application/x-www-form-urlencoded");f!=null&&(o.onData=f);e!=null&&(o.onError=e);o.request(i=="POST")};e=function(n){this.infos=n};e.__name__=!0;e.refreshBookInfo=function(){e.currentBook=null};e.getCoverUrl=function(n,t){return t==null&&(t=150),r.replace(n.bookMeta.cover,"%width",t==null?"null":""+t)};e.getBookInfo=function(n){if(e.currentBook!=null){n(e.currentBook.infos);return}u.request("infoBook",{accessType:s.string(t.getOptions().accessType)},null,function(t){for(var i=JSON.parse(t),r=i.bookMeta.author,f=new Array(r.length),o=0,h=r.length,u,s;o<h;)u=o++,f[u]=r[u].LastName;i.bookMeta.authorString=f.join(", ");s=window.document.getElementsByClassName("Pagination")[0];i.bookMeta.totalPages>1&&(s.style.display="block");e.currentBook=new e(i);n(i)})};e.prototype={__class__:e};gt=function(){};gt.__name__=!0;gt.check=function(n){var t=new oi("^[0-9]{16}","");return t.match(n)?gt.luhnCheck(n):!1};gt.luhnCheck=function(n){for(var r=0,u=0,f=n.length,i,t;u<f;)i=u++,t=s.parseInt(nt.substr(n,i,1)),i%2==0&&(t*=2,t>9&&(t=1+t%10)),r+=t;return r%10==0};l=function(){};l.__name__=!0;l.formatFloat=function(n){return Number.parseFloat(n).toFixed(2)};ei=function(){};ei.__name__=!0;ei.getOrganisationList=function(n){u.request("GetUserOrganisationsWallets",{accessType:s.string(t.getOptions().accessType)},null,function(t){var i=JSON.parse(t);n(i)})};ei.setChoosenOrganisation=function(n,t){var i={accessType:s.string(u.getAccessType()),organisationId:n==null?"null":""+n};u.request("setUserOrganisationChoosenWallet",i,null,function(n){var i=JSON.parse(n);t(i.Balance)})};f=function(){this.organisationName=null;this.walletBalance=0;this.login=null;this.identified=!1;f.currentUser=this;this.updateEvents=[];this.userBookInfo={bookSpentAmount:0,bookAcquired:!1}};f.__name__=!0;f.getUser=function(){return f.currentUser==null&&new f,f.currentUser};f.prototype={addUpdateListener:function(n){this.updateEvents.push(n)},onUpdate:function(){for(var n=0,t=this.updateEvents,i;n<t.length;)i=t[n],++n,i(this)},__class__:f};tr=function(){};tr.__name__=!0;n.$haxeUID|=0;(typeof performance!="undefined"?typeof performance.now=="function":!1)&&(nt.now=performance.now.bind(performance));String.fromCodePoint==null&&(String.fromCodePoint=function(n){return n<65536?String.fromCharCode(n):String.fromCharCode((n>>10)+55232)+String.fromCharCode((n&1023)+56320)});String.prototype.__class__=String;String.__name__=!0;Array.__name__=!0;Date.prototype.__class__=Date;Date.__name__="Date";var ir={},rr={},ur=Number,fr=Boolean,er={},or={};i.__toStr={}.toString;di=typeof $!="undefined";di&&$.fn!=null&&($.fn.elements=function(){return new wi(this)});di=typeof $!="undefined";di&&$.fn!=null&&($.fn.iterator=function(){return new bi(this)});a.requestInProgress=!1;p.curPage=0;tt.loaderVisible=!1;c.cache=new lt;rt.GLOBAL_ISBN="global";t.currentSize=1.2;t.ACCESS_MODE=2;u.session_id="";u.base_path="";u.isbn="";u.storeId=0;u.accessType=0;t.main()})(typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this)