var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)};
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
(function(a){function b(k){if(l[k])return l[k].exports;var f=l[k]={i:k,l:!1,exports:{}};a[k].call(f.exports,f,f.exports,b);f.l=!0;return f.exports}var l={};b.m=a;b.c=l;b.d=function(a,f,d){b.o(a,f)||Object.defineProperty(a,f,{configurable:!1,enumerable:!0,get:d})};b.n=function(a){var f=a&&a.__esModule?function(){return a["default"]}:function(){return a};b.d(f,"a",f);return f};b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};b.p="";return b(b.s=0)})([function(a,b,l){Object.defineProperty(b,
"__esModule",{value:!0});var k=self,f=l(1),d=function(){this.downloadQue=[];this.downloaded=[];this.lowresDownloaded=!1;this.downloadResponseCallbackList=[];this.queStop=!1};d.prototype.init=function(e,a){this.verdate=e;this.isIOSBrowser=a};d.prototype.start=function(e,a){if(0<e.length){this.downloads=e;for(var h=$jscomp.makeIterator(e),c=h.next();!c.done;c=h.next())this.downloadQue.push(c.value);a&&this.queUpdate(e[0].contentsdef,e[0].pageno,null,0)}};d.prototype.queUpdate=function(e,a,h,c){for(var b=
this,f=[],m=$jscomp.makeIterator(this.downloads),g=m.next();!g.done;g=m.next())g=g.value,g.base&&g.lowres?(f.push(g),g.reserved=!0):g.reserved=!1;m=[];var d=$jscomp.makeIterator(this.downloads);for(g=d.next();!g.done;g=d.next())g=g.value,g.reserved||(m.push(g),g.reserved=!0);g=[];this.orderingQue(e,a,h,f,g);this.orderingQue(e,a,h,m,g);this.downloadQue=[];e=$jscomp.makeIterator(g);for(a=e.next();!a.done;a=e.next())this.downloadQue.push(a.value);this.queStop=!0;0<c?(console.log("downloadContinue:::  \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306e\u958b\u59cb!!! ---  \u4e00\u6642\u505c\u6b62\u89e3\u9664\u5f85\u3061\uff1a"+
c),setTimeout(function(){b.downloadContinue()},c)):(console.log("downloadContinue:::  \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306e\u958b\u59cb!!! ---  (\u5373\u6642)"),this.downloadContinue());console.log("downloadContinue::: \u7d42\u4e86")};d.prototype.downloadResponsed=function(a){for(var e=0,b=$jscomp.makeIterator(this.downloadResponseCallbackList),c=b.next();!c.done;c=b.next()){c=c.value;if(c.url===a.que.url){c.callback(a.error,a.status);this.downloadResponseCallbackList.splice(e,1);break}e++}};
d.prototype.orderingQue=function(a,b,h,c,f){if(0!==c.length){var e=c.sort(function(a,e){return a.pageno-e.pageno});c=$jscomp.makeIterator(e);for(var d=c.next();!d.done;d=c.next());for(d=c=0;d<e.length;d++){var g=e[d];if(g.contentsdef.subjectuuid===a.subjectuuid&&g.contentsdef.unituuid===a.unituuid&&g.contentsdef.id===a.id&&b===g.pageno){c=d;break}}a=null;b=2*e.length;h=null!==h?2:1;var k=[];for(d=function(a){for(var c=0,b=0;b<e.length;b++){var d=e[b];d.pageno===a&&(c++,k.push(d),e.splice(b,1),b--)}return c};0<
e.length&&0<--b;)0>c?c=0:c>=e.length?c=e.length-h:(g=e[c],d(g.pageno),1<h&&c<e.length&&d(g.pageno),a=0===a?-h:0,c+=a);for(c=0;c<k.length;){a=!1;b=$jscomp.makeIterator(this.downloadQue);for(h=b.next();!h.done;h=b.next())if(k[c].url===h.value.url){a=!0;break}a||(k.splice(c,1),c--);c++}c=$jscomp.makeIterator(k);for(h=c.next();!h.done;h=c.next())f.push(h.value)}};d.prototype.downloadContinue=function(){for(var a=this,b=1,d=0,c=0,f={};0<b&&c<this.downloadQue.length;){var k=this.downloadQue[c];f.$jscomp$loop$prop$que$14=
k;k.downloadstarted=!0;d++;this.startDownloadFile(k,function(e){return function(b,c){if(0!==a.downloadQue.length&&!0===a.downloadQue[0].downloadstarted&&(a.downloadQue[0].downloadstarted=!1,a.downloadQue.splice(0,1),d--,0===d&&0<a.downloadQue.length&&!1===a.queStop&&a.downloadContinue(),e.$jscomp$loop$prop$que$14.base))try{a.downloadedMessage(e.$jscomp$loop$prop$que$14)}catch(p){}}}(f));if(!0===this.queStop){console.log("====== downloadContinue \u30ad\u30e5\u30fc\u306e\u4e2d\u6b62 .... \u6b8b\u4ef6:"+
this.downloadQue.length);this.queStop=!1;break}c++;b--;f={$jscomp$loop$prop$que$14:f.$jscomp$loop$prop$que$14}}};d.prototype.downloadedMessage=function(a){try{k.postMessage({type:f.SDL_MESSAGE_TYPE.DOWNLOADED,que:a})}catch(n){console.error(n)}};d.prototype.startDownloadFile=function(a,b){this.downloadResponseCallbackList.push({url:a.url,callback:b});try{k.postMessage({type:f.SDL_MESSAGE_TYPE.DL_REQUEST,que:a})}catch(h){console.error(h)}};$jscomp.global.Object.defineProperties(d,{instance:{configurable:!0,
enumerable:!0,get:function(){this.singletoninstance||(this.singletoninstance=new d);return this.singletoninstance}}});b.WorkerSyncDownload=d;k.addEventListener("message",function(a){a=a.data;switch(a.type){case f.SDL_MESSAGE_TYPE.INIT:d.instance.init(a.verdate,a.isIOSBrowser);break;case f.SDL_MESSAGE_TYPE.START:d.instance.start(a.downloads,a.start);break;case f.SDL_MESSAGE_TYPE.QUE_UPDATE:[a.contentsdef.subjectuuid,a.contentsdef.unituuid,a.contentsdef.id].join("/");d.instance.queUpdate(a.contentsdef,
a.pageno,a.nextpageno,void 0!==a.pausetime?a.pausetime:0);break;case f.SDL_MESSAGE_TYPE.DL_RESPONSED:d.instance.downloadResponsed(a)}})},function(a,b,l){Object.defineProperty(b,"__esModule",{value:!0});a=b.SDL_MESSAGE_TYPE||(b.SDL_MESSAGE_TYPE={});a[a.INIT=1]="INIT";a[a.START=2]="START";a[a.PAUSE=3]="PAUSE";a[a.RESEUM=4]="RESEUM";a[a.STOP=5]="STOP";a[a.QUE_UPDATE=6]="QUE_UPDATE";a[a.QUE_REPLACE=7]="QUE_REPLACE";a[a.DOWNLOADED=11]="DOWNLOADED";a[a.DL_REQUEST=21]="DL_REQUEST";a[a.DL_RESPONSED=22]="DL_RESPONSED"}]);
