var e=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function l(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,l)}s((n=n.apply(e,t||[])).next())})},t=this&&this.__generator||function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(s){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1] img").attr("data-src"))||void 0===r?void 0:r.replace("/https","https");if(n){var i={name:o,cover:a,path:n};c.push(i)}}),[2,c]}})})},i.prototype.parseNovel=function(r){return e(this,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return[4,(0,n.fetchText)("".concat(this.serverUrl,"/api/novel?path=").concat(r))];case 1:return e=t.sent(),[2,JSON.parse(e)]}})})},i.prototype.parseChapter=function(r){return e(this,void 0,void 0,function(){var e,o,i;return t(this,function(t){switch(t.label){case 0:return e=Number(a.storage.get("lastFetchChapterTime_"+r))||0,Date.now()-e<1e4?[2,a.storage.get("chapterContent_"+r)||""]:[4,(0,n.fetchText)("".concat(this.serverUrl,"/api/chapter?path=").concat(r))];case 1:return o=t.sent(),i=JSON.parse(o),a.storage.set("lastFetchChapterTime_"+r,Date.now()),a.storage.set("chapterContent_"+r,i.content),[2,i.content]}})})},i.prototype.searchNovels=function(r){return e(this,void 0,void 0,function(){var e,o,i;return t(this,function(t){switch(t.label){case 0:return e=Number(a.storage.get("lastSearchTime_"+this.id))||0,Date.now()-e<5e3?[2,[]]:[4,(0,n.fetchText)("".concat(this.serverUrl,"/api/search?keyword=").concat(encodeURIComponent(r)))];case 1:return o=t.sent(),i=JSON.parse(o).results,a.storage.set("lastSearchTime_"+this.id,Date.now()),[2,i]}})})},i}();exports.default=new i;