trackkun-dom 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1 +1 @@
1
- (function(z,W){typeof exports=="object"&&typeof module<"u"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(z=typeof globalThis<"u"?globalThis:z||self,W(z._trackkun_={}))})(this,function(z){"use strict";function W(a){let t=!1;return new Promise((e,r)=>{Promise.all(a.map(async n=>{const l=await n;!t&&l&&(t=!0,e(l))})).then(()=>{t||e(void 0)})})}const pe={text:de,attr:ge,"attr-contain":he,value:fe,row:ve};function g(a,t={}){if(!a)return;const{root:e=document.documentElement,returnAll:r,preProcess:n}=t,l=X(a);if(l.length>1){for(let p=0;p<l.length;p+=1){const d=g(l[p],t);if(d!=null&&d.length)return d}return}const[o,i]=a.split("|");if(!i)return;const c=(i!=null&&i.startsWith("[")&&i.endsWith("]")?i.substring(1,i.length-1).split(","):[i]).map(p=>{const d=p.indexOf(":"),h=d!==-1;return{action:h?p.substring(0,d):p,param:h?p.substring(d+1):""}}),s=o?Array.from(e.querySelectorAll(o)):[e];if(!s.length)return r?[]:void 0;n&&n(s);const u=[];for(const p of s)for(const d of c){const h=pe[d.action],v=h(p,d.param);if(v){if(r){u.push(v);break}return v}}return r?u:void 0}function de(a){return Array.from(a.childNodes).filter(t=>t.nodeType===3).map(t=>q(t.textContent)).filter(Boolean).join(" ").trim()||q(a.textContent)}function ge(a,t){return q(a.getAttribute(t))}function he(a,t){let e=a.getAttribute(t);if(!e){const r=a.getAttributeNames().find(n=>n.includes(t));r&&(e=a.getAttribute(r))}return q(e)}function X(a){const t=[],e=a.split("||").map(r=>r.trim()).filter(Boolean);return e.forEach((r,n)=>{if(r.includes("|")){t.push(r);return}const l=e[n+1];l&&(e[n+1]=`${r},${l}`)}),t}function fe(a){return a.value}function ve(a,t){var e,r,n,l;if(!t)return;const o=(e=q(a.textContent))==null?void 0:e.toLowerCase(),i=t.toLowerCase();if(!(o!==i&&o!==`${i}:`))return q((l=(r=a.nextElementSibling)==null?void 0:r.textContent)!=null?l:(n=a.nextSibling)==null?void 0:n.textContent)}function q(a){if(a)return a?.replace(/(\n|\t)/g," ").trim()||void 0}async function dt(a,t,e){const r=await e(()=>{a=0});if(r!==void 0)return r;if(!(a<=0))return await new Promise(n=>{setTimeout(async()=>{const l=await dt(a-1,t,e);n(l)},t)})}async function C(a,t,e=0){var r;const n=(r=t.root)!=null?r:document.documentElement;return dt(t.lazy===!0?200:0,100,()=>{var l;const o=t.all===!0?Array.from(n.querySelectorAll(a)):(l=n.querySelector(a))!=null?l:void 0;return(t.all?!(o!=null&&o.length):!o)?void 0:o})}const me=/(vol(ume|\.)?\s*(\d+))/i,ye=/(ch(ap(t(er)?|\.)?|\.)?|^#)\s*(\d+([_-~,.]\d+)?)/i,we=/\d+([_-~,.]\d+)?/,be=/[_-~,]/,Oe=/^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g;function V(a,t){var e;if(!a||!a)return;if(!isNaN(+a))return{chap:+a};const r=a.match(me),n=r!=null&&r[0]?a.replace(r[0],"").trim():a,l=n.match(ye),o=n.match(we),i=(e=l?.[5])!=null?e:o?.[0];if(!i)return;const c=+i.replace(be,".");if(isNaN(c))return;const s=r?.[3],u=s&&!isNaN(+s)?+s:void 0,p=n.replace((l||o)[0],"").replace(Oe,""),d=t&&p.startsWith(t)?p.replace(t,""):p;return{vol:u,chap:c,label:d||void 0}}var Re=Object.defineProperty,gt=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,ht=(a,t,e)=>t in a?Re(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Pe=(a,t)=>{for(var e in t||(t={}))Se.call(t,e)&&ht(a,e,t[e]);if(gt)for(var e of gt(t))$e.call(t,e)&&ht(a,e,t[e]);return a};function ft(a,t){var e,r;const n=[...t],l=[];let o=-1,i=-1;for(let s=0;s<a.length&&!(!n.length&&s>=10);s++){const u=Pe({},a[s]),p=n.findIndex(v=>v.slug===u.slug&&v.name===u.name),d=p===-1?void 0:n.splice(p,1)[0],h=!d||((e=d.chapters[0])==null?void 0:e.chap)!==((r=u.chapters[0])==null?void 0:r.chap);p!==-1&&(i=s),h&&(o=s,u.changed=!0),l.push(u)}if(o===-1)return[];if(n.length&&n.length!==t.length){const s=Math.max(10,i+1);l.splice(s);for(let u=i+1;u<l.length;u++)l[u].changed=!1;return l}const c=Math.min(Math.max(o+1,10),Math.max(i+1,100));return l.slice(0,c)}function G(a,t){if(!(t!=null&&t.length))return;const e={};a.forEach(({id:n,name:l,altNames:o})=>{e[tt(l)]=n,o&&o.forEach(i=>{e[tt(i)]=n})});const r=t.map(n=>e[tt(n)]).filter(Boolean);return r.length===0?void 0:Array.from(new Set(r)).sort((n,l)=>n-l)}function tt(a){const t=a.toLowerCase().replaceAll(" ","");return t[t.length-1]==="s"?t.substring(0,t.length-1):t}function A(a){return a.sort((t,e)=>t.vol===void 0||e.vol===void 0?e.chap-t.chap:e.vol-t.vol||e.chap-t.chap),De(a)}function De(a){let t;for(let e=a.length-1;e>=0;e--){const r=a[e];r.vol!==void 0?t=r.vol:t!==void 0&&(r.inferVol=t)}return a}var je=Object.defineProperty,xe=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,mt=(a,t,e)=>t in a?je(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Me=(a,t)=>{for(var e in t||(t={}))Ce.call(t,e)&&mt(a,e,t[e]);if(vt)for(var e of vt(t))Ne.call(t,e)&&mt(a,e,t[e]);return a},Ue=(a,t)=>xe(a,Te(t));function yt(a,t){const e={};return a.forEach(r=>{Object.values(r.chapters.reduce((n,l)=>{const o=l.lang||t||"default";return n[o]||(n[o]=[]),n[o].push(l),n},{})).forEach(n=>{var l,o;const i=(o=(l=n[0])==null?void 0:l.lang)!=null?o:t,c=`${r.slug}:${i||""}`;e[c]?(e[c].chapters.push(...n),A(e[c].chapters)):e[c]=Ue(Me({},r),{lang:i})})}),Object.values(e)}const Be=[{regex:/(sec|giây)/,seconds:1},{regex:/(min|phút)/,seconds:60},{regex:/(hour|giờ)/,seconds:3600},{regex:/(day|ngày)/,seconds:86400},{regex:/(week|tuần)/,seconds:604800},{regex:/(month|tháng)/,seconds:2592e3},{regex:/(year|năm)/,seconds:31536e3}];function F(a){const t=a?.toLowerCase();if(!t||t.includes("now"))return Date.now();if(t.includes("yesterday"))return Date.now()-864e5;const e=new Date(t);if(e instanceof Date){const l=e.valueOf();if(!isNaN(l))return e.getHours()===0&&e.getMinutes()===0?Math.min(Date.now(),l+432e5):l}const r=Be.find(l=>l.regex.test(t));if(!r)return;const n=t.split(" ").filter(Boolean);for(let l=0;l<n.length;l++){const o=n[l],i=o==="a"||o==="an"?1:+o;if(!i)continue;if(i<0)return;const c=Date.now()-i*r.seconds*1e3;return c>0?c:void 0}}function H(a,t=location.origin){if(!a)return;const e=a.startsWith("//")?`${location.protocol}${a}`:a;return e.startsWith(t)?e.replace(t,""):e}function J(a,t){if(!a)return"/";const e=a.replace("{titleSlug}",t),r=e.endsWith("/")?e:e+"/";return r.startsWith("/")?r:"/"+r}function wt(a,{removeTrailingSlash:t=!0}={}){if(!a)return;const e=t&&a.endsWith("/")?a.slice(0,-1):a;try{return new URL(e)}catch{return}}function D(a){var t,e;if(!(!a||typeof a!="string"))return a.startsWith("http://")||a.startsWith("https://")?(t=wt(a))==null?void 0:t.pathname:a.startsWith("//")?(e=wt(`https:${a}`))==null?void 0:e.pathname:a}var j=(a=>(a.title="title",a.reader="reader",a.update="update",a.search="search",a))(j||{}),_e=Object.defineProperty,Ie=Object.defineProperties,Ae=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable,Rt=(a,t,e)=>t in a?_e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,et=(a,t)=>{for(var e in t||(t={}))bt.call(t,e)&&Rt(a,e,t[e]);if(Y)for(var e of Y(t))Ot.call(t,e)&&Rt(a,e,t[e]);return a},St=(a,t)=>Ie(a,Ae(t)),$t=(a,t)=>{var e={};for(var r in a)bt.call(a,r)&&t.indexOf(r)<0&&(e[r]=a[r]);if(a!=null&&Y)for(var r of Y(a))t.indexOf(r)<0&&Ot.call(a,r)&&(e[r]=a[r]);return e};let Ee=class pt{constructor(t){this.methodsMap={[j.title]:()=>this.getRawTitleData(),[j.reader]:()=>this.getRawReaderData(),[j.update]:()=>this.getRawUpdateData(),[j.search]:()=>this.getRawSearchData()};var e;this.spec=t.spec,this.siteMeta=t.siteMeta,this.tags=t.tags,this.oldRawUpdates=t.oldRawUpdates,this.getGlobalData=(e=t.getGlobalData)!=null?e:Le}async getRawPageByType(t){const e=await this.methodsMap[t](),r=location.origin+location.pathname;return{type:t,is404:pt._is404Page(this.spec),specId:this.spec.id,siteName:g(this.spec.name),url:r,data:e}}async getRawUpdateData(){var t,e;if(!((e=(t=this.spec)==null?void 0:t.update)!=null&&e.title))return;const r=this.spec.update.title,{chapter:n}=r,l=$t(r,["chapter"]);if(!l.sel||!l.name||!(n!=null&&n.sel)||!(n!=null&&n.label))return;const o=await C(l.sel,{lazy:!0,all:!0});if(!(o!=null&&o.length))return;const i=o.slice(0,100).map(s=>{const u=g(l.url,{root:s}),p=D(u),d=g(l.name,{root:s}),h=g(l.at,{root:s});if(!(!p||!d))return{titleEl:s,id:g(l.id,{root:s}),path:p,img:H(g(l.img,{root:s})),name:d,lang:g(l.lang,{root:s}),at:h?F(h):void 0}}).filter(Boolean);if(!i.length)return;const c=await Promise.all(i.map(async s=>{var u;const p=s,{path:d,titleEl:h,lang:v,at:w}=p,f=$t(p,["path","titleEl","lang","at"]),O=this.resolveTitleSlug(d),m=(u=await this.getRawChapters(n,{root:h,titleSlug:O,titleName:f?.name}))!=null?u:[];return et({slug:O,chapters:v||w?m.map(b=>{var R,$;return St(et({},b),{lang:(R=b.lang)!=null?R:v,ts:($=b.ts)!=null?$:w})}):m},f)}));return this.finalizeRawUpdateData({rawUpdates:c})}async getRawTitleData(){var t,e,r;if(!((t=this.spec)!=null&&t.title))return;const n=this.spec.title;if(!n.sel||!n.name||!await C(n.sel,{lazy:!!this.spec.title.lazy}))return;const l=g(n.name);if(!l)return;const o=this.resolveTitleSlug(location.pathname);if(!o)return;let i=(e=g(n.tags,{returnAll:!0}))!=null?e:[];i.length===1&&(i=i[0].split(",").map(u=>u.trim()).filter(Boolean));const c=g(n.type),s=g(n.langs,{returnAll:!0});return{id:g(n.id),url:location.origin+location.pathname,slug:o,name:l,langs:s!=null&&s.length?s:n.langs&&this.siteMeta.defaultLang?[this.siteMeta.defaultLang]:void 0,tags:G(this.tags,[...i??[],...c?[c]:[]]),img:H(g(n.img)),chapters:(r=await this.getRawChapters(n.chapter,{lazy:!0,titleSlug:o,titleName:l}))!=null?r:[]}}async getRawReaderData(){var t,e,r,n,l,o;const{spec:i,siteMeta:c}=this;if(!(i!=null&&i.reader)||!await pt._isReaderPage(i.reader))return;const s=i.reader.title,u=document.querySelector(s.sel);if(!u)return;const p=g(s.name,{root:u}),d=g(s.url,{root:u}),h=this.resolveTitleSlug(d);if(!p||!d||!h)return;const v=(e=await this.getRawChapters((t=i.reader)==null?void 0:t.chapter,{titleSlug:h,titleName:p}))!=null?e:[],w=(r=g(i.reader.label))==null?void 0:r.toLowerCase().replace(p.toLowerCase(),"");if(!w)return;const{vol:f,chap:O=0}=V(w,p)||{};let m;const b=(n=g(i.reader.img,{returnAll:!0,preProcess(x){const T=x.map(M=>+(M.getAttribute("height")||0)/+(M.getAttribute("width")||1));T.some(M=>M>2.5)?m=!0:T.filter(Boolean).length>Math.max(1,T.length-2)&&(m=!1)}}))!=null?n:[];if(!b.length)return;const R=J(c.readerBase,h),$=c.readerBase.split("/").indexOf("{lang}"),S=$!==-1?location.pathname.substring(1).split("/")[$]:void 0,P=S?R.replace("{lang}",S):R,y=(l=S??g(i.reader.lang))!=null?l:i.reader.lang?this.siteMeta.defaultLang:void 0;return{isWebtoon:m,vol:f,inferVol:(o=v.find(x=>x.vol===f&&x.chap===O))==null?void 0:o.inferVol,chap:O,lang:y,slug:this.resolveReaderSlug(P,location.pathname),nextSlug:this._findNeighborSlug({sel:i.reader.next,basePath:P}),prevSlug:this._findNeighborSlug({sel:i.reader.prev,basePath:P}),basePath:P,imgs:b,imgsLocator:i.reader.img,title:{id:g(s.id),url:d,slug:h,name:p,langs:y?[y]:void 0,chapters:v}}}async getRawSearchData(){var t;const e=(t=this.spec.search)==null?void 0:t.title;if(!e)return;const{chapter:r}=e,n=[];return await Promise.all(Array.from(document.querySelectorAll(e.sel)).map(async l=>{var o;const i=g(e.url,{root:l}),c=D(i),s=g(e.name,{root:l}),u=this.resolveTitleSlug(c);!c||!s||!u||n.push({slug:u,img:g(e.img,{root:l}),name:s,chapters:(o=await this.getRawChapters(r,{root:l,titleSlug:u,titleName:s}))!=null?o:[]})})),n.length?{rawUpdates:n}:void 0}async getRawChapters(t,{root:e=document.documentElement,titleSlug:r="",titleName:n,lazy:l=!0}){var o;if(!t)return;const i=[],c=await C(t.sel,{root:e,all:!0,lazy:l});if(!(c!=null&&c.length))return i;const s=(c??[]).map(f=>({id:g(t.id,{root:f}),label:g(t.label,{root:f}),url:g(t.url,{root:f}),at:g(t.at,{root:f})})),u=s.map(({label:f})=>V(f,n)),p=(o=u[1])==null?void 0:o.chap;!u[0]&&(p===void 0||p<=1)&&(u[0]={label:s[0].label,chap:0});const{readerBase:d}=this.siteMeta,h=J(d,r),v=d.split("/").indexOf("{lang}"),w=v!==-1;return u.forEach((f,O)=>{var m;if(!f)return;const{id:b,url:R,at:$}=s[O],S=D(R);if(!S)return;const P=w?S?.substring(1).split("/")[v]:void 0,y=this.resolveReaderSlug(P?h.replace("{lang}",P):h,S);i.push(St(et({},f),{id:b,slug:y,lang:P,ts:F($)||((m=i[i.length+1])==null?void 0:m.ts)||Date.now()}))}),A(i)}resolveReaderSlug(t,e){return e.startsWith(t)?e.replace(t,""):e}resolveTitleSlug(t){var e;if(typeof t!="string")return;const r=(e=D(t))==null?void 0:e.split("/").filter(Boolean);return!r||!r.length?t:r[r.length-1]}finalizeRawUpdateData(t){var e,r;const n=(r=(e=this.spec.update)==null?void 0:e.title)!=null&&r.lang?this.siteMeta.defaultLang:void 0,l=yt(t.rawUpdates,n);if(l.length)return{rawUpdates:this.oldRawUpdates?ft(l,this.oldRawUpdates):l}}static async _isReaderPage(t){const{sel:e,img:r}=t;if(!e||!r||!await C(e,{lazy:!!t.lazy}))return!1;const n=X(r).map(l=>l.split("|")[0]).join(",");return!!await C(n,{lazy:!0})}_findNeighborSlug({sel:t,basePath:e}){const r=g(t);if(!r||r.startsWith("#")||r.startsWith("/#"))return;const n=D(r);return n?this.resolveReaderSlug(e,n):void 0}static _is404Page(t){return t[404]&&document.querySelector(t[404])?!0:document.title.toLowerCase().includes("not found")}};async function Le(a){let t=window;const e={__html__:document.documentElement};for(let r=0;r<a.length;r++){const{attr:n,args:l}=a[r];if(!(n in t))return;t=l?t[n](...l.map(o=>{var i;return(i=e[o])!=null?i:o})):t[n]}return t===window?void 0:t}var ze=Object.defineProperty,We=Object.defineProperties,qe=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,Pt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,jt=(a,t,e)=>t in a?ze(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,at=(a,t)=>{for(var e in t||(t={}))Pt.call(t,e)&&jt(a,e,t[e]);if(Z)for(var e of Z(t))Dt.call(t,e)&&jt(a,e,t[e]);return a},xt=(a,t)=>We(a,qe(t)),Tt=(a,t)=>{var e={};for(var r in a)Pt.call(a,r)&&t.indexOf(r)<0&&(e[r]=a[r]);if(a!=null&&Z)for(var r of Z(a))t.indexOf(r)<0&&Dt.call(a,r)&&(e[r]=a[r]);return e};class B{constructor(t){this.methodsMap={[j.title]:()=>this.getRawTitleData(),[j.reader]:()=>this.getRawReaderData(),[j.update]:()=>this.getRawUpdateData(),[j.search]:()=>this.getRawSearchData()};var e;this.spec=t.spec,this.siteMeta=t.siteMeta,this.tags=t.tags,this.oldRawUpdates=t.oldRawUpdates,this.getGlobalData=(e=t.getGlobalData)!=null?e:ke}async getRawPageByType(t){const e=await this.methodsMap[t](),r=location.origin+location.pathname;return{type:t,is404:B._is404Page(this.spec),specId:this.spec.id,siteName:g(this.spec.name),url:r,data:e}}async getRawUpdateData(){var t,e;if(!((e=(t=this.spec)==null?void 0:t.update)!=null&&e.title))return;const r=this.spec.update.title,{chapter:n}=r,l=Tt(r,["chapter"]);if(!l.sel||!l.name||!(n!=null&&n.sel)||!(n!=null&&n.label))return;const o=await C(l.sel,{lazy:!0,all:!0});if(!(o!=null&&o.length))return;const i=o.slice(0,100).map(s=>{const u=g(l.url,{root:s}),p=D(u),d=g(l.name,{root:s}),h=g(l.at,{root:s});if(!(!p||!d))return{titleEl:s,id:g(l.id,{root:s}),path:p,img:H(g(l.img,{root:s})),name:d,lang:g(l.lang,{root:s}),at:h?F(h):void 0}}).filter(Boolean);if(!i.length)return;const c=await Promise.all(i.map(async s=>{var u;const p=s,{path:d,titleEl:h,lang:v,at:w}=p,f=Tt(p,["path","titleEl","lang","at"]),O=this.resolveTitleSlug(d),m=(u=await this.getRawChapters(n,{root:h,titleSlug:O,titleName:f?.name}))!=null?u:[];return at({slug:O,chapters:v||w?m.map(b=>{var R,$;return xt(at({},b),{lang:(R=b.lang)!=null?R:v,ts:($=b.ts)!=null?$:w})}):m},f)}));return this.finalizeRawUpdateData({rawUpdates:c})}async getRawTitleData(){var t,e,r;if(!((t=this.spec)!=null&&t.title))return;const n=this.spec.title;if(!n.sel||!n.name||!await C(n.sel,{lazy:!!this.spec.title.lazy}))return;const l=g(n.name);if(!l)return;const o=this.resolveTitleSlug(location.pathname);if(!o)return;let i=(e=g(n.tags,{returnAll:!0}))!=null?e:[];i.length===1&&(i=i[0].split(",").map(u=>u.trim()).filter(Boolean));const c=g(n.type),s=g(n.langs,{returnAll:!0});return{id:g(n.id),url:location.origin+location.pathname,slug:o,name:l,langs:s!=null&&s.length?s:n.langs&&this.siteMeta.defaultLang?[this.siteMeta.defaultLang]:void 0,tags:G(this.tags,[...i??[],...c?[c]:[]]),img:H(g(n.img)),chapters:(r=await this.getRawChapters(n.chapter,{lazy:!0,titleSlug:o,titleName:l}))!=null?r:[]}}async getRawReaderData(){var t,e,r,n,l,o;const{spec:i,siteMeta:c}=this;if(!(i!=null&&i.reader)||!await B._isReaderPage(i.reader))return;const s=i.reader.title,u=document.querySelector(s.sel);if(!u)return;const p=g(s.name,{root:u}),d=g(s.url,{root:u}),h=this.resolveTitleSlug(d);if(!p||!d||!h)return;const v=(e=await this.getRawChapters((t=i.reader)==null?void 0:t.chapter,{titleSlug:h,titleName:p}))!=null?e:[],w=(r=g(i.reader.label))==null?void 0:r.toLowerCase().replace(p.toLowerCase(),"");if(!w)return;const{vol:f,chap:O=0}=V(w,p)||{};let m;const b=(n=g(i.reader.img,{returnAll:!0,preProcess(x){const T=x.map(M=>+(M.getAttribute("height")||0)/+(M.getAttribute("width")||1));T.some(M=>M>2.5)?m=!0:T.filter(Boolean).length>Math.max(1,T.length-2)&&(m=!1)}}))!=null?n:[];if(!b.length)return;const R=J(c.readerBase,h),$=c.readerBase.split("/").indexOf("{lang}"),S=$!==-1?location.pathname.substring(1).split("/")[$]:void 0,P=S?R.replace("{lang}",S):R,y=(l=S??g(i.reader.lang))!=null?l:i.reader.lang?this.siteMeta.defaultLang:void 0;return{isWebtoon:m,vol:f,inferVol:(o=v.find(x=>x.vol===f&&x.chap===O))==null?void 0:o.inferVol,chap:O,lang:y,slug:this.resolveReaderSlug(P,location.pathname),nextSlug:this._findNeighborSlug({sel:i.reader.next,basePath:P}),prevSlug:this._findNeighborSlug({sel:i.reader.prev,basePath:P}),basePath:P,imgs:b,imgsLocator:i.reader.img,title:{id:g(s.id),url:d,slug:h,name:p,langs:y?[y]:void 0,chapters:v}}}async getRawSearchData(){var t;const e=(t=this.spec.search)==null?void 0:t.title;if(!e)return;const{chapter:r}=e,n=[];return await Promise.all(Array.from(document.querySelectorAll(e.sel)).map(async l=>{var o;const i=g(e.url,{root:l}),c=D(i),s=g(e.name,{root:l}),u=this.resolveTitleSlug(c);!c||!s||!u||n.push({slug:u,img:g(e.img,{root:l}),name:s,chapters:(o=await this.getRawChapters(r,{root:l,titleSlug:u,titleName:s}))!=null?o:[]})})),n.length?{rawUpdates:n}:void 0}async getRawChapters(t,{root:e=document.documentElement,titleSlug:r="",titleName:n,lazy:l=!0}){var o;if(!t)return;const i=[],c=await C(t.sel,{root:e,all:!0,lazy:l});if(!(c!=null&&c.length))return i;const s=(c??[]).map(f=>({id:g(t.id,{root:f}),label:g(t.label,{root:f}),url:g(t.url,{root:f}),at:g(t.at,{root:f})})),u=s.map(({label:f})=>V(f,n)),p=(o=u[1])==null?void 0:o.chap;!u[0]&&(p===void 0||p<=1)&&(u[0]={label:s[0].label,chap:0});const{readerBase:d}=this.siteMeta,h=J(d,r),v=d.split("/").indexOf("{lang}"),w=v!==-1;return u.forEach((f,O)=>{var m;if(!f)return;const{id:b,url:R,at:$}=s[O],S=D(R);if(!S)return;const P=w?S?.substring(1).split("/")[v]:void 0,y=this.resolveReaderSlug(P?h.replace("{lang}",P):h,S);i.push(xt(at({},f),{id:b,slug:y,lang:P,ts:F($)||((m=i[i.length+1])==null?void 0:m.ts)||Date.now()}))}),A(i)}resolveReaderSlug(t,e){return e.startsWith(t)?e.replace(t,""):e}resolveTitleSlug(t){var e;if(typeof t!="string")return;const r=(e=D(t))==null?void 0:e.split("/").filter(Boolean);return!r||!r.length?t:r[r.length-1]}finalizeRawUpdateData(t){var e,r;const n=(r=(e=this.spec.update)==null?void 0:e.title)!=null&&r.lang?this.siteMeta.defaultLang:void 0,l=yt(t.rawUpdates,n);if(l.length)return{rawUpdates:this.oldRawUpdates?ft(l,this.oldRawUpdates):l}}static async _isReaderPage(t){const{sel:e,img:r}=t;if(!e||!r||!await C(e,{lazy:!!t.lazy}))return!1;const n=X(r).map(l=>l.split("|")[0]).join(",");return!!await C(n,{lazy:!0})}_findNeighborSlug({sel:t,basePath:e}){const r=g(t);if(!r||r.startsWith("#")||r.startsWith("/#"))return;const n=D(r);return n?this.resolveReaderSlug(e,n):void 0}static _is404Page(t){return t[404]&&document.querySelector(t[404])?!0:document.title.toLowerCase().includes("not found")}}async function ke(a){let t=window;const e={__html__:document.documentElement};for(let r=0;r<a.length;r++){const{attr:n,args:l}=a[r];if(!(n in t))return;t=l?t[n](...l.map(o=>{var i;return(i=e[o])!=null?i:o})):t[n]}return t===window?void 0:t}class Ct extends B{resolveTitleSlug(t){var e;return(e=D(t))==null?void 0:e.split("/")[1]}}Ct.specId="bato";function Ve(){return Math.random().toString(16).slice(2)}async function Ge({addListener:a,removeListener:t,transform:e,filter:r,handler:n,onTimeout:l,timeout:o,once:i}){return new Promise(c=>{a(p);const s=()=>i===!0&&t(p),u=o?setTimeout(()=>{s(),c(void 0),l?.()},o):void 0;async function p(d,...h){d=e?e(d):d,d!==void 0&&(!r||r(d,...h))&&(s(),c(d),n?.(d,...h),u&&clearTimeout(u))}})}var Fe=Object.defineProperty,Nt=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Mt=(a,t,e)=>t in a?Fe(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Ye=(a,t)=>{for(var e in t||(t={}))He.call(t,e)&&Mt(a,e,t[e]);if(Nt)for(var e of Nt(t))Je.call(t,e)&&Mt(a,e,t[e]);return a};async function Ze(a){const t=await Ge(Ye({addListener:e=>window.addEventListener("message",e),removeListener:e=>window.removeEventListener("message",e)},a));return t?.data}async function Ke(a){var t;const{receiverWindow:e,timeout:r,targetOrigin:n,event:l,args:o}=a,i={reqId:Ve(),event:l,args:o};(t=e||window)==null||t.postMessage(i,n??"*");const c=await Ze({filter:s=>{var u;return((u=s?.data)==null?void 0:u.resId)===i.reqId},timeout:r??3e4,once:!0});return c?.result}const _={isAny:!0};function N(a,...t){return Ke({event:"tk:fetchResult",args:{baseUrl:a,segments:t}})}function Qe(a){if(a)try{return JSON.parse(a)}catch{return}}var Xe=Object.defineProperty,ta=Object.defineProperties,ea=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertySymbols,aa=Object.prototype.hasOwnProperty,ra=Object.prototype.propertyIsEnumerable,Bt=(a,t,e)=>t in a?Xe(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,rt=(a,t)=>{for(var e in t||(t={}))aa.call(t,e)&&Bt(a,e,t[e]);if(Ut)for(var e of Ut(t))ra.call(t,e)&&Bt(a,e,t[e]);return a},nt=(a,t)=>ta(a,ea(t));class _t extends B{async getRawUpdateData(){const t="https://api.comick.app/",[e]=await Promise.all([N(t,"chapter")]);if(!e)return;const r=e.map(n=>{var l,o;const{vol:i,chap:c,hid:s,lang:u,updated_at:p,md_comics:d}=n,h=typeof c=="string"&&!isNaN(+c)?+c:void 0;if(typeof h!="number")return;const v=(o=(l=d.md_covers)==null?void 0:l[0])==null?void 0:o.b2key;return{id:d.id+"",slug:d.slug,name:d.title,img:typeof v=="string"?`https://meo.comick.pictures/${v}`:void 0,chapters:[{slug:s,vol:typeof i=="string"&&!isNaN(+i)?+i:void 0,chap:h,lang:u,ts:new Date(p).valueOf()}]}}).filter(Boolean);return super.finalizeRawUpdateData({rawUpdates:r})}async getRawTitleData(){var t,e,r,n;const l=await super.getRawTitleData();if(!l)return l;const o="https://api.comick.app/",[i]=await Promise.all([N(o,"comic",_,"chapters")]);if(!i)return l;const c=await na(l.slug),s=[];i.chapters.forEach(d=>{const{vol:h,chap:v,hid:w,lang:f,updated_at:O}=d,m=typeof v=="string"&&!isNaN(+v)?+v:void 0;typeof m!="number"||s.some(b=>b.vol==h&&b.chap===m&&b.lang===f)||s.push({slug:w,vol:typeof h=="string"&&!isNaN(+h)?+h:void 0,chap:m,lang:f,ts:new Date(O).valueOf()})});const u=g("h1 ~ div.text-sm span:first-child|row:demographic"),p=u?(t=G(this.tags,[u]))==null?void 0:t[0]:void 0;return p&&!((e=l.tags)!=null&&e.includes(p))&&((r=l.tags)==null||r.push(p),(n=l.tags)==null||n.sort((d,h)=>d-h)),nt(rt({},l),{id:c,hasMoreChapters:i.chapters.length<i.total,chapters:A(s)})}async getRawReaderData(){var t;const e=await super.getRawReaderData();if(!e)return e;const r=await N("/_next/data/",_,"comic",_),n=(t=r?.comic)==null?void 0:t.id;return nt(rt({},e),{title:nt(rt({},e.title),{id:n?n+"":void 0})})}}_t.specId="comick";async function na(a){var t,e,r,n,l,o,i;const c=(t=document.querySelector("script#__NEXT_DATA__"))==null?void 0:t.textContent,s=c?Qe(c):void 0;if(((e=s?.query)==null?void 0:e.slug)===a){const d=(l=(n=(r=s?.props)==null?void 0:r.pageProps)==null?void 0:n.comic)==null?void 0:l.id;return d?d+"":void 0}const u=await N("/_next/data/",_,"comic",a,"covers.json"),p=(i=(o=u?.pageProps)==null?void 0:o.comic)==null?void 0:i.id;return p?p+"":void 0}var la=Object.defineProperty,ia=Object.defineProperties,oa=Object.getOwnPropertyDescriptors,It=Object.getOwnPropertySymbols,sa=Object.prototype.hasOwnProperty,ua=Object.prototype.propertyIsEnumerable,At=(a,t,e)=>t in a?la(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,lt=(a,t)=>{for(var e in t||(t={}))sa.call(t,e)&&At(a,e,t[e]);if(It)for(var e of It(t))ua.call(t,e)&&At(a,e,t[e]);return a},it=(a,t)=>ia(a,oa(t));class Et extends B{resolveReaderSlug(t,e){return super.resolveReaderSlug(t,e).replace(/-page-\d{1,3}\.html$/,".html")}async getRawTitleData(){const t=await super.getRawTitleData();return t&&it(lt({},t),{chapters:Lt(await this.getVM(),t.slug)})}async getRawReaderData(){const t=await super.getRawReaderData();if(!t)return t;const e=await this.getVM();return it(lt({},t),{imgs:ca(e,t.imgs[0]),title:it(lt({},t.title),{chapters:Lt(e,t.title.slug)})})}getVM(){return this.getGlobalData([{attr:"angular"},{attr:"element",args:["__html__"]},{attr:"scope",args:[]},{attr:"vm"}])}}Et.specId="manga4life";function Lt(a,t){var e,r;return((r=(e=a?.Chapters)!=null?e:a?.CHAPTERS)!=null?r:[]).map(n=>{const l=+n.Chapter.substring(1)/10;return{slug:`${t}-chapter-${l}.html`,chap:l,ts:new Date(n.Date).valueOf()}})}function ca(a,t){let e=t.split(".").slice(-1)[0];e=e.length>=3&&e.length<=4?e:"png";try{const r=a.CurChapter.Chapter.slice(1,-1),n=a.CurChapter.Chapter[a.CurChapter.Chapter.length-1],l=n!=="0"?`${r}.${n}`:r,o=`https://${a.CurPathName}/manga/${a.IndexName}/${l}-`;return a.Pages.map(i=>{const c=(i+"").padStart(3,"0");return`${o}${c}.${e}`})}catch{return[]}}var pa=Object.defineProperty,da=Object.defineProperties,ga=Object.getOwnPropertyDescriptors,zt=Object.getOwnPropertySymbols,ha=Object.prototype.hasOwnProperty,fa=Object.prototype.propertyIsEnumerable,Wt=(a,t,e)=>t in a?pa(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,qt=(a,t)=>{for(var e in t||(t={}))ha.call(t,e)&&Wt(a,e,t[e]);if(zt)for(var e of zt(t))fa.call(t,e)&&Wt(a,e,t[e]);return a},kt=(a,t)=>da(a,ga(t));class Vt extends B{async getRawUpdateData(){const t="https://api.mangadex.org/",[e,r]=await Promise.all([N(t,"chapter"),N(t,"manga")]);if(!r||!e)return;const n={};r.data.forEach(({id:o,relationships:i})=>{var c;const s=i.find(({type:p})=>p==="cover_art"),u=(c=s?.attributes)==null?void 0:c.fileName;u&&(n[o]=`https://mangadex.org/covers/${o}/${u}`)});const l=e.data.map(({relationships:o,attributes:i,id:c})=>{const s=o.find(({type:d})=>d==="manga"),u=typeof i.volume=="string"?+i.volume:void 0,p=typeof i.chapter=="string"?+i.chapter:void 0;if(p)return{slug:s.id,name:Object.values(s.attributes.title)[0],img:n[s.id],chapters:[{slug:i.externalUrl||c,label:i.title||void 0,vol:u,chap:p,lang:i.translatedLanguage,ts:new Date(i.readableAt).valueOf()}]}}).filter(Boolean);return super.finalizeRawUpdateData({rawUpdates:l})}async getRawTitleData(){var t,e,r;const n="https://api.mangadex.org/manga/",[l,o]=await Promise.all([N(n,_),N(n,_,"feed")]);if(!l||!o)return;const i=(r=(e=(t=o.data)==null?void 0:t.map)==null?void 0:e.call(t,u=>{const{attributes:p,id:d}=u;if(typeof p!="object"||typeof d!="string"||!d)return;const{externalUrl:h,title:v,volume:w,chapter:f,translatedLanguage:O}=p;return{slug:h||d,label:v||void 0,vol:typeof w=="string"?+w:void 0,chap:typeof f=="string"?+f:void 0,lang:O||"en",ts:new Date(p.readableAt).valueOf()}}).filter(u=>u?.chap!=null))!=null?r:[],{data:c}=l;if(!c)return;const s=Gt({data:c,entryTags:this.tags});if(s)return kt(qt({},s),{chapters:A(i),hasMoreChapters:(o.total||0)>(o.limit||0)})}async getRawReaderData(){var t,e,r,n,l,o,i,c,s,u,p,d,h,v,w;const f="https://api.mangadex.org/",[O,m,b]=await Promise.all([N(f,"chapter",_),N(f,"at-home","server",_),N(f,"manga",_,"aggregate")]);if(!O||!m||!b)return;const R=O.data,{volume:$,chapter:S,externalUrl:P,translatedLanguage:y}=R.attributes||{},{baseUrl:x,chapter:{data:T,dataSaver:M,hash:za}}=m,se=(e=(t=R.relationships)==null?void 0:t.find)==null?void 0:e.call(t,U=>U.type==="manga");if(!se)return;const ue=Gt({data:se,entryTags:this.tags});if(!ue||typeof b.volumes!="object")return;const I=Object.values(b.volumes).map(({volume:U,chapters:Va})=>{const Ga=U==="none"||typeof U!="string"?void 0:+U;return Object.values(Va).map(({id:Fa,chapter:ct})=>typeof ct!="string"||ct==="none"?void 0:{vol:Ga,chap:+ct,slug:Fa})}).flat().filter(Boolean).reverse();if(typeof S!="string"||S==="none"){if(I.length)return;I.push({chap:0,slug:R.id})}A(I);const ut=I.findIndex(U=>U.slug===R.id),Q=(n=(r=R.relationships)==null?void 0:r.find)==null?void 0:n.call(r,U=>U.type==="scanlation_group"),Wa=x.endsWith("/")?x:x+"/",ce=!!((o=(l=localStorage.getItem("md"))==null?void 0:l.includes)!=null&&o.call(l,'"dataSaver":true')),qa=`${Wa}${ce?"data-saver":"data"}/`,ka=(u=(s=(c=(i=ce?M:T)!=null?i:[]).map)==null?void 0:s.call(c,U=>`${qa}${za}/${U}`))!=null?u:[];return{externalUrl:P,vol:typeof $=="string"?+$:void 0,inferVol:(p=I[ut])==null?void 0:p.inferVol,chap:+S||0,imgs:ka,lang:y,slug:R.id,prevSlug:(d=I[ut+1])==null?void 0:d.slug,nextSlug:(h=I[ut-1])==null?void 0:h.slug,basePath:"/chapter/",groupName:(v=Q?.attributes)==null?void 0:v.name,groupUrl:(w=Q?.attributes)==null?void 0:w.website,title:kt(qt({},ue),{chapters:I})}}resolveTitleSlug(t){var e;return(e=D(t))==null?void 0:e.split("/")[1]}}Vt.specId="mangadex";function Gt({data:a,entryTags:t}){var e,r,n,l,o;const{id:i,attributes:c,relationships:s}=a;if(!i||typeof i!="string"||typeof c!="object")return;const{title:u,availableTranslatedLanguages:p,altTitles:d,tags:h,contentRating:v}=c;if(typeof u!="object"||!Array.isArray(p))return;const w=Object.values(u)[0];if(!w||typeof w!="string")return;const f=va(),O=(r=(e=p?.map)==null?void 0:e.call(p,y=>typeof y=="string"?y:void 0).filter(Boolean))!=null?r:[],m=O.filter(y=>y&&(!f||f.includes(y))),b=(n=d?.map)==null?void 0:n.call(d,y=>{const[[x,T]=[]]=Object.entries(y);return{lang:x,name:T}}),R=(l=s?.find)==null?void 0:l.call(s,y=>y.type==="cover_art"),$=(o=R?.attributes)==null?void 0:o.fileName,S=$?`https://mangadex.org/covers/${i}/${$}`:void 0,P=(h||[]).map(y=>{var x,T;return(T=(x=y?.attributes)==null?void 0:x.name)==null?void 0:T.en}).concat(v).filter(Boolean);return{url:`${location.origin}/title/${i}`,slug:i,name:w,altNames:b,langs:m.length>0?m:O,img:S,tags:G(t,P),isWebtoon:h?.some(y=>y.attributes.name.en==="Long Strip")}}function va(){var a;const t=localStorage.getItem("md");if(t)try{const e=JSON.parse(t),r=(a=e?.userPreferences)==null?void 0:a.filteredLanguages;return r!=null&&r.length?r:void 0}catch{return}}var ma=(a=>(a[a.reading=1]="reading",a[a.paused=2]="paused",a[a.plan=3]="plan",a[a.completed=4]="completed",a[a.dropped=5]="dropped",a[a.deleted=6]="deleted",a))(ma||{}),ot=(a=>(a.id="id",a.name="name",a.slug="slug",a))(ot||{}),ya=(a=>(a[a.string=1]="string",a[a.number=2]="number",a[a.bool=3]="bool",a[a.selection=4]="selection",a))(ya||{}),wa=(a=>(a[a.pending=0]="pending",a[a.completed=1]="completed",a[a.offline=2]="offline",a[a.incompat=3]="incompat",a))(wa||{}),ba=(a=>(a[a.releases=1]="releases",a[a.img=2]="img",a))(ba||{});function Ft(a,t){const e=a[0]===t?a.substring(1):a;return e[e.length-1]===t?e.substring(0,e.length-1):e}var Oa=Object.defineProperty,Ra=Object.defineProperties,Sa=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertySymbols,$a=Object.prototype.hasOwnProperty,Pa=Object.prototype.propertyIsEnumerable,Jt=(a,t,e)=>t in a?Oa(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,E=(a,t)=>{for(var e in t||(t={}))$a.call(t,e)&&Jt(a,e,t[e]);if(Ht)for(var e of Ht(t))Pa.call(t,e)&&Jt(a,e,t[e]);return a},k=(a,t)=>Ra(a,Sa(t));class Yt extends B{async getRawUpdateData(){const t=await super.getRawUpdateData();if(t)return k(E({},t),{siteMeta:Da(this.spec.update,this.siteMeta)})}async getRawTitleData(){var t;const e=await super.getRawTitleData();if(!e)return;const r=L(location.pathname);let n;if((t=e.chapters)!=null&&t.length){const l=this.spec.title.chapter,o=document.querySelector(l.sel),i=D(g(l.url,{root:o}));i&&(n=L(i))}return k(E({},e),{siteMeta:K(this.siteMeta,{titleBase:r,readerBase:n})})}async getRawReaderData(){const t=await super.getRawReaderData();if(t)return k(E({},t),{siteMeta:K(this.siteMeta,{titleBase:L(D(t.title.url)),readerBase:L(location.pathname),idBase:Zt()}),title:k(E({},t.title),{id:await this.getReaderTitleId()})})}async getRawSearchData(){const t=await super.getRawSearchData();if(!t)return;const e=this.spec.search.title,r=document.querySelector(e.sel),n=g(e.url,{root:r});return k(E({},t),{siteMeta:K(this.siteMeta,{titleBase:L(D(n)),idBase:Zt()})})}async getReaderTitleId(){const t=await this.getGlobalData([{attr:"HISTORY"},{attr:"getStored",args:[]}]);if(!t||typeof t!="object")return;const e=Object.values(t).filter(Boolean);if(e.length)return e.sort((r,n)=>n.time-r.time),e[0].manga_ID}}Yt.specId="mangastream";function Da(a,t){var e,r;if(!a)return;const n=k(E({},t),{updatePath:Ft(location.pathname,"/")}),l=a.title,o=(e=document.querySelector(l.sel))!=null?e:void 0;if(!o)return;const i=D(g(l.url,{root:o}));if(i===void 0)return;const c=(r=o.querySelector(l.chapter.sel))!=null?r:void 0;if(!c)return;const s=D(g(l.chapter.url,{root:c}));if(s!==void 0)return n.titleBase=L(i),n.readerBase=L(s),t.titleIdType===ot.id&&(g(l.id,{root:o})||(t.titleIdType=ot.name)),K(t,n)}function Zt(){return document.querySelector('link[rel="shortlink"][href*="/?p="]')?"?p=":void 0}function K(a,t){const e=Object.keys(t),r=E({},a);let n=!1;return e.forEach(l=>{const o=t[l];o!==a[l]&&(r[l]=o,n=!0)}),n?r:void 0}function L(a){return Ft(a,"/").split("/").slice(0,-1).join("/")}var ja=Object.defineProperty,xa=Object.defineProperties,Ta=Object.getOwnPropertyDescriptors,Kt=Object.getOwnPropertySymbols,Ca=Object.prototype.hasOwnProperty,Na=Object.prototype.propertyIsEnumerable,Qt=(a,t,e)=>t in a?ja(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,st=(a,t)=>{for(var e in t||(t={}))Ca.call(t,e)&&Qt(a,e,t[e]);if(Kt)for(var e of Kt(t))Na.call(t,e)&&Qt(a,e,t[e]);return a},Xt=(a,t)=>xa(a,Ta(t));class te extends B{async getRawReaderData(){const t=await super.getRawReaderData();if(!t)return t;let e=t.title.id;if(!e){const r=this.spec.reader.title;r.id&&await C(r.id.split("|")[0],{lazy:!0}),e=g(r.id)}return Xt(st({},t),{title:Xt(st({},t.title),{id:e,chapters:await Ma(e)})})}resolveTitleSlug(t){const e=super.resolveTitleSlug(t);if(!e)return;const r=e.lastIndexOf("-"),n=+e.substring(r+1);return r===-1||isNaN(n)||n<1e3?e:e.substring(0,r)}}te.specId="nettruyen";async function Ma(a){var t;if(!a)return[];const e=await fetch(`/Comic/Services/ComicService.asmx/ProcessChapterList?comicId=${a}`).then(r=>r.status===200?r.json():void 0).catch(()=>[]);return(t=e?.chapters)!=null&&t.length?A(e.chapters.map(r=>{const{name:n,url:l}=r,o=V(n);if(!(!o||!l))return st({slug:D(l).split("/").filter(Boolean).slice(2).join("/")},o)})):[]}const Ua=[Ct,_t,Et,Vt,Yt,te];function ee(a){var t;const e=(t=Ua.find(r=>r.specId===a.spec.id))!=null?t:Ee;return new e(a)}var Ba=Object.defineProperty,_a=Object.defineProperties,Ia=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,Aa=Object.prototype.hasOwnProperty,Ea=Object.prototype.propertyIsEnumerable,re=(a,t,e)=>t in a?Ba(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,ne=(a,t)=>{for(var e in t||(t={}))Aa.call(t,e)&&re(a,e,t[e]);if(ae)for(var e of ae(t))Ea.call(t,e)&&re(a,e,t[e]);return a},le=(a,t)=>_a(a,Ia(t));async function La(a){var t,e;const{spec:r}=a;if(r){const n=(t=a.siteMeta)!=null?t:r.meta,l=a.type?[a.type]:ie(n,r.generic);if(!l.length)return;const o=ee(le(ne({},a),{spec:r,siteMeta:n}));return await W(l.map(i=>o.getRawPageByType(i)))}return await W(((e=a.genericSpecs)!=null?e:[]).map(n=>{const l=ie(n.meta,n.generic);if(!l.length)return[];const o=ee(le(ne({},a),{spec:n,siteMeta:n.meta}));return l.map(i=>o.getRawPageByType(i))}).flat())}function ie(a,t){if(location.pathname==="/")return[];const{titleBase:e,readerBase:r}=a,n=location.pathname.split("/").filter(Boolean),l=oe(n,r),o=oe(n,e);if(l!==o)return l>o?[j.reader]:[j.title];if(l>0)return[j.reader,j.title];if(n.length===1){const i=[!r&&j.reader,!e&&j.title].filter(Boolean);if(i.length)return i}return t?[j.reader,j.title]:[]}function oe(a,t){if(!t)return 0;const e=t.split("/").filter(Boolean);return a.length<=e.length?0:e.filter((r,n)=>a[n]===r||r==="{titleSlug}"||r==="{lang}").length}z.PageType=j,z.scrape=La});
1
+ (function(z,W){typeof exports=="object"&&typeof module<"u"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(z=typeof globalThis<"u"?globalThis:z||self,W(z._trackkun_={}))})(this,function(z){"use strict";function W(a){let t=!1;return new Promise((e,r)=>{Promise.all(a.map(async n=>{const l=await n;!t&&l&&(t=!0,e(l))})).then(()=>{t||e(void 0)})})}const pe={text:de,attr:ge,"attr-contain":he,value:fe,row:ve};function g(a,t={}){if(!a)return;const{root:e=document.documentElement,returnAll:r,preProcess:n}=t,l=X(a);if(l.length>1){for(let p=0;p<l.length;p+=1){const d=g(l[p],t);if(d!=null&&d.length)return d}return}const[o,i]=a.split("|");if(!i)return;const c=(i!=null&&i.startsWith("[")&&i.endsWith("]")?i.substring(1,i.length-1).split(","):[i]).map(p=>{const d=p.indexOf(":"),h=d!==-1;return{action:h?p.substring(0,d):p,param:h?p.substring(d+1):""}}),s=o?Array.from(e.querySelectorAll(o)):[e];if(!s.length)return r?[]:void 0;n&&n(s);const u=[];for(const p of s)for(const d of c){const h=pe[d.action],v=h(p,d.param);if(v){if(r){u.push(v);break}return v}}return r?u:void 0}function de(a){return Array.from(a.childNodes).filter(t=>t.nodeType===3).map(t=>q(t.textContent)).filter(Boolean).join(" ").trim()||q(a.textContent)}function ge(a,t){return q(a.getAttribute(t))}function he(a,t){let e=a.getAttribute(t);if(!e){const r=a.getAttributeNames().find(n=>n.includes(t));r&&(e=a.getAttribute(r))}return q(e)}function X(a){const t=[],e=a.split("||").map(r=>r.trim()).filter(Boolean);return e.forEach((r,n)=>{if(r.includes("|")){t.push(r);return}const l=e[n+1];l&&(e[n+1]=`${r},${l}`)}),t}function fe(a){return a.value}function ve(a,t){var e,r,n,l;if(!t)return;const o=(e=q(a.textContent))==null?void 0:e.toLowerCase(),i=t.toLowerCase();if(!(o!==i&&o!==`${i}:`))return q((l=(r=a.nextElementSibling)==null?void 0:r.textContent)!=null?l:(n=a.nextSibling)==null?void 0:n.textContent)}function q(a){if(a)return a?.replace(/(\n|\t)/g," ").trim()||void 0}async function dt(a,t,e){const r=await e(()=>{a=0});if(r!==void 0)return r;if(!(a<=0))return await new Promise(n=>{setTimeout(async()=>{const l=await dt(a-1,t,e);n(l)},t)})}async function C(a,t,e=0){var r;const n=(r=t.root)!=null?r:document.documentElement;return dt(t.lazy===!0?200:0,100,()=>{var l;const o=t.all===!0?Array.from(n.querySelectorAll(a)):(l=n.querySelector(a))!=null?l:void 0;return(t.all?!(o!=null&&o.length):!o)?void 0:o})}const me=/(vol(ume|\.)?\s*(\d+))/i,ye=/(ch(ap(t(er)?|\.)?|\.)?|^#)\s*(\d+([_-~,.]\d+)?)/i,we=/\d+([_-~,.]\d+)?/,be=/[_-~,]/,Oe=/^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g;function V(a,t){var e;if(!a||!a)return;if(!isNaN(+a))return{chap:+a};const r=a.match(me),n=r!=null&&r[0]?a.replace(r[0],"").trim():a,l=n.match(ye),o=n.match(we),i=(e=l?.[5])!=null?e:o?.[0];if(!i)return;const c=+i.replace(be,".");if(isNaN(c))return;const s=r?.[3],u=s&&!isNaN(+s)?+s:void 0,p=n.replace((l||o)[0],"").replace(Oe,""),d=t&&p.startsWith(t)?p.replace(t,""):p;return{vol:u,chap:c,label:d||void 0}}var Re=Object.defineProperty,gt=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,ht=(a,t,e)=>t in a?Re(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Pe=(a,t)=>{for(var e in t||(t={}))Se.call(t,e)&&ht(a,e,t[e]);if(gt)for(var e of gt(t))$e.call(t,e)&&ht(a,e,t[e]);return a};function ft(a,t){var e,r;const n=[...t],l=[];let o=-1,i=-1;for(let s=0;s<a.length&&!(!n.length&&s>=10);s++){const u=Pe({},a[s]),p=n.findIndex(v=>v.slug===u.slug&&v.name===u.name),d=p===-1?void 0:n.splice(p,1)[0],h=!d||((e=d.chapters[0])==null?void 0:e.chap)!==((r=u.chapters[0])==null?void 0:r.chap);p!==-1&&(i=s),h&&(o=s,u.changed=!0),l.push(u)}if(o===-1)return[];if(n.length&&n.length!==t.length){const s=Math.max(10,i+1);l.splice(s);for(let u=i+1;u<l.length;u++)l[u].changed=!1;return l}const c=Math.min(Math.max(o+1,10),Math.max(i+1,100));return l.slice(0,c)}function G(a,t){if(!(t!=null&&t.length))return;const e={};a.forEach(({id:n,name:l,altNames:o})=>{e[tt(l)]=n,o&&o.forEach(i=>{e[tt(i)]=n})});const r=t.map(n=>e[tt(n)]).filter(Boolean);return r.length===0?void 0:Array.from(new Set(r)).sort((n,l)=>n-l)}function tt(a){const t=a.toLowerCase().replaceAll(" ","");return t[t.length-1]==="s"?t.substring(0,t.length-1):t}function A(a){return a.sort((t,e)=>t.vol===void 0||e.vol===void 0?e.chap-t.chap:e.vol-t.vol||e.chap-t.chap),De(a)}function De(a){let t;for(let e=a.length-1;e>=0;e--){const r=a[e];r.vol!==void 0?t=r.vol:t!==void 0&&(r.inferVol=t)}return a}var je=Object.defineProperty,xe=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,mt=(a,t,e)=>t in a?je(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Me=(a,t)=>{for(var e in t||(t={}))Ce.call(t,e)&&mt(a,e,t[e]);if(vt)for(var e of vt(t))Ne.call(t,e)&&mt(a,e,t[e]);return a},Ue=(a,t)=>xe(a,Te(t));function yt(a,t){const e={};return a.forEach(r=>{Object.values(r.chapters.reduce((n,l)=>{const o=l.lang||t||"default";return n[o]||(n[o]=[]),n[o].push(l),n},{})).forEach(n=>{var l,o;const i=(o=(l=n[0])==null?void 0:l.lang)!=null?o:t,c=`${r.slug}:${i||""}`;e[c]?(e[c].chapters.push(...n),A(e[c].chapters)):e[c]=Ue(Me({},r),{lang:i})})}),Object.values(e)}const Be=[{regex:/(sec|giây)/,seconds:1},{regex:/(min|phút)/,seconds:60},{regex:/(hour|giờ)/,seconds:3600},{regex:/(day|ngày)/,seconds:86400},{regex:/(week|tuần)/,seconds:604800},{regex:/(month|tháng)/,seconds:2592e3},{regex:/(year|năm)/,seconds:31536e3}];function F(a){const t=a?.toLowerCase();if(!t||t.includes("now"))return Date.now();if(t.includes("yesterday"))return Date.now()-864e5;const e=new Date(t);if(e instanceof Date){const l=e.valueOf();if(!isNaN(l))return e.getHours()===0&&e.getMinutes()===0?Math.min(Date.now(),l+432e5):l}const r=Be.find(l=>l.regex.test(t));if(!r)return;const n=t.split(" ").filter(Boolean);for(let l=0;l<n.length;l++){const o=n[l],i=o==="a"||o==="an"?1:+o;if(!i)continue;if(i<0)return;const c=Date.now()-i*r.seconds*1e3;return c>0?c:void 0}}function H(a,t=location.origin){if(!a)return;const e=a.startsWith("//")?`${location.protocol}${a}`:a;return e.startsWith(t)?e.replace(t,""):e}function J(a,t){if(!a)return"/";const e=a.replace("{titleSlug}",t),r=e.endsWith("/")?e:e+"/";return r.startsWith("/")?r:"/"+r}function wt(a,{removeTrailingSlash:t=!0}={}){if(!a)return;const e=t&&a.endsWith("/")?a.slice(0,-1):a;try{return new URL(e)}catch{return}}function D(a){var t,e;if(!(!a||typeof a!="string"))return a.startsWith("http://")||a.startsWith("https://")?(t=wt(a))==null?void 0:t.pathname:a.startsWith("//")?(e=wt(`https:${a}`))==null?void 0:e.pathname:a}var j=(a=>(a.title="title",a.reader="reader",a.update="update",a.search="search",a))(j||{}),_e=Object.defineProperty,Ie=Object.defineProperties,Ae=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable,Rt=(a,t,e)=>t in a?_e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,et=(a,t)=>{for(var e in t||(t={}))bt.call(t,e)&&Rt(a,e,t[e]);if(Y)for(var e of Y(t))Ot.call(t,e)&&Rt(a,e,t[e]);return a},St=(a,t)=>Ie(a,Ae(t)),$t=(a,t)=>{var e={};for(var r in a)bt.call(a,r)&&t.indexOf(r)<0&&(e[r]=a[r]);if(a!=null&&Y)for(var r of Y(a))t.indexOf(r)<0&&Ot.call(a,r)&&(e[r]=a[r]);return e};let Ee=class pt{constructor(t){this.methodsMap={[j.title]:()=>this.getRawTitleData(),[j.reader]:()=>this.getRawReaderData(),[j.update]:()=>this.getRawUpdateData(),[j.search]:()=>this.getRawSearchData()};var e;this.spec=t.spec,this.siteMeta=t.siteMeta,this.tags=t.tags,this.oldRawUpdates=t.oldRawUpdates,this.getGlobalData=(e=t.getGlobalData)!=null?e:Le}async getRawPageByType(t){const e=await this.methodsMap[t](),r=location.origin+location.pathname;return{type:t,is404:pt._is404Page(this.spec),specId:this.spec.id,siteName:g(this.spec.name),url:r,data:e}}async getRawUpdateData(){var t,e;if(!((e=(t=this.spec)==null?void 0:t.update)!=null&&e.title))return;const r=this.spec.update.title,{chapter:n}=r,l=$t(r,["chapter"]);if(!l.sel||!l.name||!(n!=null&&n.sel)||!(n!=null&&n.label))return;const o=await C(l.sel,{lazy:!0,all:!0});if(!(o!=null&&o.length))return;const i=o.slice(0,100).map(s=>{const u=g(l.url,{root:s}),p=D(u),d=g(l.name,{root:s}),h=g(l.at,{root:s});if(!(!p||!d))return{titleEl:s,id:g(l.id,{root:s}),path:p,img:H(g(l.img,{root:s})),name:d,lang:g(l.lang,{root:s}),at:h?F(h):void 0}}).filter(Boolean);if(!i.length)return;const c=await Promise.all(i.map(async s=>{var u;const p=s,{path:d,titleEl:h,lang:v,at:w}=p,f=$t(p,["path","titleEl","lang","at"]),O=this.resolveTitleSlug(d),m=(u=await this.getRawChapters(n,{root:h,titleSlug:O,titleName:f?.name}))!=null?u:[];return et({slug:O,chapters:v||w?m.map(b=>{var R,$;return St(et({},b),{lang:(R=b.lang)!=null?R:v,ts:($=b.ts)!=null?$:w})}):m},f)}));return this.finalizeRawUpdateData({rawUpdates:c})}async getRawTitleData(){var t,e,r;if(!((t=this.spec)!=null&&t.title))return;const n=this.spec.title;if(!n.sel||!n.name||!await C(n.sel,{lazy:!!this.spec.title.lazy}))return;const l=g(n.name);if(!l)return;const o=this.resolveTitleSlug(location.pathname);if(!o)return;let i=(e=g(n.tags,{returnAll:!0}))!=null?e:[];i.length===1&&(i=i[0].split(",").map(u=>u.trim()).filter(Boolean));const c=g(n.type),s=g(n.langs,{returnAll:!0});return{id:g(n.id),url:location.origin+location.pathname,slug:o,name:l,langs:s!=null&&s.length?s:n.langs&&this.siteMeta.defaultLang?[this.siteMeta.defaultLang]:void 0,tags:G(this.tags,[...i??[],...c?[c]:[]]),img:H(g(n.img)),chapters:(r=await this.getRawChapters(n.chapter,{lazy:!0,titleSlug:o,titleName:l}))!=null?r:[]}}async getRawReaderData(){var t,e,r,n,l,o;const{spec:i,siteMeta:c}=this;if(!(i!=null&&i.reader)||!await pt._isReaderPage(i.reader))return;const s=i.reader.title,u=document.querySelector(s.sel);if(!u)return;const p=g(s.name,{root:u}),d=g(s.url,{root:u}),h=this.resolveTitleSlug(d);if(!p||!d||!h)return;const v=(e=await this.getRawChapters((t=i.reader)==null?void 0:t.chapter,{titleSlug:h,titleName:p}))!=null?e:[],w=(r=g(i.reader.label))==null?void 0:r.toLowerCase().replace(p.toLowerCase(),"");if(!w)return;const{vol:f,chap:O=0}=V(w,p)||{};let m;const b=(n=g(i.reader.img,{returnAll:!0,preProcess(x){const T=x.map(M=>+(M.getAttribute("height")||0)/+(M.getAttribute("width")||1));T.some(M=>M>2.5)?m=!0:T.filter(Boolean).length>Math.max(1,T.length-2)&&(m=!1)}}))!=null?n:[];if(!b.length)return;const R=J(c.readerBase,h),$=c.readerBase.split("/").indexOf("{lang}"),S=$!==-1?location.pathname.substring(1).split("/")[$]:void 0,P=S?R.replace("{lang}",S):R,y=(l=S??g(i.reader.lang))!=null?l:i.reader.lang?this.siteMeta.defaultLang:void 0;return{isWebtoon:m,vol:f,inferVol:(o=v.find(x=>x.vol===f&&x.chap===O))==null?void 0:o.inferVol,chap:O,lang:y,slug:this.resolveReaderSlug(P,location.pathname),nextSlug:this._findNeighborSlug({sel:i.reader.next,basePath:P}),prevSlug:this._findNeighborSlug({sel:i.reader.prev,basePath:P}),basePath:P,imgs:b,imgsLocator:i.reader.img,title:{id:g(s.id),url:d,slug:h,name:p,langs:y?[y]:void 0,chapters:v}}}async getRawSearchData(){var t;const e=(t=this.spec.search)==null?void 0:t.title;if(!e)return;const{chapter:r}=e,n=[];return await Promise.all(Array.from(document.querySelectorAll(e.sel)).map(async l=>{var o;const i=g(e.url,{root:l}),c=D(i),s=g(e.name,{root:l}),u=this.resolveTitleSlug(c);!c||!s||!u||n.push({slug:u,img:g(e.img,{root:l}),name:s,chapters:(o=await this.getRawChapters(r,{root:l,titleSlug:u,titleName:s}))!=null?o:[]})})),n.length?{rawUpdates:n}:void 0}async getRawChapters(t,{root:e=document.documentElement,titleSlug:r="",titleName:n,lazy:l=!0}){var o;if(!t)return;const i=[],c=await C(t.sel,{root:e,all:!0,lazy:l});if(!(c!=null&&c.length))return i;const s=(c??[]).map(f=>({id:g(t.id,{root:f}),label:g(t.label,{root:f}),url:g(t.url,{root:f}),at:g(t.at,{root:f})})),u=s.map(({label:f})=>V(f,n)),p=(o=u[1])==null?void 0:o.chap;!u[0]&&(p===void 0||p<=1)&&(u[0]={label:s[0].label,chap:0});const{readerBase:d}=this.siteMeta,h=J(d,r),v=d.split("/").indexOf("{lang}"),w=v!==-1;return u.forEach((f,O)=>{var m;if(!f)return;const{id:b,url:R,at:$}=s[O],S=D(R);if(!S)return;const P=w?S?.substring(1).split("/")[v]:void 0,y=this.resolveReaderSlug(P?h.replace("{lang}",P):h,S);i.push(St(et({},f),{id:b,slug:y,lang:P,ts:F($)||((m=i[i.length+1])==null?void 0:m.ts)||Date.now()}))}),A(i)}resolveReaderSlug(t,e){return e.startsWith(t)?e.replace(t,""):e}resolveTitleSlug(t){var e;if(typeof t!="string")return;const r=(e=D(t))==null?void 0:e.split("/").filter(Boolean);return!r||!r.length?t:r[r.length-1]}finalizeRawUpdateData(t){var e,r;const n=(r=(e=this.spec.update)==null?void 0:e.title)!=null&&r.lang?this.siteMeta.defaultLang:void 0,l=yt(t.rawUpdates,n);if(l.length)return{rawUpdates:this.oldRawUpdates?ft(l,this.oldRawUpdates):l}}static async _isReaderPage(t){const{sel:e,img:r}=t;if(!e||!r||!await C(e,{lazy:!!t.lazy}))return!1;const n=X(r).map(l=>l.split("|")[0]).join(",");return!!await C(n,{lazy:!0})}_findNeighborSlug({sel:t,basePath:e}){const r=g(t);if(!r||r.startsWith("#")||r.startsWith("/#"))return;const n=D(r);return n?this.resolveReaderSlug(e,n):void 0}static _is404Page(t){return t[404]&&document.querySelector(t[404])?!0:document.title.toLowerCase().includes("not found")}};async function Le(a){let t=window;const e={__html__:document.documentElement};for(let r=0;r<a.length;r++){const{attr:n,args:l}=a[r];if(!(n in t))return;t=l?t[n](...l.map(o=>{var i;return(i=e[o])!=null?i:o})):t[n]}return t===window?void 0:t}var ze=Object.defineProperty,We=Object.defineProperties,qe=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,Pt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,jt=(a,t,e)=>t in a?ze(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,at=(a,t)=>{for(var e in t||(t={}))Pt.call(t,e)&&jt(a,e,t[e]);if(Z)for(var e of Z(t))Dt.call(t,e)&&jt(a,e,t[e]);return a},xt=(a,t)=>We(a,qe(t)),Tt=(a,t)=>{var e={};for(var r in a)Pt.call(a,r)&&t.indexOf(r)<0&&(e[r]=a[r]);if(a!=null&&Z)for(var r of Z(a))t.indexOf(r)<0&&Dt.call(a,r)&&(e[r]=a[r]);return e};class B{constructor(t){this.methodsMap={[j.title]:()=>this.getRawTitleData(),[j.reader]:()=>this.getRawReaderData(),[j.update]:()=>this.getRawUpdateData(),[j.search]:()=>this.getRawSearchData()};var e;this.spec=t.spec,this.siteMeta=t.siteMeta,this.tags=t.tags,this.oldRawUpdates=t.oldRawUpdates,this.getGlobalData=(e=t.getGlobalData)!=null?e:ke}async getRawPageByType(t){const e=await this.methodsMap[t](),r=location.origin+location.pathname;return{type:t,is404:B._is404Page(this.spec),specId:this.spec.id,siteName:g(this.spec.name),url:r,data:e}}async getRawUpdateData(){var t,e;if(!((e=(t=this.spec)==null?void 0:t.update)!=null&&e.title))return;const r=this.spec.update.title,{chapter:n}=r,l=Tt(r,["chapter"]);if(!l.sel||!l.name||!(n!=null&&n.sel)||!(n!=null&&n.label))return;const o=await C(l.sel,{lazy:!0,all:!0});if(!(o!=null&&o.length))return;const i=o.slice(0,100).map(s=>{const u=g(l.url,{root:s}),p=D(u),d=g(l.name,{root:s}),h=g(l.at,{root:s});if(!(!p||!d))return{titleEl:s,id:g(l.id,{root:s}),path:p,img:H(g(l.img,{root:s})),name:d,lang:g(l.lang,{root:s}),at:h?F(h):void 0}}).filter(Boolean);if(!i.length)return;const c=await Promise.all(i.map(async s=>{var u;const p=s,{path:d,titleEl:h,lang:v,at:w}=p,f=Tt(p,["path","titleEl","lang","at"]),O=this.resolveTitleSlug(d),m=(u=await this.getRawChapters(n,{root:h,titleSlug:O,titleName:f?.name}))!=null?u:[];return at({slug:O,chapters:v||w?m.map(b=>{var R,$;return xt(at({},b),{lang:(R=b.lang)!=null?R:v,ts:($=b.ts)!=null?$:w})}):m},f)}));return this.finalizeRawUpdateData({rawUpdates:c})}async getRawTitleData(){var t,e,r;if(!((t=this.spec)!=null&&t.title))return;const n=this.spec.title;if(!n.sel||!n.name||!await C(n.sel,{lazy:!!this.spec.title.lazy}))return;const l=g(n.name);if(!l)return;const o=this.resolveTitleSlug(location.pathname);if(!o)return;let i=(e=g(n.tags,{returnAll:!0}))!=null?e:[];i.length===1&&(i=i[0].split(",").map(u=>u.trim()).filter(Boolean));const c=g(n.type),s=g(n.langs,{returnAll:!0});return{id:g(n.id),url:location.origin+location.pathname,slug:o,name:l,langs:s!=null&&s.length?s:n.langs&&this.siteMeta.defaultLang?[this.siteMeta.defaultLang]:void 0,tags:G(this.tags,[...i??[],...c?[c]:[]]),img:H(g(n.img)),chapters:(r=await this.getRawChapters(n.chapter,{lazy:!0,titleSlug:o,titleName:l}))!=null?r:[]}}async getRawReaderData(){var t,e,r,n,l,o;const{spec:i,siteMeta:c}=this;if(!(i!=null&&i.reader)||!await B._isReaderPage(i.reader))return;const s=i.reader.title,u=document.querySelector(s.sel);if(!u)return;const p=g(s.name,{root:u}),d=g(s.url,{root:u}),h=this.resolveTitleSlug(d);if(!p||!d||!h)return;const v=(e=await this.getRawChapters((t=i.reader)==null?void 0:t.chapter,{titleSlug:h,titleName:p}))!=null?e:[],w=(r=g(i.reader.label))==null?void 0:r.toLowerCase().replace(p.toLowerCase(),"");if(!w)return;const{vol:f,chap:O=0}=V(w,p)||{};let m;const b=(n=g(i.reader.img,{returnAll:!0,preProcess(x){const T=x.map(M=>+(M.getAttribute("height")||0)/+(M.getAttribute("width")||1));T.some(M=>M>2.5)?m=!0:T.filter(Boolean).length>Math.max(1,T.length-2)&&(m=!1)}}))!=null?n:[];if(!b.length)return;const R=J(c.readerBase,h),$=c.readerBase.split("/").indexOf("{lang}"),S=$!==-1?location.pathname.substring(1).split("/")[$]:void 0,P=S?R.replace("{lang}",S):R,y=(l=S??g(i.reader.lang))!=null?l:i.reader.lang?this.siteMeta.defaultLang:void 0;return{isWebtoon:m,vol:f,inferVol:(o=v.find(x=>x.vol===f&&x.chap===O))==null?void 0:o.inferVol,chap:O,lang:y,slug:this.resolveReaderSlug(P,location.pathname),nextSlug:this._findNeighborSlug({sel:i.reader.next,basePath:P}),prevSlug:this._findNeighborSlug({sel:i.reader.prev,basePath:P}),basePath:P,imgs:b,imgsLocator:i.reader.img,title:{id:g(s.id),url:d,slug:h,name:p,langs:y?[y]:void 0,chapters:v}}}async getRawSearchData(){var t;const e=(t=this.spec.search)==null?void 0:t.title;if(!e)return;const{chapter:r}=e,n=[];return await Promise.all(Array.from(document.querySelectorAll(e.sel)).map(async l=>{var o;const i=g(e.url,{root:l}),c=D(i),s=g(e.name,{root:l}),u=this.resolveTitleSlug(c);!c||!s||!u||n.push({slug:u,img:g(e.img,{root:l}),name:s,chapters:(o=await this.getRawChapters(r,{root:l,titleSlug:u,titleName:s}))!=null?o:[]})})),n.length?{rawUpdates:n}:void 0}async getRawChapters(t,{root:e=document.documentElement,titleSlug:r="",titleName:n,lazy:l=!0}){var o;if(!t)return;const i=[],c=await C(t.sel,{root:e,all:!0,lazy:l});if(!(c!=null&&c.length))return i;const s=(c??[]).map(f=>({id:g(t.id,{root:f}),label:g(t.label,{root:f}),url:g(t.url,{root:f}),at:g(t.at,{root:f})})),u=s.map(({label:f})=>V(f,n)),p=(o=u[1])==null?void 0:o.chap;!u[0]&&(p===void 0||p<=1)&&(u[0]={label:s[0].label,chap:0});const{readerBase:d}=this.siteMeta,h=J(d,r),v=d.split("/").indexOf("{lang}"),w=v!==-1;return u.forEach((f,O)=>{var m;if(!f)return;const{id:b,url:R,at:$}=s[O],S=D(R);if(!S)return;const P=w?S?.substring(1).split("/")[v]:void 0,y=this.resolveReaderSlug(P?h.replace("{lang}",P):h,S);i.push(xt(at({},f),{id:b,slug:y,lang:P,ts:F($)||((m=i[i.length+1])==null?void 0:m.ts)||Date.now()}))}),A(i)}resolveReaderSlug(t,e){return e.startsWith(t)?e.replace(t,""):e}resolveTitleSlug(t){var e;if(typeof t!="string")return;const r=(e=D(t))==null?void 0:e.split("/").filter(Boolean);return!r||!r.length?t:r[r.length-1]}finalizeRawUpdateData(t){var e,r;const n=(r=(e=this.spec.update)==null?void 0:e.title)!=null&&r.lang?this.siteMeta.defaultLang:void 0,l=yt(t.rawUpdates,n);if(l.length)return{rawUpdates:this.oldRawUpdates?ft(l,this.oldRawUpdates):l}}static async _isReaderPage(t){const{sel:e,img:r}=t;if(!e||!r||!await C(e,{lazy:!!t.lazy}))return!1;const n=X(r).map(l=>l.split("|")[0]).join(",");return!!await C(n,{lazy:!0})}_findNeighborSlug({sel:t,basePath:e}){const r=g(t);if(!r||r.startsWith("#")||r.startsWith("/#"))return;const n=D(r);return n?this.resolveReaderSlug(e,n):void 0}static _is404Page(t){return t[404]&&document.querySelector(t[404])?!0:document.title.toLowerCase().includes("not found")}}async function ke(a){let t=window;const e={__html__:document.documentElement};for(let r=0;r<a.length;r++){const{attr:n,args:l}=a[r];if(!(n in t))return;t=l?t[n](...l.map(o=>{var i;return(i=e[o])!=null?i:o})):t[n]}return t===window?void 0:t}class Ct extends B{resolveTitleSlug(t){var e;return(e=D(t))==null?void 0:e.split("/").filter(Boolean)[1]}}Ct.specId="bato";function Ve(){return Math.random().toString(16).slice(2)}async function Ge({addListener:a,removeListener:t,transform:e,filter:r,handler:n,onTimeout:l,timeout:o,once:i}){return new Promise(c=>{a(p);const s=()=>i===!0&&t(p),u=o?setTimeout(()=>{s(),c(void 0),l?.()},o):void 0;async function p(d,...h){d=e?e(d):d,d!==void 0&&(!r||r(d,...h))&&(s(),c(d),n?.(d,...h),u&&clearTimeout(u))}})}var Fe=Object.defineProperty,Nt=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Mt=(a,t,e)=>t in a?Fe(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Ye=(a,t)=>{for(var e in t||(t={}))He.call(t,e)&&Mt(a,e,t[e]);if(Nt)for(var e of Nt(t))Je.call(t,e)&&Mt(a,e,t[e]);return a};async function Ze(a){const t=await Ge(Ye({addListener:e=>window.addEventListener("message",e),removeListener:e=>window.removeEventListener("message",e)},a));return t?.data}async function Ke(a){var t;const{receiverWindow:e,timeout:r,targetOrigin:n,event:l,args:o}=a,i={reqId:Ve(),event:l,args:o};(t=e||window)==null||t.postMessage(i,n??"*");const c=await Ze({filter:s=>{var u;return((u=s?.data)==null?void 0:u.resId)===i.reqId},timeout:r??3e4,once:!0});return c?.result}const _={isAny:!0};function N(a,...t){return Ke({event:"tk:fetchResult",args:{baseUrl:a,segments:t}})}function Qe(a){if(a)try{return JSON.parse(a)}catch{return}}var Xe=Object.defineProperty,ta=Object.defineProperties,ea=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertySymbols,aa=Object.prototype.hasOwnProperty,ra=Object.prototype.propertyIsEnumerable,Bt=(a,t,e)=>t in a?Xe(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,rt=(a,t)=>{for(var e in t||(t={}))aa.call(t,e)&&Bt(a,e,t[e]);if(Ut)for(var e of Ut(t))ra.call(t,e)&&Bt(a,e,t[e]);return a},nt=(a,t)=>ta(a,ea(t));class _t extends B{async getRawUpdateData(){const t="https://api.comick.app/",[e]=await Promise.all([N(t,"chapter")]);if(!e)return;const r=e.map(n=>{var l,o;const{vol:i,chap:c,hid:s,lang:u,updated_at:p,md_comics:d}=n,h=typeof c=="string"&&!isNaN(+c)?+c:void 0;if(typeof h!="number")return;const v=(o=(l=d.md_covers)==null?void 0:l[0])==null?void 0:o.b2key;return{id:d.id+"",slug:d.slug,name:d.title,img:typeof v=="string"?`https://meo.comick.pictures/${v}`:void 0,chapters:[{slug:s,vol:typeof i=="string"&&!isNaN(+i)?+i:void 0,chap:h,lang:u,ts:new Date(p).valueOf()}]}}).filter(Boolean);return super.finalizeRawUpdateData({rawUpdates:r})}async getRawTitleData(){var t,e,r,n;const l=await super.getRawTitleData();if(!l)return l;const o="https://api.comick.app/",[i]=await Promise.all([N(o,"comic",_,"chapters")]);if(!i)return l;const c=await na(l.slug),s=[];i.chapters.forEach(d=>{const{vol:h,chap:v,hid:w,lang:f,updated_at:O}=d,m=typeof v=="string"&&!isNaN(+v)?+v:void 0;typeof m!="number"||s.some(b=>b.vol==h&&b.chap===m&&b.lang===f)||s.push({slug:w,vol:typeof h=="string"&&!isNaN(+h)?+h:void 0,chap:m,lang:f,ts:new Date(O).valueOf()})});const u=g("h1 ~ div.text-sm span:first-child|row:demographic"),p=u?(t=G(this.tags,[u]))==null?void 0:t[0]:void 0;return p&&!((e=l.tags)!=null&&e.includes(p))&&((r=l.tags)==null||r.push(p),(n=l.tags)==null||n.sort((d,h)=>d-h)),nt(rt({},l),{id:c,hasMoreChapters:i.chapters.length<i.total,chapters:A(s)})}async getRawReaderData(){var t;const e=await super.getRawReaderData();if(!e)return e;const r=await N("/_next/data/",_,"comic",_),n=(t=r?.comic)==null?void 0:t.id;return nt(rt({},e),{title:nt(rt({},e.title),{id:n?n+"":void 0})})}}_t.specId="comick";async function na(a){var t,e,r,n,l,o,i;const c=(t=document.querySelector("script#__NEXT_DATA__"))==null?void 0:t.textContent,s=c?Qe(c):void 0;if(((e=s?.query)==null?void 0:e.slug)===a){const d=(l=(n=(r=s?.props)==null?void 0:r.pageProps)==null?void 0:n.comic)==null?void 0:l.id;return d?d+"":void 0}const u=await N("/_next/data/",_,"comic",a,"covers.json"),p=(i=(o=u?.pageProps)==null?void 0:o.comic)==null?void 0:i.id;return p?p+"":void 0}var la=Object.defineProperty,ia=Object.defineProperties,oa=Object.getOwnPropertyDescriptors,It=Object.getOwnPropertySymbols,sa=Object.prototype.hasOwnProperty,ua=Object.prototype.propertyIsEnumerable,At=(a,t,e)=>t in a?la(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,lt=(a,t)=>{for(var e in t||(t={}))sa.call(t,e)&&At(a,e,t[e]);if(It)for(var e of It(t))ua.call(t,e)&&At(a,e,t[e]);return a},it=(a,t)=>ia(a,oa(t));class Et extends B{resolveReaderSlug(t,e){return super.resolveReaderSlug(t,e).replace(/-page-\d{1,3}\.html$/,".html")}async getRawTitleData(){const t=await super.getRawTitleData();return t&&it(lt({},t),{chapters:Lt(await this.getVM(),t.slug)})}async getRawReaderData(){const t=await super.getRawReaderData();if(!t)return t;const e=await this.getVM();return it(lt({},t),{imgs:ca(e,t.imgs[0]),title:it(lt({},t.title),{chapters:Lt(e,t.title.slug)})})}getVM(){return this.getGlobalData([{attr:"angular"},{attr:"element",args:["__html__"]},{attr:"scope",args:[]},{attr:"vm"}])}}Et.specId="manga4life";function Lt(a,t){var e,r;return((r=(e=a?.Chapters)!=null?e:a?.CHAPTERS)!=null?r:[]).map(n=>{const l=+n.Chapter.substring(1)/10;return{slug:`${t}-chapter-${l}.html`,chap:l,ts:new Date(n.Date).valueOf()}})}function ca(a,t){let e=t.split(".").slice(-1)[0];e=e.length>=3&&e.length<=4?e:"png";try{const r=a.CurChapter.Chapter.slice(1,-1),n=a.CurChapter.Chapter[a.CurChapter.Chapter.length-1],l=n!=="0"?`${r}.${n}`:r,o=`https://${a.CurPathName}/manga/${a.IndexName}/${l}-`;return a.Pages.map(i=>{const c=(i+"").padStart(3,"0");return`${o}${c}.${e}`})}catch{return[]}}var pa=Object.defineProperty,da=Object.defineProperties,ga=Object.getOwnPropertyDescriptors,zt=Object.getOwnPropertySymbols,ha=Object.prototype.hasOwnProperty,fa=Object.prototype.propertyIsEnumerable,Wt=(a,t,e)=>t in a?pa(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,qt=(a,t)=>{for(var e in t||(t={}))ha.call(t,e)&&Wt(a,e,t[e]);if(zt)for(var e of zt(t))fa.call(t,e)&&Wt(a,e,t[e]);return a},kt=(a,t)=>da(a,ga(t));class Vt extends B{async getRawUpdateData(){const t="https://api.mangadex.org/",[e,r]=await Promise.all([N(t,"chapter"),N(t,"manga")]);if(!r||!e)return;const n={};r.data.forEach(({id:o,relationships:i})=>{var c;const s=i.find(({type:p})=>p==="cover_art"),u=(c=s?.attributes)==null?void 0:c.fileName;u&&(n[o]=`https://mangadex.org/covers/${o}/${u}`)});const l=e.data.map(({relationships:o,attributes:i,id:c})=>{const s=o.find(({type:d})=>d==="manga"),u=typeof i.volume=="string"?+i.volume:void 0,p=typeof i.chapter=="string"?+i.chapter:void 0;if(p)return{slug:s.id,name:Object.values(s.attributes.title)[0],img:n[s.id],chapters:[{slug:i.externalUrl||c,label:i.title||void 0,vol:u,chap:p,lang:i.translatedLanguage,ts:new Date(i.readableAt).valueOf()}]}}).filter(Boolean);return super.finalizeRawUpdateData({rawUpdates:l})}async getRawTitleData(){var t,e,r;const n="https://api.mangadex.org/manga/",[l,o]=await Promise.all([N(n,_),N(n,_,"feed")]);if(!l||!o)return;const i=(r=(e=(t=o.data)==null?void 0:t.map)==null?void 0:e.call(t,u=>{const{attributes:p,id:d}=u;if(typeof p!="object"||typeof d!="string"||!d)return;const{externalUrl:h,title:v,volume:w,chapter:f,translatedLanguage:O}=p;return{slug:h||d,label:v||void 0,vol:typeof w=="string"?+w:void 0,chap:typeof f=="string"?+f:void 0,lang:O||"en",ts:new Date(p.readableAt).valueOf()}}).filter(u=>u?.chap!=null))!=null?r:[],{data:c}=l;if(!c)return;const s=Gt({data:c,entryTags:this.tags});if(s)return kt(qt({},s),{chapters:A(i),hasMoreChapters:(o.total||0)>(o.limit||0)})}async getRawReaderData(){var t,e,r,n,l,o,i,c,s,u,p,d,h,v,w;const f="https://api.mangadex.org/",[O,m,b]=await Promise.all([N(f,"chapter",_),N(f,"at-home","server",_),N(f,"manga",_,"aggregate")]);if(!O||!m||!b)return;const R=O.data,{volume:$,chapter:S,externalUrl:P,translatedLanguage:y}=R.attributes||{},{baseUrl:x,chapter:{data:T,dataSaver:M,hash:za}}=m,se=(e=(t=R.relationships)==null?void 0:t.find)==null?void 0:e.call(t,U=>U.type==="manga");if(!se)return;const ue=Gt({data:se,entryTags:this.tags});if(!ue||typeof b.volumes!="object")return;const I=Object.values(b.volumes).map(({volume:U,chapters:Va})=>{const Ga=U==="none"||typeof U!="string"?void 0:+U;return Object.values(Va).map(({id:Fa,chapter:ct})=>typeof ct!="string"||ct==="none"?void 0:{vol:Ga,chap:+ct,slug:Fa})}).flat().filter(Boolean).reverse();if(typeof S!="string"||S==="none"){if(I.length)return;I.push({chap:0,slug:R.id})}A(I);const ut=I.findIndex(U=>U.slug===R.id),Q=(n=(r=R.relationships)==null?void 0:r.find)==null?void 0:n.call(r,U=>U.type==="scanlation_group"),Wa=x.endsWith("/")?x:x+"/",ce=!!((o=(l=localStorage.getItem("md"))==null?void 0:l.includes)!=null&&o.call(l,'"dataSaver":true')),qa=`${Wa}${ce?"data-saver":"data"}/`,ka=(u=(s=(c=(i=ce?M:T)!=null?i:[]).map)==null?void 0:s.call(c,U=>`${qa}${za}/${U}`))!=null?u:[];return{externalUrl:P,vol:typeof $=="string"?+$:void 0,inferVol:(p=I[ut])==null?void 0:p.inferVol,chap:+S||0,imgs:ka,lang:y,slug:R.id,prevSlug:(d=I[ut+1])==null?void 0:d.slug,nextSlug:(h=I[ut-1])==null?void 0:h.slug,basePath:"/chapter/",groupName:(v=Q?.attributes)==null?void 0:v.name,groupUrl:(w=Q?.attributes)==null?void 0:w.website,title:kt(qt({},ue),{chapters:I})}}resolveTitleSlug(t){var e;return(e=D(t))==null?void 0:e.split("/").filter(Boolean)[1]}}Vt.specId="mangadex";function Gt({data:a,entryTags:t}){var e,r,n,l,o;const{id:i,attributes:c,relationships:s}=a;if(!i||typeof i!="string"||typeof c!="object")return;const{title:u,availableTranslatedLanguages:p,altTitles:d,tags:h,contentRating:v}=c;if(typeof u!="object"||!Array.isArray(p))return;const w=Object.values(u)[0];if(!w||typeof w!="string")return;const f=va(),O=(r=(e=p?.map)==null?void 0:e.call(p,y=>typeof y=="string"?y:void 0).filter(Boolean))!=null?r:[],m=O.filter(y=>y&&(!f||f.includes(y))),b=(n=d?.map)==null?void 0:n.call(d,y=>{const[[x,T]=[]]=Object.entries(y);return{lang:x,name:T}}),R=(l=s?.find)==null?void 0:l.call(s,y=>y.type==="cover_art"),$=(o=R?.attributes)==null?void 0:o.fileName,S=$?`https://mangadex.org/covers/${i}/${$}`:void 0,P=(h||[]).map(y=>{var x,T;return(T=(x=y?.attributes)==null?void 0:x.name)==null?void 0:T.en}).concat(v).filter(Boolean);return{url:`${location.origin}/title/${i}`,slug:i,name:w,altNames:b,langs:m.length>0?m:O,img:S,tags:G(t,P),isWebtoon:h?.some(y=>y.attributes.name.en==="Long Strip")}}function va(){var a;const t=localStorage.getItem("md");if(t)try{const e=JSON.parse(t),r=(a=e?.userPreferences)==null?void 0:a.filteredLanguages;return r!=null&&r.length?r:void 0}catch{return}}var ma=(a=>(a[a.reading=1]="reading",a[a.paused=2]="paused",a[a.plan=3]="plan",a[a.completed=4]="completed",a[a.dropped=5]="dropped",a[a.deleted=6]="deleted",a))(ma||{}),ot=(a=>(a.id="id",a.name="name",a.slug="slug",a))(ot||{}),ya=(a=>(a[a.string=1]="string",a[a.number=2]="number",a[a.bool=3]="bool",a[a.selection=4]="selection",a))(ya||{}),wa=(a=>(a[a.pending=0]="pending",a[a.completed=1]="completed",a[a.offline=2]="offline",a[a.incompat=3]="incompat",a))(wa||{}),ba=(a=>(a[a.releases=1]="releases",a[a.img=2]="img",a))(ba||{});function Ft(a,t){const e=a[0]===t?a.substring(1):a;return e[e.length-1]===t?e.substring(0,e.length-1):e}var Oa=Object.defineProperty,Ra=Object.defineProperties,Sa=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertySymbols,$a=Object.prototype.hasOwnProperty,Pa=Object.prototype.propertyIsEnumerable,Jt=(a,t,e)=>t in a?Oa(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,E=(a,t)=>{for(var e in t||(t={}))$a.call(t,e)&&Jt(a,e,t[e]);if(Ht)for(var e of Ht(t))Pa.call(t,e)&&Jt(a,e,t[e]);return a},k=(a,t)=>Ra(a,Sa(t));class Yt extends B{async getRawUpdateData(){const t=await super.getRawUpdateData();if(t)return k(E({},t),{siteMeta:Da(this.spec.update,this.siteMeta)})}async getRawTitleData(){var t;const e=await super.getRawTitleData();if(!e)return;const r=L(location.pathname);let n;if((t=e.chapters)!=null&&t.length){const l=this.spec.title.chapter,o=document.querySelector(l.sel),i=D(g(l.url,{root:o}));i&&(n=L(i))}return k(E({},e),{siteMeta:K(this.siteMeta,{titleBase:r,readerBase:n})})}async getRawReaderData(){const t=await super.getRawReaderData();if(t)return k(E({},t),{siteMeta:K(this.siteMeta,{titleBase:L(D(t.title.url)),readerBase:L(location.pathname),idBase:Zt()}),title:k(E({},t.title),{id:await this.getReaderTitleId()})})}async getRawSearchData(){const t=await super.getRawSearchData();if(!t)return;const e=this.spec.search.title,r=document.querySelector(e.sel),n=g(e.url,{root:r});return k(E({},t),{siteMeta:K(this.siteMeta,{titleBase:L(D(n)),idBase:Zt()})})}async getReaderTitleId(){const t=await this.getGlobalData([{attr:"HISTORY"},{attr:"getStored",args:[]}]);if(!t||typeof t!="object")return;const e=Object.values(t).filter(Boolean);if(e.length)return e.sort((r,n)=>n.time-r.time),e[0].manga_ID}}Yt.specId="mangastream";function Da(a,t){var e,r;if(!a)return;const n=k(E({},t),{updatePath:Ft(location.pathname,"/")}),l=a.title,o=(e=document.querySelector(l.sel))!=null?e:void 0;if(!o)return;const i=D(g(l.url,{root:o}));if(i===void 0)return;const c=(r=o.querySelector(l.chapter.sel))!=null?r:void 0;if(!c)return;const s=D(g(l.chapter.url,{root:c}));if(s!==void 0)return n.titleBase=L(i),n.readerBase=L(s),t.titleIdType===ot.id&&(g(l.id,{root:o})||(t.titleIdType=ot.name)),K(t,n)}function Zt(){return document.querySelector('link[rel="shortlink"][href*="/?p="]')?"?p=":void 0}function K(a,t){const e=Object.keys(t),r=E({},a);let n=!1;return e.forEach(l=>{const o=t[l];o!==a[l]&&(r[l]=o,n=!0)}),n?r:void 0}function L(a){return Ft(a,"/").split("/").slice(0,-1).join("/")}var ja=Object.defineProperty,xa=Object.defineProperties,Ta=Object.getOwnPropertyDescriptors,Kt=Object.getOwnPropertySymbols,Ca=Object.prototype.hasOwnProperty,Na=Object.prototype.propertyIsEnumerable,Qt=(a,t,e)=>t in a?ja(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,st=(a,t)=>{for(var e in t||(t={}))Ca.call(t,e)&&Qt(a,e,t[e]);if(Kt)for(var e of Kt(t))Na.call(t,e)&&Qt(a,e,t[e]);return a},Xt=(a,t)=>xa(a,Ta(t));class te extends B{async getRawReaderData(){const t=await super.getRawReaderData();if(!t)return t;let e=t.title.id;if(!e){const r=this.spec.reader.title;r.id&&await C(r.id.split("|")[0],{lazy:!0}),e=g(r.id)}return Xt(st({},t),{title:Xt(st({},t.title),{id:e,chapters:await Ma(e)})})}resolveTitleSlug(t){const e=super.resolveTitleSlug(t);if(!e)return;const r=e.lastIndexOf("-"),n=+e.substring(r+1);return r===-1||isNaN(n)||n<1e3?e:e.substring(0,r)}}te.specId="nettruyen";async function Ma(a){var t;if(!a)return[];const e=await fetch(`/Comic/Services/ComicService.asmx/ProcessChapterList?comicId=${a}`).then(r=>r.status===200?r.json():void 0).catch(()=>[]);return(t=e?.chapters)!=null&&t.length?A(e.chapters.map(r=>{const{name:n,url:l}=r,o=V(n);if(!(!o||!l))return st({slug:D(l).split("/").filter(Boolean).slice(2).join("/")},o)})):[]}const Ua=[Ct,_t,Et,Vt,Yt,te];function ee(a){var t;const e=(t=Ua.find(r=>r.specId===a.spec.id))!=null?t:Ee;return new e(a)}var Ba=Object.defineProperty,_a=Object.defineProperties,Ia=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,Aa=Object.prototype.hasOwnProperty,Ea=Object.prototype.propertyIsEnumerable,re=(a,t,e)=>t in a?Ba(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,ne=(a,t)=>{for(var e in t||(t={}))Aa.call(t,e)&&re(a,e,t[e]);if(ae)for(var e of ae(t))Ea.call(t,e)&&re(a,e,t[e]);return a},le=(a,t)=>_a(a,Ia(t));async function La(a){var t,e;const{spec:r}=a;if(r){const n=(t=a.siteMeta)!=null?t:r.meta,l=a.type?[a.type]:ie(n,r.generic);if(!l.length)return;const o=ee(le(ne({},a),{spec:r,siteMeta:n}));return await W(l.map(i=>o.getRawPageByType(i)))}return await W(((e=a.genericSpecs)!=null?e:[]).map(n=>{const l=ie(n.meta,n.generic);if(!l.length)return[];const o=ee(le(ne({},a),{spec:n,siteMeta:n.meta}));return l.map(i=>o.getRawPageByType(i))}).flat())}function ie(a,t){if(location.pathname==="/")return[];const{titleBase:e,readerBase:r}=a,n=location.pathname.split("/").filter(Boolean),l=oe(n,r),o=oe(n,e);if(l!==o)return l>o?[j.reader]:[j.title];if(l>0)return[j.reader,j.title];if(n.length===1){const i=[!r&&j.reader,!e&&j.title].filter(Boolean);if(i.length)return i}return t?[j.reader,j.title]:[]}function oe(a,t){if(!t)return 0;const e=t.split("/").filter(Boolean);return a.length<=e.length?0:e.filter((r,n)=>a[n]===r||r==="{titleSlug}"||r==="{lang}").length}z.PageType=j,z.scrape=La});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trackkun-dom",
3
3
  "author": "endyquang",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Trkun DOM parser",
7
7
  "main": "index.js",