openfreebooks-bookgenerator/themes/openfreebooks/static/js/bundle.js

1 line
14 KiB
JavaScript

const we=(e,t)=>e===t,ve=Symbol("solid-track"),j={equals:we};let re=ce;const T=1,P=2,oe={owned:null,cleanups:null,context:null,owner:null};var g=null;let K=null,ye=null,h=null,p=null,C=null,H=0;function D(e,t){const n=h,s=g,l=e.length===0,r=t===void 0?s:t,o=l?oe:{owned:null,cleanups:null,context:r?r.context:null,owner:r},i=l?e:()=>e(()=>N(()=>B(o)));g=o,h=null;try{return q(i,!0)}finally{h=n,g=s}}function F(e,t){t=t?Object.assign({},j,t):j;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},s=l=>(typeof l=="function"&&(l=l(n.value)),ue(n,l));return[ae.bind(n),s]}function _(e,t,n){const s=X(e,t,!1,T);M(s)}function Se(e,t,n){re=$e;const s=X(e,t,!1,T);s.user=!0,C?C.push(s):M(s)}function R(e,t,n){n=n?Object.assign({},j,n):j;const s=X(e,t,!0,0);return s.observers=null,s.observerSlots=null,s.comparator=n.equals||void 0,M(s),ae.bind(s)}function N(e){if(h===null)return e();const t=h;h=null;try{return e()}finally{h=t}}function J(e){Se(()=>N(e))}function Q(e){return g===null||(g.cleanups===null?g.cleanups=[e]:g.cleanups.push(e)),e}function ae(){if(this.sources&&this.state)if(this.state===T)M(this);else{const e=p;p=null,q(()=>G(this),!1),p=e}if(h){const e=this.observers;if(!e||e[e.length-1]!==h){const t=e?e.length:0;h.sources?(h.sources.push(this),h.sourceSlots.push(t)):(h.sources=[this],h.sourceSlots=[t]),e?(e.push(h),this.observerSlots.push(h.sources.length-1)):(this.observers=[h],this.observerSlots=[h.sources.length-1])}}return this.value}function ue(e,t,n){let s=e.value;return(!e.comparator||!e.comparator(s,t))&&(e.value=t,e.observers&&e.observers.length&&q(()=>{for(let l=0;l<e.observers.length;l+=1){const r=e.observers[l],o=K&&K.running;o&&K.disposed.has(r),(o?!r.tState:!r.state)&&(r.pure?p.push(r):C.push(r),r.observers&&fe(r)),o||(r.state=T)}if(p.length>1e6)throw p=[],new Error},!1)),t}function M(e){if(!e.fn)return;B(e);const t=H;Ee(e,e.value,t)}function Ee(e,t,n){let s;const l=g,r=h;h=g=e;try{s=e.fn(t)}catch(o){return e.pure&&(e.state=T,e.owned&&e.owned.forEach(B),e.owned=null),e.updatedAt=n+1,de(o)}finally{h=r,g=l}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?ue(e,s):e.value=s,e.updatedAt=n)}function X(e,t,n,s=T,l){const r={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:g,context:g?g.context:null,pure:n};return g===null||g!==oe&&(g.owned?g.owned.push(r):g.owned=[r]),r}function V(e){if(e.state===0)return;if(e.state===P)return G(e);if(e.suspense&&N(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<H);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===T)M(e);else if(e.state===P){const s=p;p=null,q(()=>G(e,t[0]),!1),p=s}}function q(e,t){if(p)return e();let n=!1;t||(p=[]),C?n=!0:C=[],H++;try{const s=e();return Ae(n),s}catch(s){n||(C=null),p=null,de(s)}}function Ae(e){if(p&&(ce(p),p=null),e)return;const t=C;C=null,t.length&&q(()=>re(t),!1)}function ce(e){for(let t=0;t<e.length;t++)V(e[t])}function $e(e){let t,n=0;for(t=0;t<e.length;t++){const s=e[t];s.user?e[n++]=s:V(s)}for(t=0;t<n;t++)V(e[t])}function G(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const s=e.sources[n];if(s.sources){const l=s.state;l===T?s!==t&&(!s.updatedAt||s.updatedAt<H)&&V(s):l===P&&G(s,t)}}}function fe(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=P,n.pure?p.push(n):C.push(n),n.observers&&fe(n))}}function B(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),s=e.sourceSlots.pop(),l=n.observers;if(l&&l.length){const r=l.pop(),o=n.observerSlots.pop();s<l.length&&(r.sourceSlots[o]=s,l[s]=r,n.observerSlots[s]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)B(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)B(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function ke(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function de(e,t=g){throw ke(e)}const Ce=Symbol("fallback");function z(e){for(let t=0;t<e.length;t++)e[t]()}function xe(e,t,n={}){let s=[],l=[],r=[],o=0,i=t.length>1?[]:null;return Q(()=>z(r)),()=>{let u=e()||[],c=u.length,f,a;return u[ve],N(()=>{let m,S,$,d,b,w,v,y,k;if(c===0)o!==0&&(z(r),r=[],s=[],l=[],o=0,i&&(i=[])),n.fallback&&(s=[Ce],l[0]=D(me=>(r[0]=me,n.fallback())),o=1);else if(o===0){for(l=new Array(c),a=0;a<c;a++)s[a]=u[a],l[a]=D(A);o=c}else{for($=new Array(c),d=new Array(c),i&&(b=new Array(c)),w=0,v=Math.min(o,c);w<v&&s[w]===u[w];w++);for(v=o-1,y=c-1;v>=w&&y>=w&&s[v]===u[y];v--,y--)$[y]=l[v],d[y]=r[v],i&&(b[y]=i[v]);for(m=new Map,S=new Array(y+1),a=y;a>=w;a--)k=u[a],f=m.get(k),S[a]=f===void 0?-1:f,m.set(k,a);for(f=w;f<=v;f++)k=s[f],a=m.get(k),a!==void 0&&a!==-1?($[a]=l[f],d[a]=r[f],i&&(b[a]=i[f]),a=S[a],m.set(k,a)):r[f]();for(a=w;a<c;a++)a in $?(l[a]=$[a],r[a]=d[a],i&&(i[a]=b[a],i[a](a))):l[a]=D(A);l=l.slice(0,o=c),s=u.slice(0)}return l});function A(m){if(r[a]=m,i){const[S,$]=F(a);return i[a]=$,t(u[a],S)}return t(u[a])}}}function L(e,t){return N(()=>e(t||{}))}const Te=e=>`Stale read from <${e}>.`;function ee(e){const t="fallback"in e&&{fallback:()=>e.fallback};return R(xe(()=>e.each,e.children,t||void 0))}function _e(e){const t=e.keyed,n=R(()=>e.when,void 0,void 0),s=t?n:R(n,void 0,{equals:(l,r)=>!l==!r});return R(()=>{const l=s();if(l){const r=e.children;return typeof r=="function"&&r.length>0?N(()=>r(t?l:()=>{if(!N(s))throw Te("Show");return n()})):r}return e.fallback},void 0,void 0)}function Le(e,t,n){let s=n.length,l=t.length,r=s,o=0,i=0,u=t[l-1].nextSibling,c=null;for(;o<l||i<r;){if(t[o]===n[i]){o++,i++;continue}for(;t[l-1]===n[r-1];)l--,r--;if(l===o){const f=r<s?i?n[i-1].nextSibling:n[r-i]:u;for(;i<r;)e.insertBefore(n[i++],f)}else if(r===i)for(;o<l;)(!c||!c.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[r-1]&&n[i]===t[l-1]){const f=t[--l].nextSibling;e.insertBefore(n[i++],t[o++].nextSibling),e.insertBefore(n[--r],f),t[l]=n[r]}else{if(!c){c=new Map;let a=i;for(;a<r;)c.set(n[a],a++)}const f=c.get(t[o]);if(f!=null)if(i<f&&f<r){let a=o,A=1,m;for(;++a<l&&a<r&&!((m=c.get(t[a]))==null||m!==f+A);)A++;if(A>f-i){const S=t[o];for(;i<f;)e.insertBefore(n[i++],S)}else e.replaceChild(n[i++],t[o++])}else o++;else t[o++].remove()}}}const te="_$DX_DELEGATE";function Z(e,t,n,s={}){let l;return D(r=>{l=r,t===document?e():E(t,e(),t.firstChild?null:void 0,n)},s.owner),()=>{l(),t.textContent=""}}function O(e,t,n,s){let l;const r=()=>{const i=document.createElement("template");return i.innerHTML=e,i.content.firstChild},o=()=>(l||(l=r())).cloneNode(!0);return o.cloneNode=o,o}function he(e,t=window.document){const n=t[te]||(t[te]=new Set);for(let s=0,l=e.length;s<l;s++){const r=e[s];n.has(r)||(n.add(r),t.addEventListener(r,Oe))}}function x(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Ne(e,t){t==null?e.removeAttribute("class"):e.className=t}function E(e,t,n,s){if(n!==void 0&&!s&&(s=[]),typeof t!="function")return Y(e,t,s,n);_(l=>Y(e,t(),l,n),s)}function Oe(e){let t=e.target;const n=`$$${e.type}`,s=e.target,l=e.currentTarget,r=u=>Object.defineProperty(e,"target",{configurable:!0,value:u}),o=()=>{const u=t[n];if(u&&!t.disabled){const c=t[`${n}Data`];if(c!==void 0?u.call(t,c,e):u.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&r(t.host),!0},i=()=>{for(;o()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),e.composedPath){const u=e.composedPath();r(u[0]);for(let c=0;c<u.length-2&&(t=u[c],!!o());c++){if(t._$host){t=t._$host,i();break}if(t.parentNode===l)break}}else i();r(s)}function Y(e,t,n,s,l){for(;typeof n=="function";)n=n();if(t===n)return n;const r=typeof t,o=s!==void 0;if(e=o&&n[0]&&n[0].parentNode||e,r==="string"||r==="number"){if(r==="number"&&(t=t.toString(),t===n))return n;if(o){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=U(e,n,s,i)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||r==="boolean")n=U(e,n,s);else{if(r==="function")return _(()=>{let i=t();for(;typeof i=="function";)i=i();n=Y(e,i,n,s)}),()=>n;if(Array.isArray(t)){const i=[],u=n&&Array.isArray(n);if(W(i,t,n,l))return _(()=>n=Y(e,i,n,s,!0)),()=>n;if(i.length===0){if(n=U(e,n,s),o)return n}else u?n.length===0?ne(e,i,s):Le(e,n,i):(n&&U(e),ne(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(o)return n=U(e,n,s,t);U(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function W(e,t,n,s){let l=!1;for(let r=0,o=t.length;r<o;r++){let i=t[r],u=n&&n[e.length],c;if(!(i==null||i===!0||i===!1))if((c=typeof i)=="object"&&i.nodeType)e.push(i);else if(Array.isArray(i))l=W(e,i,u)||l;else if(c==="function")if(s){for(;typeof i=="function";)i=i();l=W(e,Array.isArray(i)?i:[i],Array.isArray(u)?u:[u])||l}else e.push(i),l=!0;else{const f=String(i);u&&u.nodeType===3&&u.data===f?e.push(u):e.push(document.createTextNode(f))}}return l}function ne(e,t,n=null){for(let s=0,l=t.length;s<l;s++)e.insertBefore(t[s],n)}function U(e,t,n,s){if(n===void 0)return e.textContent="";const l=s||document.createTextNode("");if(t.length){let r=!1;for(let o=t.length-1;o>=0;o--){const i=t[o];if(l!==i){const u=i.parentNode===e;!r&&!o?u?e.replaceChild(l,i):e.insertBefore(l,n):u&&i.remove()}else r=!0}}else e.insertBefore(l,n);return[l]}const ge="openfreebooks-theme";function Ue(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Ie(){const e=localStorage.getItem(ge);return e==="light"||e==="dark"?e:null}function be(){return Ie()??Ue()}function pe(e){document.documentElement.setAttribute("data-theme",e)}function Be(e){localStorage.setItem(ge,e),pe(e)}function Me(){pe(be())}var qe=O("<span aria-hidden=true>☀"),De=O("<button type=button class=theme-toggle>"),Re=O("<span aria-hidden=true>☾");function je(){const[e,t]=F("light");J(()=>{t(be())});const n=()=>{const s=e()==="dark"?"light":"dark";Be(s),t(s)};return(()=>{var s=De();return s.$$click=n,E(s,L(_e,{get when(){return e()==="dark"},get fallback(){return Re()},get children(){return qe()}})),_(l=>{var r=e()==="dark"?"Switch to light theme":"Switch to dark theme",o=e()==="dark"?"Light mode":"Dark mode";return r!==l.e&&x(s,"aria-label",l.e=r),o!==l.t&&x(s,"title",l.t=o),l},{e:void 0,t:void 0}),s})()}he(["click"]);var Pe=O('<header><div class="container header-row"><div class=brand><a class=brand-name></a></div><div class=header-actions><nav class=main-nav aria-label="Primary navigation"></nav><button type=button class=nav-burger aria-controls=mobile-nav><span class=nav-burger-line></span><span class=nav-burger-line></span><span class=nav-burger-line></span></button></div></div><div class=nav-backdrop></div><nav id=mobile-nav class=mobile-nav-panel aria-label="Mobile navigation">'),se=O("<a>");function Fe(e){const[t,n]=F(!1),[s,l]=F(!1);J(()=>{const i=()=>n(window.scrollY>24);i(),window.addEventListener("scroll",i,{passive:!0});const u=()=>{window.innerWidth>467&&s()&&(l(!1),document.body.style.overflow="")};window.addEventListener("resize",u,{passive:!0}),Q(()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",u),document.body.style.overflow=""})});const r=i=>{l(i),document.body.style.overflow=i?"hidden":""},o=()=>{const i=["site-header"];return t()&&i.push("is-scrolled"),s()&&i.push("nav-is-open"),i.join(" ")};return(()=>{var i=Pe(),u=i.firstChild,c=u.firstChild,f=c.firstChild,a=c.nextSibling,A=a.firstChild,m=A.nextSibling,S=u.nextSibling,$=S.nextSibling;return E(f,()=>e.brand),E(A,L(ee,{get each(){return e.links},children:d=>(()=>{var b=se();return E(b,()=>d.label),_(()=>x(b,"href",d.href)),b})()})),E(a,L(je,{}),m),m.$$click=()=>r(!s()),S.$$click=()=>r(!1),E($,L(ee,{get each(){return e.links},children:d=>(()=>{var b=se();return b.$$click=()=>r(!1),E(b,()=>d.label),_(()=>x(b,"href",d.href)),b})()})),_(d=>{var b=o(),w=e.homeUrl,v=s()?"true":"false",y=s()?"Close menu":"Open menu",k=s()?"false":"true";return b!==d.e&&Ne(i,d.e=b),w!==d.t&&x(f,"href",d.t=w),v!==d.a&&x(m,"aria-expanded",d.a=v),y!==d.o&&x(m,"aria-label",d.o=y),k!==d.i&&x(S,"aria-hidden",d.i=k),d},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()}he(["click"]);var Ve=O("<span class=marquee-text>Every human being deserves free high quality learning materials — Man Lung Yeung&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"),Ge=O('<div class=marquee-shell role=region aria-label="Site quote"><div class=marquee-line></div><div class=marquee aria-hidden=true><div class=marquee-track></div></div><div class=marquee-line>');function Ye(){const e=()=>Ve();return(()=>{var t=Ge(),n=t.firstChild,s=n.nextSibling,l=s.firstChild;return E(l,e,null),E(l,e,null),E(l,e,null),t})()}function He(){return J(()=>{const e=document.querySelectorAll("[data-scroll-reveal-card]");if(!e.length)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){e.forEach(s=>s.classList.add("is-inview"));return}const n=new IntersectionObserver((s,l)=>{s.forEach(r=>{r.isIntersecting&&(r.target.classList.add("is-inview"),l.unobserve(r.target))})},{threshold:.14});e.forEach((s,l)=>{s.style.transitionDelay=`${l*80}ms`,n.observe(s)}),Q(()=>n.disconnect())}),null}function Ke(){const e=document.getElementById("site-config");return e!=null&&e.textContent?JSON.parse(e.textContent):{brand:"Open Free Books",homeUrl:"/",browseUrl:"/browse/",aboutUrl:"/about/",githubUrl:"https://github.com/openfreebooks/openfreebooks"}}function We(){const e=document.getElementById("footer-year");e&&(e.textContent=String(new Date().getFullYear()))}Me();const I=Ke(),Je=[{label:"Browse",href:I.browseUrl},{label:"About",href:I.aboutUrl},{label:"GitHub",href:I.githubUrl}],le=document.getElementById("site-header");le&&Z(()=>L(Fe,{get brand(){return I.brand},get homeUrl(){return I.homeUrl},links:Je}),le);const ie=document.getElementById("marquee");ie&&Z(()=>L(Ye,{}),ie);Z(()=>L(He,{}),document.body);We();