@zinejs/core 0.4.1 → 0.6.0

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.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ZineJS={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},r=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r};function i(e,t={}){let{direction:n=`ltr`,mode:r=`cover`}=t;if(e<=0)return[];let i=t=>t>=0&&t<e?t:null,a=[];if(r===`single`)for(let t=0;t<e;t++)a.push({left:null,right:t});else if(r===`double`)for(let t=0;t<e;t+=2)a.push({left:i(t),right:i(t+1)});else if(r===`cover`){a.push({left:null,right:0});for(let t=1;t<e;t+=2)a.push({left:i(t),right:i(t+1)})}else if(a.push({left:null,right:0}),e>1){for(let t=1;t<=e-2;t+=2)a.push({left:i(t),right:t+1<=e-2?i(t+1):null});a.push({left:e-1,right:null})}return n===`rtl`?a.map(e=>({left:e.right,right:e.left})):a}function a(e,t){return e<t}function o(e,t,n){let r=[],i=Math.max(0,e-n),a=Math.min(t-1,e+n);for(let e=i;e<=a;e++)r.push(e);return r}var s=class{#e;#t=new Set;constructor(e=2){this.#e=e}get mounted(){return[...this.#t].sort((e,t)=>e-t)}update(e,t){let n=new Set(o(e,t,this.#e)),r=[...n].filter(e=>!this.#t.has(e)).sort((e,t)=>e-t),i=[...this.#t].filter(e=>!n.has(e)).sort((e,t)=>e-t);for(let e of i)this.#t.delete(e);for(let e of r)this.#t.add(e);return{toMount:r,toEvict:i}}},c=class{#e=new Map;on(e,t){let n=this.#e.get(e);return n||(n=new Set,this.#e.set(e,n)),n.add(t),()=>this.off(e,t)}off(e,t){this.#e.get(e)?.delete(t)}emit(e,...t){let n=t[0],r=this.#e.get(e);if(r)for(let e of[...r])e(n)}clear(){this.#e.clear()}},l={idle:{grab:`dragging`,panStart:`zoomed-panning`,flip:`animating`},dragging:{release:`animating`},animating:{settle:`idle`},"zoomed-panning":{panEnd:`idle`}};function u(e,t){return l[e][t]??null}var d=class{#e;constructor(e=`idle`){this.#e=e}get state(){return this.#e}send(e){let t=u(this.#e,e);return t!==null&&(this.#e=t),t}},f=.3,p=class{#e;#t=null;#n=null;#r=null;#i=null;constructor(e={}){this.#e=e}get active(){return this.#t!==null}down(e,t,n,r){if(this.#t!==null)return;this.#t=e;let i={x:t,y:n,t:r};this.#n=i,this.#r=i,this.#i=i,this.#e.onStart?.({x:t,y:n,t:r})}move(e,t,n,r){e!==this.#t||this.#n===null||(this.#r=this.#i,this.#i={x:t,y:n,t:r},this.#e.onMove?.({x:t,y:n,dx:t-this.#n.x,dy:n-this.#n.y}))}up(e,t,n,r){this.#a(e,t,n,r,!1)}cancel(e,t,n,r){this.#a(e,t,n,r,!0)}#a(e,t,n,r,i){if(e!==this.#t||this.#n===null)return;let a=this.#n,o=this.#i??a,s=this.#r??a,c=o.t-s.t,l=c>0?(o.x-s.x)/c:0,u=c>0?(o.y-s.y)/c:0,d=Math.hypot(l,u);this.#o(),this.#e.onEnd?.({x:t,y:n,dx:t-a.x,dy:n-a.y,dt:r-a.t,vx:l,vy:u,swipe:!i&&d>f,canceled:i})}#o(){this.#t=null,this.#n=null,this.#r=null,this.#i=null}};function m(e,t){let{pointer:n,pinch:r}=t,i=e=>{let t=e;n?.down(t.pointerId,t.clientX,t.clientY,t.timeStamp),r?.down(t.pointerId,t.clientX,t.clientY)},a=e=>{let t=e;n?.move(t.pointerId,t.clientX,t.clientY,t.timeStamp),r?.move(t.pointerId,t.clientX,t.clientY)},o=e=>{let t=e;n?.up(t.pointerId,t.clientX,t.clientY,t.timeStamp),r?.up(t.pointerId)},s=e=>{let t=e;n?.cancel(t.pointerId,t.clientX,t.clientY,t.timeStamp),r?.cancel(t.pointerId)};return e.addEventListener(`pointerdown`,i),e.addEventListener(`pointermove`,a),e.addEventListener(`pointerup`,o),e.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,i),e.removeEventListener(`pointermove`,a),e.removeEventListener(`pointerup`,o),e.removeEventListener(`pointercancel`,s)}}function h(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}var g=class{#e;#t=new Map;#n=0;#r=!1;constructor(e={}){this.#e=e}get pinching(){return this.#r}down(e,t,n){if(!(this.#t.has(e)||this.#t.size>=2)&&(this.#t.set(e,{x:t,y:n}),this.#t.size===2)){let{a:e,b:t}=this.#a();this.#n=h(e,t),this.#r=!0,this.#e.onPinchStart?.({centerX:(e.x+t.x)/2,centerY:(e.y+t.y)/2,distance:this.#n})}}move(e,t,n){let r=this.#t.get(e);if(!r||(r.x=t,r.y=n,!this.#r))return;let{a:i,b:a}=this.#a();this.#e.onPinchMove?.({centerX:(i.x+a.x)/2,centerY:(i.y+a.y)/2,scale:this.#n>0?h(i,a)/this.#n:1})}up(e){this.#i(e)}cancel(e){this.#i(e)}#i(e){this.#t.delete(e)&&this.#r&&this.#t.size<2&&(this.#r=!1,this.#n=0,this.#e.onPinchEnd?.())}#a(){let e=[...this.#t.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`pinch requires two active pointers`);return{a:t,b:n}}};function _(e,t,n){let{width:r,height:i}=t;if(e.x<0||e.x>r||e.y<0||e.y>i)return`outside`;let a=e.x<=n||e.x>=r-n,o=e.y<=n||e.y>=i-n;return a&&o?`corner`:`page`}var v,y,b=n((()=>{v=[`roll`,`cone`,`leaf`,`flick`,`silk`,`simple`],y=`cone`}));function x(e){let t=e<0?0:e>1?1:e,n=Math.sin(t*Math.PI);return{angle:t*Math.PI,curl:n,shadowAlpha:n}}var S=n((()=>{})),C=r({CssRenderer:()=>D});function w(e){return e.left===null==(e.right===null)?0:e.right===null?1:-1}function T(e){let t=e===`forward`?`to right`:`to left`;return[`linear-gradient(${t}, rgba(0,0,0,0.6), rgba(0,0,0,0.15) 40%, rgba(0,0,0,0) 60%)`,`linear-gradient(${t}, transparent 40%, rgba(255,255,255,0.32) 66%, transparent 90%)`,`linear-gradient(${t}, transparent 66%, rgba(0,0,0,0.35))`].join(`,`)}var E,D,ee=n((()=>{S(),E=180/Math.PI,D=class{#e=null;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u=0;#d=0;#f=0;#p=0;#m=!1;#h=0;mount(e){let t=e.ownerDocument;return this.#e=e,this.#t=t.createElement(`div`),this.#t.className=`zine-clip`,this.#t.style.cssText=`position:relative;width:100%;height:100%;overflow:hidden;`,this.#n=t.createElement(`div`),this.#n.className=`zine-viewport`,this.#n.style.cssText=`position:absolute;inset:0;transform-origin:0 0;`,this.#r=t.createElement(`div`),this.#r.className=`zine-book`,this.#r.style.cssText=`position:absolute;inset:0;perspective:2000px;transform-style:preserve-3d;`,this.#i=this.#x(t,`zine-page-left`,`left:0;`),this.#a=this.#x(t,`zine-page-right`,`right:0;`),this.#o=t.createElement(`div`),this.#o.className=`zine-leaf`,this.#o.style.cssText=`position:absolute;top:0;width:50%;height:100%;transform-style:preserve-3d;display:none;`,this.#s=t.createElement(`canvas`),this.#s.className=`zine-leaf-front`,this.#s.style.cssText=`position:absolute;inset:0;width:100%;height:100%;backface-visibility:hidden;`,this.#c=t.createElement(`canvas`),this.#c.className=`zine-leaf-back`,this.#c.style.cssText=`position:absolute;inset:0;width:100%;height:100%;backface-visibility:hidden;transform:rotateY(180deg);`,this.#l=t.createElement(`div`),this.#l.className=`zine-leaf-shadow`,this.#l.style.cssText=`position:absolute;inset:0;opacity:0;pointer-events:none;`,this.#l.style.background=T(`forward`),this.#o.append(this.#s,this.#c,this.#l),this.#r.append(this.#i,this.#a,this.#o),this.#n.append(this.#r),this.#t.append(this.#n),e.append(this.#t),Promise.resolve()}destroy(){this.#t?.remove(),this.#e=null}renderSpread(e,t,n){n?.fill?(this.#i.style.width=`100%`,this.#a.style.display=`none`,this.#S(this.#i,t.right??t.left)):(this.#i.style.width=`50%`,this.#a.style.display=``,this.#S(this.#i,t.left),this.#S(this.#a,t.right)),this.#m=n?.fill??!1,this.#h=this.#m?0:w(t),this.#_(t),this.#v(),this.#g(this.#h),this.#o.style.display=`none`,this.#o.style.transform=``,this.#l.style.opacity=`0`}beginFlip(e,t,n,r){r?.fill?(this.#i.style.width=`100%`,this.#a.style.display=`none`,this.#o.style.width=`100%`,this.#o.style.left=`0`,this.#o.style.transformOrigin=n===`forward`?`left center`:`right center`,this.#S(this.#i,t.right??t.left),this.#S(this.#s,e.right??e.left),this.#S(this.#c,t.right??t.left)):(this.#i.style.width=`50%`,this.#a.style.display=``,this.#o.style.width=`50%`,n===`forward`?(this.#S(this.#i,e.left),this.#S(this.#a,t.right),this.#S(this.#s,e.right),this.#S(this.#c,t.left),this.#o.style.left=`50%`,this.#o.style.transformOrigin=`left center`):(this.#S(this.#a,e.right),this.#S(this.#i,t.left),this.#S(this.#s,e.left),this.#S(this.#c,t.right),this.#o.style.left=`0`,this.#o.style.transformOrigin=`right center`)),this.#u=r?.fill?0:w(e),this.#d=r?.fill?0:w(t),this.#m=r?.fill??!1,this.#_(t),this.#v(),this.#g(this.#u),this.#o.style.display=`block`,this.#o.style.transform=`rotateY(0deg)`,this.#l.style.background=T(n),this.#l.style.opacity=`0`}setFlipProgress(e,t){let n=x(e),r=n.angle*E;this.#g(this.#u+(this.#d-this.#u)*e),this.#o.style.display=`block`,this.#o.style.transform=`rotateY(${t===`forward`?-r:r}deg)`,this.#l.style.opacity=String(n.shadowAlpha)}#g(e){let t=e*(this.#p/4);this.#r.style.transform=t?`translateX(${t}px)`:``}#_(e){let t=e.left??e.right;t&&t.height&&(this.#f=t.width/t.height)}#v(){let e=this.#y();this.#p=e.width;let t=this.#r.style;t.inset=`auto`,t.left=`${e.x}px`,t.top=`${e.y}px`,t.width=`${e.width}px`,t.height=`${e.height}px`}#y(){let e=this.#e?.clientWidth??0,t=this.#e?.clientHeight??0;if(this.#f<=0||e<=0||t<=0)return{x:0,y:0,width:e,height:t};let n=(this.#m?1:2)*this.#f,r=e,i=t;return n>e/t?i=e/n:r=t*n,{x:(e-r)/2,y:(t-i)/2,width:r,height:i}}#b(){let e=this.#y();return this.#h===0?e:{x:e.x+e.width/4,y:e.y,width:e.width/2,height:e.height}}setViewTransform(e,t,n){this.#n.style.transform=`translate(${t}px, ${n}px) scale(${e})`}measure(){let e=this.#e,t=e?.clientWidth??0,n=e?.clientHeight??0,r=this.#f>0,i=r?this.#y():void 0,a=r?this.#b():void 0;return{containerWidth:t,containerHeight:n,pageWidth:t/2,pageHeight:n,book:i,content:a}}#x(e,t,n){let r=e.createElement(`canvas`);return r.className=t,r.style.cssText=`position:absolute;top:0;width:50%;height:100%;${n}`,r}#S(e,t){let n=e.getContext(`2d`);if(t===null){n?.clearRect(0,0,e.width,e.height);return}e.width=t.width,e.height=t.height,n?.drawImage(t,0,0)}}}));function te(e,t){let n=e+1,r=t+1,i=n*r,a=new Float32Array(i*2);for(let i=0;i<r;i++)for(let r=0;r<n;r++){let o=i*n+r;a[o*2]=r/e,a[o*2+1]=i/t}return{cols:e,rows:t,uvs:a,positions:new Float32Array(i*3),normals:new Float32Array(i*3)}}function O(e){let t=e.cols+1,n=e.rows+1,r=e.positions,i=e.normals;for(let e=0;e<n;e++)for(let a=0;a<t;a++){let o=a>0?a-1:a,s=a<t-1?a+1:a,c=e>0?e-1:e,l=e<n-1?e+1:e,u=(e*t+s)*3,d=(e*t+o)*3,f=(l*t+a)*3,p=(c*t+a)*3,m=r[u]-r[d],h=r[u+1]-r[d+1],g=r[u+2]-r[d+2],_=r[f]-r[p],v=r[f+1]-r[p+1],y=r[f+2]-r[p+2],b=h*y-g*v,x=g*_-m*y,S=m*v-h*_,C=Math.hypot(b,x,S)||1;b/=C,x/=C,S/=C;let w=(e*t+a)*3;i[w]=b,i[w+1]=x,i[w+2]=S}}var k=n((()=>{}));function ne(e,t,n,r){let i=e.cols+1,a=e.rows+1,o=e.positions,s=Math.max(1e-6,r<.5?r*2*Math.PI:(1-(r-.5)*2)*Math.PI),c=t/s,l=r<.5?0:-(r-.5)*2*Math.PI,u=Math.cos(l),d=Math.sin(l);for(let t=0;t<i;t++){let r=t/e.cols*s,l=Math.sin(r)*c,f=(1-Math.cos(r))*c,p=l*u+f*d,m=-l*d+f*u;for(let r=0;r<a;r++){let a=(r*i+t)*3;o[a]=p,o[a+1]=r/e.rows*n,o[a+2]=m}}O(e)}var re=n((()=>{k()}));function ie(e,t,n,r,i){let a=e.cols+1,o=e.rows+1,s=e.positions,c=!!i.fill,l=Math.sin(Math.PI*r)**.85,u=c?oe:ae,d=Math.PI/2-l*(Math.PI/2-u),f=Math.sin(d),p=Math.cos(d),m=1/Math.max(f,1e-6),h=c?ce:A,g=n*(h+((c?le:se)-h)*l),_=(i.y-.5)*2,v=_>=0,y=Math.min(1,Math.abs(_)/ue),b=1-y,x=v?n+g:-g,S=Math.hypot(t,.5*n-x),C=Math.max(S*f,t/Math.PI),w=c?r**+j:r,T=-Math.PI*w,E=Math.cos(T),D=Math.sin(T);if(l<1e-4){for(let r=0;r<o;r++){let i=r/e.rows*n;for(let n=0;n<a;n++){let o=n/e.cols*t,c=(r*a+n)*3;s[c]=o*E,s[c+1]=i,s[c+2]=-o*D}}O(e);return}for(let r=0;r<o;r++){let i=r/e.rows*n;for(let o=0;o<a;o++){let c=o/e.cols*t,l=c,u=i,d=0;if(y>1e-5){let e=v?n-i:i,t=-g,r=Math.hypot(c,e-t);if(r>1e-8){let e=r*f,i=Math.asin(Math.min(1,Math.max(0,c/r)))*m,a=1-Math.cos(i),o=r+t-e*a*f;l=e*Math.sin(i),u=v?n-o:o,d=e*a*p}}let h=l,_=u,x=d;if(b>1e-5){let e=c/C,t=C*Math.sin(e),n=C*(1-Math.cos(e));h=y*l+b*t,_=y*u+b*i,x=y*d+b*n}let S=(r*a+o)*3;s[S]=h*E+x*D,s[S+1]=_,s[S+2]=-h*D+x*E}}O(e)}var ae,oe,A,se,ce,le,ue,j,de=n((()=>{k(),ae=30*Math.PI/180,oe=44*Math.PI/180,A=1.35,se=.7,ce=1.85,le=1.15,ue=.42,j=1.08}));function fe(){let e=new Float64Array(129),t=new Float64Array(129),n=1/N,r=e=>Math.PI*e-.5*Math.sin(2*Math.PI*e);for(let i=1;i<=N;i++){let a=r((i-1)*n),o=r(i*n);e[i]=e[i-1]+.5*(Math.cos(a)+Math.cos(o))*n,t[i]=t[i-1]+.5*(Math.sin(a)+Math.sin(o))*n}return e[N]=0,{x:e,z:t}}function pe(e){let t=Math.max(0,Math.min(1,e))*N,n=Math.min(N-1,Math.floor(t)),r=t-n;return[P.x[n]+(P.x[n+1]-P.x[n])*r,P.z[n]+(P.z[n+1]-P.z[n])*r]}function me(e,t,n,r,i){let a=e.cols+1,o=e.rows+1,s=e.positions;if(r<=1e-7||r>=.9999999){let i=r<.5?1:-1;for(let r=0;r<o;r++){let o=r/e.rows*n;for(let n=0;n<a;n++){let c=(r*a+n)*3;s[c]=i*(n/e.cols)*t,s[c+1]=o,s[c+2]=0}}O(e);return}let c=Math.sin(Math.PI*r)**.72,l=Math.max(1e-6,t*M*c),u=Math.max(-1,Math.min(1,(i.y-.5)*2))*he*Math.sin(Math.PI*r)**1.15,d=Math.cos(u),f=Math.sin(u),p=-f,m=d,h=Math.abs(f)*n*.5,g=t+h/d,_=g+(-(l+h)/d-g)*r,v=n*.5;for(let r=0;r<o;r++){let i=r/e.rows*n;for(let n=0;n<a;n++){let o=n/e.cols*t,c=o-_,u=i-v,h=c*d+u*f,g=c*p+u*m,y=(r*a+n)*3;if(h<=0){s[y]=o,s[y+1]=i,s[y+2]=0;continue}let b,x;if(h<l){let[e,t]=pe(h/l);b=l*e,x=l*t}else b=-(h-l),x=l*F;s[y]=_+p*g+d*b,s[y+1]=v+m*g+f*b,s[y+2]=x}}O(e)}var M,he,N,P,F,ge=n((()=>{k(),M=.34,he=11*Math.PI/180,N=128,P=fe(),F=P.z[N]}));function _e(e,t,n,r,i){let a=e.cols+1,o=e.rows+1,s=e.cols,c=e.positions,l=t/s,u=Math.PI*r,d=-.52*Math.sin(2*Math.PI*r);for(let t=0;t<o;t++){let r=t/e.rows,o=d*(1+I*Math.abs(r-i.y)),f=r*n,p=0,m=0,h=Math.cos(u),g=Math.sin(u);c[t*a*3]=0,c[t*a*3+1]=f,c[t*a*3+2]=0;for(let e=1;e<a;e++){let n=e/s,r=u+o*n*n,i=Math.cos(r),d=Math.sin(r);p+=.5*(h+i)*l,m+=.5*(g+d)*l,h=i,g=d;let _=(t*a+e)*3;c[_]=p,c[_+1]=f,c[_+2]=m}}O(e)}var I,ve=n((()=>{k(),I=.45}));function ye(e,t,n,r,i){let a=e.cols+1,o=e.rows+1,s=e.cols,c=e.positions,l=t/s,u=!!i.fill;if(r<=1e-7||r>=.9999999){let i=r<.5?1:-1;for(let r=0;r<o;r++){let o=r/e.rows*n;for(let n=0;n<a;n++){let s=(r*a+n)*3;c[s]=i*(n/e.cols)*t,c[s+1]=o,c[s+2]=0}}O(e);return}let d=Math.PI*(u?r**+B:r),f=Math.sin(Math.PI*r)**.8,p=L*f,m=R*Math.sin(Math.PI*r)*(1-r);for(let t=0;t<o;t++){let r=t/e.rows,o=r*n,u=1-z*Math.abs(r-i.y),f=p*(.75+.25*u),h=m*u,g=0,_=0,v=Math.cos(d),y=Math.sin(d);c[t*a*3]=0,c[t*a*3+1]=o,c[t*a*3+2]=0;for(let e=1;e<a;e++){let n=e/s,r=d+f*Math.sin(2*Math.PI*n)+h*n*n,i=Math.cos(r),u=Math.sin(r);g+=.5*(v+i)*l,_+=.5*(y+u)*l,v=i,y=u;let p=(t*a+e)*3;c[p]=g,c[p+1]=o,c[p+2]=_}}O(e)}var L,R,z,B,be=n((()=>{k(),L=.52,R=.62,z=.5,B=1.12}));function xe(e,t,n,r){let i=e.cols+1,a=e.rows+1,o=e.positions,s=r*Math.PI,c=Math.cos(s),l=Math.sin(s);for(let r=0;r<i;r++){let s=r/e.cols*t,u=s*c,d=s*l;for(let t=0;t<a;t++){let a=(t*i+r)*3;o[a]=u,o[a+1]=t/e.rows*n,o[a+2]=d}}O(e)}var Se=n((()=>{k()})),V,Ce=n((()=>{re(),de(),ge(),ve(),be(),Se(),k(),b(),V={roll:{deform:ne,anchored:!1},cone:{deform:ie,anchored:!0},leaf:{deform:me,anchored:!0},flick:{deform:_e,anchored:!0},silk:{deform:ye,anchored:!0},simple:{deform:xe,anchored:!1}}}));function we(e){let t=e.getContext(`webgl2`,{alpha:!0,premultipliedAlpha:!0,antialias:!0,depth:!1,stencil:!1,preserveDrawingBuffer:!0});if(t===null)throw Error(`WebglRenderer: could not create a WebGL2 context.`);return t}var Te=n((()=>{}));function H(e,t,n){let r=e.createProgram();if(r===null)throw Error(`WebglRenderer: could not create a program.`);let i=U(e,e.VERTEX_SHADER,t),a=U(e,e.FRAGMENT_SHADER,n);if(e.attachShader(r,i),e.attachShader(r,a),e.linkProgram(r),e.deleteShader(i),e.deleteShader(a),!e.getProgramParameter(r,e.LINK_STATUS)){let t=e.getProgramInfoLog(r);throw e.deleteProgram(r),Error(`WebglRenderer: program link failed: ${t??`unknown error`}`)}return r}function U(e,t,n){let r=e.createShader(t);if(r===null)throw Error(`WebglRenderer: could not create a shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebglRenderer: shader compile failed: ${t??`unknown error`}`)}return r}var Ee=n((()=>{}));function W(e){let t=e.createTexture();if(t===null)throw Error(`WebglRenderer: could not create a texture.`);return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),t}function De(e,t,n){e.bindTexture(e.TEXTURE_2D,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)}var Oe=n((()=>{})),ke=r({WebglRenderer:()=>Ie});function G(e){return e.left===null==(e.right===null)?0:e.right===null?1:-1}var K,q,Ae,je,J,Y,Me,Ne,Pe,Fe,Ie,Le=n((()=>{Ce(),Te(),Ee(),Oe(),K=`#version 300 es
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ZineJS={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},r=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r};function i(e,t={}){let{direction:n=`ltr`,mode:r=`cover`}=t;if(e<=0)return[];let i=t=>t>=0&&t<e?t:null,a=[];if(r===`single`)for(let t=0;t<e;t++)a.push({left:null,right:t});else if(r===`double`)for(let t=0;t<e;t+=2)a.push({left:i(t),right:i(t+1)});else if(r===`cover`){a.push({left:null,right:0});for(let t=1;t<e;t+=2)a.push({left:i(t),right:i(t+1)})}else if(a.push({left:null,right:0}),e>1){for(let t=1;t<=e-2;t+=2)a.push({left:i(t),right:t+1<=e-2?i(t+1):null});a.push({left:e-1,right:null})}return n===`rtl`?a.map(e=>({left:e.right,right:e.left})):a}function a(e,t){return e<t}function o(e,t,n){let r=[],i=Math.max(0,e-n),a=Math.min(t-1,e+n);for(let e=i;e<=a;e++)r.push(e);return r}var s=class{#e;#t=new Set;constructor(e=2){this.#e=e}get mounted(){return[...this.#t].sort((e,t)=>e-t)}update(e,t){let n=new Set(o(e,t,this.#e)),r=[...n].filter(e=>!this.#t.has(e)).sort((e,t)=>e-t),i=[...this.#t].filter(e=>!n.has(e)).sort((e,t)=>e-t);for(let e of i)this.#t.delete(e);for(let e of r)this.#t.add(e);return{toMount:r,toEvict:i}}},c=class{#e=new Map;on(e,t){let n=this.#e.get(e);return n||(n=new Set,this.#e.set(e,n)),n.add(t),()=>this.off(e,t)}off(e,t){this.#e.get(e)?.delete(t)}emit(e,...t){let n=t[0],r=this.#e.get(e);if(r)for(let e of[...r])e(n)}clear(){this.#e.clear()}},l={idle:{grab:`dragging`,panStart:`zoomed-panning`,flip:`animating`},dragging:{release:`animating`},animating:{settle:`idle`},"zoomed-panning":{panEnd:`idle`}};function u(e,t){return l[e][t]??null}var d=class{#e;constructor(e=`idle`){this.#e=e}get state(){return this.#e}send(e){let t=u(this.#e,e);return t!==null&&(this.#e=t),t}},f=.3,p=class{#e;#t=null;#n=null;#r=null;#i=null;constructor(e={}){this.#e=e}get active(){return this.#t!==null}down(e,t,n,r){if(this.#t!==null)return;this.#t=e;let i={x:t,y:n,t:r};this.#n=i,this.#r=i,this.#i=i,this.#e.onStart?.({x:t,y:n,t:r})}move(e,t,n,r){e!==this.#t||this.#n===null||(this.#r=this.#i,this.#i={x:t,y:n,t:r},this.#e.onMove?.({x:t,y:n,dx:t-this.#n.x,dy:n-this.#n.y}))}up(e,t,n,r){this.#a(e,t,n,r,!1)}cancel(e,t,n,r){this.#a(e,t,n,r,!0)}#a(e,t,n,r,i){if(e!==this.#t||this.#n===null)return;let a=this.#n,o=this.#i??a,s=this.#r??a,c=o.t-s.t,l=c>0?(o.x-s.x)/c:0,u=c>0?(o.y-s.y)/c:0,d=Math.hypot(l,u);this.#o(),this.#e.onEnd?.({x:t,y:n,dx:t-a.x,dy:n-a.y,dt:r-a.t,vx:l,vy:u,swipe:!i&&d>f,canceled:i})}#o(){this.#t=null,this.#n=null,this.#r=null,this.#i=null}};function m(e,t){let{pointer:n,pinch:r}=t,i=e=>{let t=e;n?.down(t.pointerId,t.clientX,t.clientY,t.timeStamp),r?.down(t.pointerId,t.clientX,t.clientY)},a=e=>{let t=e;n?.move(t.pointerId,t.clientX,t.clientY,t.timeStamp),r?.move(t.pointerId,t.clientX,t.clientY)},o=e=>{let t=e;n?.up(t.pointerId,t.clientX,t.clientY,t.timeStamp),r?.up(t.pointerId)},s=e=>{let t=e;n?.cancel(t.pointerId,t.clientX,t.clientY,t.timeStamp),r?.cancel(t.pointerId)};return e.addEventListener(`pointerdown`,i),e.addEventListener(`pointermove`,a),e.addEventListener(`pointerup`,o),e.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,i),e.removeEventListener(`pointermove`,a),e.removeEventListener(`pointerup`,o),e.removeEventListener(`pointercancel`,s)}}function h(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}var g=class{#e;#t=new Map;#n=0;#r=!1;constructor(e={}){this.#e=e}get pinching(){return this.#r}down(e,t,n){if(!(this.#t.has(e)||this.#t.size>=2)&&(this.#t.set(e,{x:t,y:n}),this.#t.size===2)){let{a:e,b:t}=this.#a();this.#n=h(e,t),this.#r=!0,this.#e.onPinchStart?.({centerX:(e.x+t.x)/2,centerY:(e.y+t.y)/2,distance:this.#n})}}move(e,t,n){let r=this.#t.get(e);if(!r||(r.x=t,r.y=n,!this.#r))return;let{a:i,b:a}=this.#a();this.#e.onPinchMove?.({centerX:(i.x+a.x)/2,centerY:(i.y+a.y)/2,scale:this.#n>0?h(i,a)/this.#n:1})}up(e){this.#i(e)}cancel(e){this.#i(e)}#i(e){this.#t.delete(e)&&this.#r&&this.#t.size<2&&(this.#r=!1,this.#n=0,this.#e.onPinchEnd?.())}#a(){let e=[...this.#t.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`pinch requires two active pointers`);return{a:t,b:n}}};function _(e,t,n){let{width:r,height:i}=t;if(e.x<0||e.x>r||e.y<0||e.y>i)return`outside`;let a=e.x<=n||e.x>=r-n,o=e.y<=n||e.y>=i-n;return a&&o?`corner`:`page`}var v=`page`,y=!1;function b(){return y?!1:(y=!0,!0)}function x(){y=!1}function S(e){let t=new URLSearchParams(e.replace(/^#/,``)).get(v);if(t===null)return null;let n=Number(t);return Number.isInteger(n)&&n>=1?n-1:null}function C(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return n.set(v,String(t+1)),`#${n.toString()}`}function w(e,t){let n=null,r=()=>{let r=S(e.location.hash);r===null||r===n||(n=r,t(r))};return e.addEventListener(`hashchange`,r),{push(t){if(t===n)return;n=t;let r=C(e.location.hash,t);r!==e.location.hash&&e.history?.replaceState?.(e.history.state,``,r)},stop(){e.removeEventListener(`hashchange`,r)}}}var T,E,D=n((()=>{T=[`roll`,`cone`,`leaf`,`flick`,`silk`,`simple`],E=`cone`}));function ee(e){let t=e<0?0:e>1?1:e,n=Math.sin(t*Math.PI);return{angle:t*Math.PI,curl:n,shadowAlpha:n}}var te=n((()=>{})),ne=r({CssRenderer:()=>ae});function O(e){return e.left===null==(e.right===null)?0:e.right===null?1:-1}function re(e){let t=e===`forward`?`to right`:`to left`;return[`linear-gradient(${t}, rgba(0,0,0,0.6), rgba(0,0,0,0.15) 40%, rgba(0,0,0,0) 60%)`,`linear-gradient(${t}, transparent 40%, rgba(255,255,255,0.32) 66%, transparent 90%)`,`linear-gradient(${t}, transparent 66%, rgba(0,0,0,0.35))`].join(`,`)}var ie,ae,oe=n((()=>{te(),ie=180/Math.PI,ae=class{#e=null;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u=0;#d=0;#f=0;#p=0;#m=!1;#h=0;mount(e){let t=e.ownerDocument;return this.#e=e,this.#t=t.createElement(`div`),this.#t.className=`zine-clip`,this.#t.style.cssText=`position:relative;width:100%;height:100%;overflow:hidden;`,this.#n=t.createElement(`div`),this.#n.className=`zine-viewport`,this.#n.style.cssText=`position:absolute;inset:0;transform-origin:0 0;`,this.#r=t.createElement(`div`),this.#r.className=`zine-book`,this.#r.style.cssText=`position:absolute;inset:0;perspective:2000px;transform-style:preserve-3d;`,this.#i=this.#x(t,`zine-page-left`,`left:0;`),this.#a=this.#x(t,`zine-page-right`,`right:0;`),this.#o=t.createElement(`div`),this.#o.className=`zine-leaf`,this.#o.style.cssText=`position:absolute;top:0;width:50%;height:100%;transform-style:preserve-3d;display:none;`,this.#s=t.createElement(`canvas`),this.#s.className=`zine-leaf-front`,this.#s.style.cssText=`position:absolute;inset:0;width:100%;height:100%;backface-visibility:hidden;`,this.#c=t.createElement(`canvas`),this.#c.className=`zine-leaf-back`,this.#c.style.cssText=`position:absolute;inset:0;width:100%;height:100%;backface-visibility:hidden;transform:rotateY(180deg);`,this.#l=t.createElement(`div`),this.#l.className=`zine-leaf-shadow`,this.#l.style.cssText=`position:absolute;inset:0;opacity:0;pointer-events:none;`,this.#l.style.background=re(`forward`),this.#o.append(this.#s,this.#c,this.#l),this.#r.append(this.#i,this.#a,this.#o),this.#n.append(this.#r),this.#t.append(this.#n),e.append(this.#t),Promise.resolve()}destroy(){this.#t?.remove(),this.#e=null}renderSpread(e,t,n){n?.fill?(this.#i.style.width=`100%`,this.#a.style.display=`none`,this.#S(this.#i,t.right??t.left)):(this.#i.style.width=`50%`,this.#a.style.display=``,this.#S(this.#i,t.left),this.#S(this.#a,t.right)),this.#m=n?.fill??!1,this.#h=this.#m?0:O(t),this.#_(t),this.#v(),this.#g(this.#h),this.#o.style.display=`none`,this.#o.style.transform=``,this.#l.style.opacity=`0`}beginFlip(e,t,n,r){r?.fill?(this.#i.style.width=`100%`,this.#a.style.display=`none`,this.#o.style.width=`100%`,this.#o.style.left=`0`,this.#o.style.transformOrigin=n===`forward`?`left center`:`right center`,this.#S(this.#i,t.right??t.left),this.#S(this.#s,e.right??e.left),this.#S(this.#c,t.right??t.left)):(this.#i.style.width=`50%`,this.#a.style.display=``,this.#o.style.width=`50%`,n===`forward`?(this.#S(this.#i,e.left),this.#S(this.#a,t.right),this.#S(this.#s,e.right),this.#S(this.#c,t.left),this.#o.style.left=`50%`,this.#o.style.transformOrigin=`left center`):(this.#S(this.#a,e.right),this.#S(this.#i,t.left),this.#S(this.#s,e.left),this.#S(this.#c,t.right),this.#o.style.left=`0`,this.#o.style.transformOrigin=`right center`)),this.#u=r?.fill?0:O(e),this.#d=r?.fill?0:O(t),this.#m=r?.fill??!1,this.#_(t),this.#v(),this.#g(this.#u),this.#o.style.display=`block`,this.#o.style.transform=`rotateY(0deg)`,this.#l.style.background=re(n),this.#l.style.opacity=`0`}setFlipProgress(e,t){let n=ee(e),r=n.angle*ie;this.#g(this.#u+(this.#d-this.#u)*e),this.#o.style.display=`block`,this.#o.style.transform=`rotateY(${t===`forward`?-r:r}deg)`,this.#l.style.opacity=String(n.shadowAlpha)}#g(e){let t=e*(this.#p/4);this.#r.style.transform=t?`translateX(${t}px)`:``}#_(e){let t=e.left??e.right;t&&t.height&&(this.#f=t.width/t.height)}#v(){let e=this.#y();this.#p=e.width;let t=this.#r.style;t.inset=`auto`,t.left=`${e.x}px`,t.top=`${e.y}px`,t.width=`${e.width}px`,t.height=`${e.height}px`}#y(){let e=this.#e?.clientWidth??0,t=this.#e?.clientHeight??0;if(this.#f<=0||e<=0||t<=0)return{x:0,y:0,width:e,height:t};let n=(this.#m?1:2)*this.#f,r=e,i=t;return n>e/t?i=e/n:r=t*n,{x:(e-r)/2,y:(t-i)/2,width:r,height:i}}#b(){let e=this.#y();return this.#h===0?e:{x:e.x+e.width/4,y:e.y,width:e.width/2,height:e.height}}setViewTransform(e,t,n){this.#n.style.transform=`translate(${t}px, ${n}px) scale(${e})`}measure(){let e=this.#e,t=e?.clientWidth??0,n=e?.clientHeight??0,r=this.#f>0,i=r?this.#y():void 0,a=r?this.#b():void 0;return{containerWidth:t,containerHeight:n,pageWidth:t/2,pageHeight:n,book:i,content:a}}#x(e,t,n){let r=e.createElement(`canvas`);return r.className=t,r.style.cssText=`position:absolute;top:0;width:50%;height:100%;${n}`,r}#S(e,t){let n=e.getContext(`2d`);if(t===null){n?.clearRect(0,0,e.width,e.height);return}e.width=t.width,e.height=t.height,n?.drawImage(t,0,0)}}}));function se(e,t){let n=e+1,r=t+1,i=n*r,a=new Float32Array(i*2);for(let i=0;i<r;i++)for(let r=0;r<n;r++){let o=i*n+r;a[o*2]=r/e,a[o*2+1]=i/t}return{cols:e,rows:t,uvs:a,positions:new Float32Array(i*3),normals:new Float32Array(i*3)}}function k(e){let t=e.cols+1,n=e.rows+1,r=e.positions,i=e.normals;for(let e=0;e<n;e++)for(let a=0;a<t;a++){let o=a>0?a-1:a,s=a<t-1?a+1:a,c=e>0?e-1:e,l=e<n-1?e+1:e,u=(e*t+s)*3,d=(e*t+o)*3,f=(l*t+a)*3,p=(c*t+a)*3,m=r[u]-r[d],h=r[u+1]-r[d+1],g=r[u+2]-r[d+2],_=r[f]-r[p],v=r[f+1]-r[p+1],y=r[f+2]-r[p+2],b=h*y-g*v,x=g*_-m*y,S=m*v-h*_,C=Math.hypot(b,x,S)||1;b/=C,x/=C,S/=C;let w=(e*t+a)*3;i[w]=b,i[w+1]=x,i[w+2]=S}}var A=n((()=>{}));function ce(e,t,n,r){let i=e.cols+1,a=e.rows+1,o=e.positions,s=Math.max(1e-6,r<.5?r*2*Math.PI:(1-(r-.5)*2)*Math.PI),c=t/s,l=r<.5?0:-(r-.5)*2*Math.PI,u=Math.cos(l),d=Math.sin(l);for(let t=0;t<i;t++){let r=t/e.cols*s,l=Math.sin(r)*c,f=(1-Math.cos(r))*c,p=l*u+f*d,m=-l*d+f*u;for(let r=0;r<a;r++){let a=(r*i+t)*3;o[a]=p,o[a+1]=r/e.rows*n,o[a+2]=m}}k(e)}var le=n((()=>{A()}));function ue(e,t,n,r,i){let a=e.cols+1,o=e.rows+1,s=e.positions,c=!!i.fill,l=Math.sin(Math.PI*r)**.85,u=c?fe:de,d=Math.PI/2-l*(Math.PI/2-u),f=Math.sin(d),p=Math.cos(d),m=1/Math.max(f,1e-6),h=c?he:pe,g=n*(h+((c?ge:me)-h)*l),_=(i.y-.5)*2,v=_>=0,y=Math.min(1,Math.abs(_)/_e),b=1-y,x=v?n+g:-g,S=Math.hypot(t,.5*n-x),C=Math.max(S*f,t/Math.PI),w=c?r**+ve:r,T=-Math.PI*w,E=Math.cos(T),D=Math.sin(T);if(l<1e-4){for(let r=0;r<o;r++){let i=r/e.rows*n;for(let n=0;n<a;n++){let o=n/e.cols*t,c=(r*a+n)*3;s[c]=o*E,s[c+1]=i,s[c+2]=-o*D}}k(e);return}for(let r=0;r<o;r++){let i=r/e.rows*n;for(let o=0;o<a;o++){let c=o/e.cols*t,l=c,u=i,d=0;if(y>1e-5){let e=v?n-i:i,t=-g,r=Math.hypot(c,e-t);if(r>1e-8){let e=r*f,i=Math.asin(Math.min(1,Math.max(0,c/r)))*m,a=1-Math.cos(i),o=r+t-e*a*f;l=e*Math.sin(i),u=v?n-o:o,d=e*a*p}}let h=l,_=u,x=d;if(b>1e-5){let e=c/C,t=C*Math.sin(e),n=C*(1-Math.cos(e));h=y*l+b*t,_=y*u+b*i,x=y*d+b*n}let S=(r*a+o)*3;s[S]=h*E+x*D,s[S+1]=_,s[S+2]=-h*D+x*E}}k(e)}var de,fe,pe,me,he,ge,_e,ve,ye=n((()=>{A(),de=30*Math.PI/180,fe=44*Math.PI/180,pe=1.35,me=.7,he=1.85,ge=1.15,_e=.42,ve=1.08}));function be(){let e=new Float64Array(129),t=new Float64Array(129),n=1/j,r=e=>Math.PI*e-.5*Math.sin(2*Math.PI*e);for(let i=1;i<=j;i++){let a=r((i-1)*n),o=r(i*n);e[i]=e[i-1]+.5*(Math.cos(a)+Math.cos(o))*n,t[i]=t[i-1]+.5*(Math.sin(a)+Math.sin(o))*n}return e[j]=0,{x:e,z:t}}function xe(e){let t=Math.max(0,Math.min(1,e))*j,n=Math.min(j-1,Math.floor(t)),r=t-n;return[M.x[n]+(M.x[n+1]-M.x[n])*r,M.z[n]+(M.z[n+1]-M.z[n])*r]}function Se(e,t,n,r,i){let a=e.cols+1,o=e.rows+1,s=e.positions;if(r<=1e-7||r>=.9999999){let i=r<.5?1:-1;for(let r=0;r<o;r++){let o=r/e.rows*n;for(let n=0;n<a;n++){let c=(r*a+n)*3;s[c]=i*(n/e.cols)*t,s[c+1]=o,s[c+2]=0}}k(e);return}let c=Math.sin(Math.PI*r)**.72,l=Math.max(1e-6,t*Ce*c),u=Math.max(-1,Math.min(1,(i.y-.5)*2))*we*Math.sin(Math.PI*r)**1.15,d=Math.cos(u),f=Math.sin(u),p=-f,m=d,h=Math.abs(f)*n*.5,g=t+h/d,_=g+(-(l+h)/d-g)*r,v=n*.5;for(let r=0;r<o;r++){let i=r/e.rows*n;for(let n=0;n<a;n++){let o=n/e.cols*t,c=o-_,u=i-v,h=c*d+u*f,g=c*p+u*m,y=(r*a+n)*3;if(h<=0){s[y]=o,s[y+1]=i,s[y+2]=0;continue}let b,x;if(h<l){let[e,t]=xe(h/l);b=l*e,x=l*t}else b=-(h-l),x=l*Te;s[y]=_+p*g+d*b,s[y+1]=v+m*g+f*b,s[y+2]=x}}k(e)}var Ce,we,j,M,Te,Ee=n((()=>{A(),Ce=.34,we=11*Math.PI/180,j=128,M=be(),Te=M.z[j]}));function De(e,t,n,r,i){let a=e.cols+1,o=e.rows+1,s=e.cols,c=e.positions,l=t/s,u=Math.PI*r,d=-.52*Math.sin(2*Math.PI*r);for(let t=0;t<o;t++){let r=t/e.rows,o=d*(1+Oe*Math.abs(r-i.y)),f=r*n,p=0,m=0,h=Math.cos(u),g=Math.sin(u);c[t*a*3]=0,c[t*a*3+1]=f,c[t*a*3+2]=0;for(let e=1;e<a;e++){let n=e/s,r=u+o*n*n,i=Math.cos(r),d=Math.sin(r);p+=.5*(h+i)*l,m+=.5*(g+d)*l,h=i,g=d;let _=(t*a+e)*3;c[_]=p,c[_+1]=f,c[_+2]=m}}k(e)}var Oe,ke=n((()=>{A(),Oe=.45}));function Ae(e,t,n,r,i){let a=e.cols+1,o=e.rows+1,s=e.cols,c=e.positions,l=t/s,u=!!i.fill;if(r<=1e-7||r>=.9999999){let i=r<.5?1:-1;for(let r=0;r<o;r++){let o=r/e.rows*n;for(let n=0;n<a;n++){let s=(r*a+n)*3;c[s]=i*(n/e.cols)*t,c[s+1]=o,c[s+2]=0}}k(e);return}let d=Math.PI*(u?r**+Pe:r),f=Math.sin(Math.PI*r)**.8,p=je*f,m=Me*Math.sin(Math.PI*r)*(1-r);for(let t=0;t<o;t++){let r=t/e.rows,o=r*n,u=1-Ne*Math.abs(r-i.y),f=p*(.75+.25*u),h=m*u,g=0,_=0,v=Math.cos(d),y=Math.sin(d);c[t*a*3]=0,c[t*a*3+1]=o,c[t*a*3+2]=0;for(let e=1;e<a;e++){let n=e/s,r=d+f*Math.sin(2*Math.PI*n)+h*n*n,i=Math.cos(r),u=Math.sin(r);g+=.5*(v+i)*l,_+=.5*(y+u)*l,v=i,y=u;let p=(t*a+e)*3;c[p]=g,c[p+1]=o,c[p+2]=_}}k(e)}var je,Me,Ne,Pe,Fe=n((()=>{A(),je=.52,Me=.62,Ne=.5,Pe=1.12}));function Ie(e,t,n,r){let i=e.cols+1,a=e.rows+1,o=e.positions,s=r*Math.PI,c=Math.cos(s),l=Math.sin(s);for(let r=0;r<i;r++){let s=r/e.cols*t,u=s*c,d=s*l;for(let t=0;t<a;t++){let a=(t*i+r)*3;o[a]=u,o[a+1]=t/e.rows*n,o[a+2]=d}}k(e)}var Le=n((()=>{A()})),Re,ze=n((()=>{le(),ye(),Ee(),ke(),Fe(),Le(),A(),D(),Re={roll:{deform:ce,anchored:!1},cone:{deform:ue,anchored:!0},leaf:{deform:Se,anchored:!0},flick:{deform:De,anchored:!0},silk:{deform:Ae,anchored:!0},simple:{deform:Ie,anchored:!1}}}));function Be(e){let t=e.getContext(`webgl2`,{alpha:!0,premultipliedAlpha:!0,antialias:!0,depth:!1,stencil:!1,preserveDrawingBuffer:!0});if(t===null)throw Error(`WebglRenderer: could not create a WebGL2 context.`);return t}var Ve=n((()=>{}));function He(e,t,n){let r=e.createProgram();if(r===null)throw Error(`WebglRenderer: could not create a program.`);let i=Ue(e,e.VERTEX_SHADER,t),a=Ue(e,e.FRAGMENT_SHADER,n);if(e.attachShader(r,i),e.attachShader(r,a),e.linkProgram(r),e.deleteShader(i),e.deleteShader(a),!e.getProgramParameter(r,e.LINK_STATUS)){let t=e.getProgramInfoLog(r);throw e.deleteProgram(r),Error(`WebglRenderer: program link failed: ${t??`unknown error`}`)}return r}function Ue(e,t,n){let r=e.createShader(t);if(r===null)throw Error(`WebglRenderer: could not create a shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebglRenderer: shader compile failed: ${t??`unknown error`}`)}return r}var We=n((()=>{}));function Ge(e){let t=e.createTexture();if(t===null)throw Error(`WebglRenderer: could not create a texture.`);return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),t}function Ke(e,t,n){e.bindTexture(e.TEXTURE_2D,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)}var qe=n((()=>{})),Je=r({WebglRenderer:()=>rt});function N(e){return e.left===null==(e.right===null)?0:e.right===null?1:-1}var Ye,Xe,Ze,Qe,P,F,$e,et,tt,nt,rt,it=n((()=>{ze(),Ve(),We(),qe(),Ye=`#version 300 es
2
2
  in vec2 aUnit;
3
3
  uniform vec2 uViewport;
4
4
  uniform vec4 uRect;
@@ -10,7 +10,7 @@ void main() {
10
10
  vec2 clip = px / uViewport * 2.0 - 1.0;
11
11
  gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);
12
12
  vUv = aUnit;
13
- }`,q=`#version 300 es
13
+ }`,Xe=`#version 300 es
14
14
  precision mediump float;
15
15
  in vec2 vUv;
16
16
  uniform sampler2D uTex;
@@ -23,7 +23,7 @@ void main() {
23
23
  c.rgb *= mix(0.72, 1.0, smoothstep(0.0, 0.10, d));
24
24
  }
25
25
  outColor = c;
26
- }`,Ae=`#version 300 es
26
+ }`,Ze=`#version 300 es
27
27
  in vec3 aPos; // leaf-local device px: x = bent offset from spine, y 0..H, z depth
28
28
  in vec3 aNormal;
29
29
  in vec2 aUv;
@@ -54,7 +54,7 @@ void main() {
54
54
  vUv = aUv;
55
55
  vFacing = aNormal.z;
56
56
  vU = aUv.x;
57
- }`,je=`#version 300 es
57
+ }`,Qe=`#version 300 es
58
58
  precision mediump float;
59
59
  in vec2 vUv;
60
60
  in float vFacing;
@@ -87,5 +87,447 @@ void main() {
87
87
  // Premultiplied alpha (blendFunc ONE, ONE_MINUS_SRC_ALPHA): scale colour as well as alpha,
88
88
  // or fading would brighten the sheet additively instead of dissolving it.
89
89
  outColor = vec4(c.rgb * uAlpha, c.a * uAlpha);
90
- }`,J=28,Y=36,Me=.7,Ne=.8,Pe=4e3,Fe=256*1024*1024,Ie=class{#e=null;#t=null;#n=null;#r=null;#i=null;#a=null;#o=null;#s=null;#c=null;#l=0;#u=te(J,Y);#d=new Map;#f=0;#p=null;#m={};#h={};#g={scale:1,tx:0,ty:0};#_=1;#v=null;#y=!1;#b=null;#x=0;#S=y;#C={y:.5};#w=0;#T=0;#E=0;#D=0;#O=0;#k=0;#A=!1;#j=!1;#M=null;#N=null;mount(e){this.#e=e;let t=e.ownerDocument,n=t.createElement(`canvas`);return n.style.cssText=`display:block;width:100%;height:100%;`,e.append(n),this.#t=n,n.addEventListener(`webglcontextlost`,this.#L),n.addEventListener(`webglcontextrestored`,this.#R),t.addEventListener(`visibilitychange`,this.#z),this.#n=we(n),this.#H(),Promise.resolve()}destroy(){this.#V();let e=this.#t;e!==null&&(e.removeEventListener(`webglcontextlost`,this.#L),e.removeEventListener(`webglcontextrestored`,this.#R),e.ownerDocument.removeEventListener(`visibilitychange`,this.#z));let t=this.#n;if(t!==null){for(let e of this.#d.values())t.deleteTexture(e.tex);this.#p!==null&&t.deleteTexture(this.#p),this.#a!==null&&t.deleteVertexArray(this.#a),this.#o!==null&&t.deleteVertexArray(this.#o),this.#r!==null&&t.deleteProgram(this.#r),this.#i!==null&&t.deleteProgram(this.#i),t.getExtension(`WEBGL_lose_context`)?.loseContext()}e?.remove(),this.#d.clear(),this.#f=0,this.#p=null,this.#e=null,this.#t=null,this.#n=null,this.#v=null,this.#b=null}onFatal(e){this.#N=e}renderSpread(e,t,n){this.#v=t,this.#y=n?.fill??!1,this.#b=null,this.#P(t),this.#G()}#P(e){let t=e.left??e.right;t&&t.height&&(this.#D=t.width/t.height)}beginFlip(e,t,n,r){let i=r?.fill??!1;this.#x=0,r?.curl&&(this.#S=r.curl),r?.anchor&&(this.#C=r.anchor),this.#T=i?0:G(e),this.#E=i?0:G(t),this.#P(t),i?this.#b={underLeft:null,underRight:null,underFull:t.right??t.left,front:e.right??e.left,back:e.right??e.left,dir:n===`forward`?1:-1,fill:!0}:n===`forward`?this.#b={underLeft:e.left,underRight:t.right,underFull:null,front:e.right,back:t.left,dir:1,fill:!1}:this.#b={underLeft:t.left,underRight:e.right,underFull:null,front:e.left,back:t.right,dir:-1,fill:!1},this.#G()}setFlipProgress(e,t){this.#x=e,this.#G()}setViewTransform(e,t,n){this.#g={scale:e,tx:t,ty:n},this.#G()}measure(){let e=this.#e,t=e?.clientWidth??0,n=e?.clientHeight??0,r=this.#D>0,i=r?this.#F():void 0,a=r?this.#I():void 0;return{containerWidth:t,containerHeight:n,pageWidth:t/2,pageHeight:n,book:i,content:a}}#F(){let e=this.#e,t=e?.clientWidth??0,n=e?.clientHeight??0;if(this.#D<=0||t<=0||n<=0)return{x:0,y:0,width:t,height:n};let r=(this.#y?1:2)*this.#D,i=t,a=n;return r>t/n?a=t/r:i=n*r,{x:(t-i)/2,y:(n-a)/2,width:i,height:a}}#I(){let e=this.#F();return!this.#y&&this.#v!==null&&G(this.#v)!==0?{x:e.x+e.width/4,y:e.y,width:e.width/2,height:e.height}:e}#L=e=>{e.preventDefault(),this.#A=!0,this.#M===null&&(this.#M=setTimeout(()=>this.#B(),Pe))};#R=()=>{this.#V(),this.#A=!1,this.#H(),this.#G()};#z=()=>{this.#t?.ownerDocument.visibilityState===`visible`&&this.#G()};#B(){this.#j||(this.#j=!0,this.#N?.())}#V(){this.#M!==null&&(clearTimeout(this.#M),this.#M=null)}#H(){let e=this.#n;if(e!==null){this.#r=H(e,K,q),this.#i=H(e,Ae,je);for(let t of[`uViewport`,`uRect`,`uView`,`uTex`,`uGutterSide`])this.#m[t]=e.getUniformLocation(this.#r,t);for(let t of[`uViewport`,`uView`,`uOriginX`,`uDir`,`uLeafW`,`uFront`,`uBack`,`uGloss`,`uAlpha`])this.#h[t]=e.getUniformLocation(this.#i,t);this.#a=this.#U(e,this.#r),this.#W(e,this.#i),this.#d.clear(),this.#f=0,this.#p=this.#te(e),e.useProgram(this.#r),e.uniform1i(this.#m.uTex??null,0),e.useProgram(this.#i),e.uniform1i(this.#h.uFront??null,0),e.uniform1i(this.#h.uBack??null,1),e.clearColor(0,0,0,0),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}}#U(e,t){let n=e.createVertexArray(),r=e.createBuffer();if(n===null||r===null)throw Error(`WebglRenderer: could not create buffers.`);e.bindVertexArray(n),e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW);let i=e.getAttribLocation(t,`aUnit`);return e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),n}#W(e,t){let n=[];for(let e=0;e<Y;e++)for(let t=0;t<J;t++){let r=e*29+t,i=r+1,a=r+29,o=a+1;n.push(r,a,i,i,a,o)}this.#l=n.length;let r=e.createVertexArray();this.#s=e.createBuffer(),this.#c=e.createBuffer();let i=e.createBuffer(),a=e.createBuffer();if(r===null||this.#s===null||this.#c===null||i===null||a===null)throw Error(`WebglRenderer: could not create mesh buffers.`);e.bindVertexArray(r),e.bindBuffer(e.ARRAY_BUFFER,this.#s),e.bufferData(e.ARRAY_BUFFER,this.#u.positions,e.DYNAMIC_DRAW);let o=e.getAttribLocation(t,`aPos`);e.enableVertexAttribArray(o),e.vertexAttribPointer(o,3,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#c),e.bufferData(e.ARRAY_BUFFER,this.#u.normals,e.DYNAMIC_DRAW);let s=e.getAttribLocation(t,`aNormal`);e.enableVertexAttribArray(s),e.vertexAttribPointer(s,3,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,this.#u.uvs,e.STATIC_DRAW);let c=e.getAttribLocation(t,`aUv`);e.enableVertexAttribArray(c),e.vertexAttribPointer(c,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(n),e.STATIC_DRAW),e.bindVertexArray(null),this.#o=r}#G(){let e=this.#n,t=this.#t;e===null||t===null||this.#A||e.isContextLost()||(this.#ne(),e.clear(e.COLOR_BUFFER_BIT),this.#K(),this.#b===null?this.#v!==null&&this.#q():this.#J())}#K(){let e=this.#n,t=this.#t,n=t.width,r=t.height;if(this.#D>0){let e=(this.#y?1:2)*this.#D;e>n/r?(this.#O=n,this.#k=Math.round(n/e)):(this.#k=r,this.#O=Math.round(r*e))}else this.#O=n,this.#k=r;let i=Math.round((n-this.#O)/2),a=Math.round((r-this.#k)/2);e.viewport(i,a,this.#O,this.#k)}#q(){let e=this.#O,t=this.#k,n=this.#v;this.#w=this.#y?0:G(n)*(e/4),this.#X(),this.#y?this.#Z({x:0,y:0,w:e,h:t},n.right??n.left):(this.#Z({x:0,y:0,w:e/2,h:t},n.left,+!!n.right),this.#Z({x:e/2,y:0,w:e/2,h:t},n.right,n.left?-1:0))}#J(){let e=this.#n,t=this.#O,n=this.#k,r=this.#b;if(this.#w=r.fill?0:(this.#T+(this.#E-this.#T)*this.#x)*(t/4),this.#X(),r.fill?this.#Z({x:0,y:0,w:t,h:n},r.underFull):(this.#Z({x:0,y:0,w:t/2,h:n},r.underLeft,1),this.#Z({x:t/2,y:0,w:t/2,h:n},r.underRight,-1)),r.front===null&&r.back===null)return;let i=r.fill?t:t/2,a=r.fill?r.dir>0?0:t:t/2;V[this.#S].deform(this.#u,i,n,this.#x,{y:this.#C.y,fill:r.fill}),e.bindBuffer(e.ARRAY_BUFFER,this.#s),e.bufferSubData(e.ARRAY_BUFFER,0,this.#u.positions),e.bindBuffer(e.ARRAY_BUFFER,this.#c),e.bufferSubData(e.ARRAY_BUFFER,0,this.#u.normals),this.#Q(e.TEXTURE0,r.front),this.#Q(e.TEXTURE1,r.back),e.activeTexture(e.TEXTURE0),e.useProgram(this.#i),e.bindVertexArray(this.#o),e.uniform2f(this.#h.uViewport??null,t,n),e.uniform3f(this.#h.uView??null,this.#g.scale,this.#g.tx*this.#_+this.#w,this.#g.ty*this.#_),e.uniform1f(this.#h.uOriginX??null,a),e.uniform1f(this.#h.uDir??null,r.dir),e.uniform1f(this.#h.uLeafW??null,i),e.uniform1f(this.#h.uGloss??null,this.#S===`simple`?0:1),e.uniform1f(this.#h.uAlpha??null,r.fill?this.#Y():1),e.drawElements(e.TRIANGLES,this.#l,e.UNSIGNED_SHORT,0)}#Y(){let e=this.#S===`roll`||this.#S===`simple`?Me:Ne,t=(this.#x-e)/(1-e);return t<=0?1:t>=1?0:(1-t)**1.5}#X(){let e=this.#n;e.useProgram(this.#r),e.bindVertexArray(this.#a),e.activeTexture(e.TEXTURE0),e.uniform2f(this.#m.uViewport??null,this.#O,this.#k),e.uniform3f(this.#m.uView??null,this.#g.scale,this.#g.tx*this.#_+this.#w,this.#g.ty*this.#_)}#Z(e,t,n=0){let r=this.#n;t!==null&&(this.#Q(r.TEXTURE0,t),r.uniform4f(this.#m.uRect??null,e.x,e.y,e.w,e.h),r.uniform1f(this.#m.uGutterSide??null,n),r.drawArrays(r.TRIANGLE_STRIP,0,4))}#Q(e,t){let n=this.#n;n.activeTexture(e),n.bindTexture(n.TEXTURE_2D,t===null?this.#p:this.#$(t))}#$(e){let t=this.#n,n=this.#d.get(e);if(n!==void 0)return this.#d.delete(e),this.#d.set(e,n),n.tex;let r=W(t);De(t,r,e);let i=e,a=i.width*i.height*4;return this.#d.set(e,{tex:r,bytes:a}),this.#f+=a,this.#ee(),r}#ee(){let e=this.#n;for(let[t,n]of this.#d){if(this.#f<=Fe||this.#d.size<=4)break;this.#d.delete(t),this.#f-=n.bytes,e.deleteTexture(n.tex)}}#te(e){let t=W(e);return e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,0])),t}#ne(){let e=this.#n,t=this.#t,n=this.#e;if(e===null||t===null||n===null)return;this.#_=typeof devicePixelRatio==`number`?devicePixelRatio:1;let r=Math.max(1,Math.round(n.clientWidth*this.#_)),i=Math.max(1,Math.round(n.clientHeight*this.#_));(t.width!==r||t.height!==i)&&(t.width=r,t.height=i,e.viewport(0,0,r,i))}}})),Re={css:async()=>new(await(Promise.resolve().then(()=>(ee(),C)))).CssRenderer,webgl2:async()=>new(await(Promise.resolve().then(()=>(Le(),ke)))).WebglRenderer},ze=!0;function Be(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.mount==`function`}function Ve(e){return e.gpu&&ze?[`webgl2`,`css`]:[`css`]}function He(){return{gpu:Ue()}}function Ue(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)}catch{return!1}}async function X(e=`auto`,t=He()){if(Be(e))return e;let n=Array.isArray(e)?e:e===`auto`?Ve(t):[e];for(let e of n){if(e===`webgl2`&&!t.gpu)continue;let n=Re[e];if(n)return n()}throw n.length===1&&n[0]===`webgl2`&&!t.gpu?Error(`renderer: 'webgl2' was forced but this device has no WebGL2. Use 'css' or 'auto'.`):Error(`renderer: none of [${n.join(`, `)}] could be loaded — use 'css' or 'auto'.`)}function We(e,t){let n=typeof t.frontCover==`string`,r=typeof t.backCover==`string`,i=t.pages!=null&&Object.keys(t.pages).length>0;return!n&&!r&&!i?e:new Ke(e,t)}function Ge(e){return fetch(e).then(t=>{if(!t.ok)throw Error(`zine: could not load image "${e}" (HTTP ${t.status}).`);return t.blob()}).then(e=>createImageBitmap(e))}var Ke=class{#e;#t;#n;#r;#i=new Map;#a=new Map;open;onPageUpdate;constructor(e,t){this.#e=e,this.#t=typeof t.frontCover==`string`?t.frontCover:null,this.#n=typeof t.backCover==`string`?t.backCover:null,this.#r=t.pages??{},typeof e.open==`function`?this.open=async()=>{await e.open(),this.#o()}:this.#o(),typeof e.onPageUpdate==`function`&&(this.onPageUpdate=t=>{e.onPageUpdate(e=>t(e+(this.#t===null?0:1)))})}get pageCount(){return this.#e.pageCount+(this.#t===null?0:1)+(this.#n===null?0:1)}get(e){let t=this.#t===null?0:1;if(this.#t!==null&&e===0)return this.#s(this.#t);if(this.#n!==null&&e===this.pageCount-1)return this.#s(this.#n);let n=e-t,r=this.#i.get(n);return r===void 0?this.#e.get(n):this.#s(r)}prefetch(e){let t=this.#t===null?0:1,n=[];for(let r of e)if(this.#t!==null&&r===0)this.#s(this.#t).catch(()=>{});else if(this.#n!==null&&r===this.pageCount-1)this.#s(this.#n).catch(()=>{});else{let e=r-t,i=this.#i.get(e);i===void 0?n.push(e):this.#s(i).catch(()=>{})}this.#e.prefetch(n)}destroy(){this.#e.destroy();for(let e of this.#a.values())e.then(e=>e.close()).catch(()=>{});this.#a.clear()}#o(){let e=this.#e.pageCount;this.#i.clear();for(let[t,n]of Object.entries(this.#r)){let r=Number(t),i=r<0?e+r:r;Number.isInteger(i)&&i>=0&&i<e&&this.#i.set(i,n)}}#s(e){let t=this.#a.get(e);return t===void 0&&(t=Ge(e).catch(t=>{throw this.#a.delete(e),t}),this.#a.set(e,t)),t}};b();var qe=.25,Je=.0015,Z=6,Ye=250,Xe=1.55,Ze=class{#e;#t;#n=new c;#r=new s(2);#i=new d;#a;#o;#s;#c=1;#l;#u;#d;#f;#p;#m=!1;#h=!1;#g=``;#_;#v=[];#y=0;#b=0;#x={left:null,right:null};#S;#C;#w;#T;#E;#D=null;#O=!1;#k=1;#A=0;#j=0;#M=null;#N=!1;#P=!1;#F=null;#I=null;#L=null;#R=null;#z=null;#B=null;#V=null;#H=null;#U=!1;#W=1;#G=!1;#K=null;#q=null;#J=null;#Y=null;#X=null;#Z;debug={setFlipProgress:(e,t)=>{this.#M?.setFlipProgress(e,t)}};constructor(e,t){tt(e,t),this.#e=e,t.width!==void 0&&(e.style.width=`${t.width}px`),t.height!==void 0&&(e.style.height=`${t.height}px`),this.#t=We(t.source,{frontCover:t.frontCover,backCover:t.backCover,pages:t.pages});let n=t.direction??`ltr`;this.#a=n,this.#o=t.spreadMode??`cover`,this.#s=t.curl??`cone`,this.#l=t.clickToFlip??`edge`,this.#u=t.clickZoneSize??64,this.#p=t.singlePageThreshold??640,this.#_=t.startPage,typeof this.#t.open!=`function`&&this.#He(),this.#S=t.flipDuration??800,this.#C=t.zoom?.enabled??!0,this.#w=t.zoom?.wheel??!0;let r=t.zoom?.doubleClick,i=r===!1?[]:[...r??[1,2,4]].sort((e,t)=>e-t);this.#T=i.length>0?i:null,this.#E=t.zoom?.max??4;let a=this.#C&&this.#T!==null,o=t.zoom?.doubleClickInFlipZone??this.#l===`half`;this.#d=this.#l!==`off`&&a&&o&&t.clickFlipDelay!==0,this.#f=this.#d?t.clickFlipDelay??Ye:0,this.#Z=this.#Se(t.renderer??`auto`)}get ready(){return this.#Z}getPageCount(){return this.#t.pageCount}getPage(){return this.#b}flipNext(){this.#Q(()=>this.#ne(this.#y+1))}flipPrev(){this.#Q(()=>this.#ne(this.#y-1))}flipTo(e){let t=Q(e,0,Math.max(0,this.#t.pageCount-1));this.#Q(()=>this.#ne(this.#Ve(t)))}#Q(e){this.#i.state===`idle`?e():this.#V?(this.#$(),e()):this.#B=e}#$(){let e=this.#V;e&&(this.#V=null,this.#F!==null&&(cancelAnimationFrame(this.#F),this.#F=null),this.#M?.setFlipProgress(e.toT,e.direction),e.onDone())}#ee(){let e=this.#B;e&&(this.#B=null,e())}getZoom(){return this.#k}setZoom(e,t){if(!this.#M||!this.#C)return;let n=Q(e,1,this.#E),r=this.#M.measure(),i=t??{x:r.containerWidth/2,y:r.containerHeight/2},a=this.#k,o=n===1?0:i.x-n/a*(i.x-this.#A),s=n===1?0:i.y-n/a*(i.y-this.#j);[o,s]=this.#te(o,s,n,r.containerWidth,r.containerHeight),this.#k=n,this.#A=o,this.#j=s,this.#M.setViewTransform(n,o,s),this.#n.emit(`zoomChanged`,{scale:n})}resetZoom(){this.setZoom(1)}#te(e,t,n,r,i){return[Q(e,r*(1-n),0),Q(t,i*(1-n),0)]}on(e,t){return this.#n.on(e,t)}destroy(){this.#P=!0,this.#F!==null&&cancelAnimationFrame(this.#F),this.#V=null,this.#B=null,this.#he(),this.#D?.disconnect(),this.#X?.(),this.#J?.(),this.#Y?.(),this.#q?.(),this.#M?.destroy(),this.#M=null,this.#t.destroy(),this.#n.clear()}#ne(e){if(e<0||e>=this.#v.length||e===this.#y||this.#i.send(`flip`)===null)return;let t=e>this.#y?`forward`:`backward`,n=this.#oe(e);this.#n.emit(`flipStart`,{from:this.#b,to:n}),this.#re(e,t,n)}async#re(e,t,n){let r=this.#v[e],i=r?await this.#Re(r):{left:null,right:null};this.#M?.beginFlip(this.#x,i,t,{fill:this.#m,curl:this.#s,anchor:{y:this.#c}}),this.#ie(0,1,t,()=>this.#ae(e,n,i))}#ie(e,t,n,r){let i=this.#ke()*Math.abs(t-e);if(i<=0){this.#M?.setFlipProgress(t,n),r();return}let a={toT:t,direction:n,onDone:r};this.#V=a;let o=performance.now(),s=c=>{if(this.#V!==a)return;let l=Math.min(1,(c-o)/i),u=this.#m?$e(l):Qe(l);this.#M?.setFlipProgress(e+(t-e)*u,n),l<1?this.#F=requestAnimationFrame(s):(this.#F=null,this.#V=null,r())};this.#F=requestAnimationFrame(s)}#ae(e,t,n){let r=this.#v[e];this.#y=e,this.#b=t,this.#x=n,r&&this.#Ne(r,n),this.#Be(),this.#i.send(`settle`),this.#Oe(),this.#n.emit(`pageChanged`,{page:t}),this.#n.emit(`flipEnd`,{page:t}),this.#ee()}#oe(e){let t=this.#v[e];if(!t)return this.#b;let n=[t.left,t.right].filter(e=>e!==null);return n.length>0?Math.min(...n):this.#b}#se(e,t){if(this.#U||!this.#M||this.#i.state!==`idle`)return;if(this.#he(),this.#k>1){if(this.#i.send(`panStart`)===null)return;this.#H={baseTx:this.#A,baseTy:this.#j};return}let n=this.#e.getBoundingClientRect(),r=this.#pe(),i={x:e-n.left-r.x,y:t-n.top-r.y};this.#R=i;let a=Math.min(r.width,r.height)*qe;if(_(i,{width:r.width,height:r.height},a)!==`corner`)return;this.#c=Q(i.y/r.height,0,1);let o=i.x>r.width/2,s=this.#a===`rtl`?!o:o,c=this.#y+(s?1:-1);c<0||c>=this.#v.length||(this.#L={direction:s?`forward`:`backward`,targetIndex:c,toPage:this.#oe(c),width:r.width})}#ce(){let e=this.#L;e&&(this.#L=null,this.#i.send(`grab`)!==null&&(this.#I={direction:e.direction,targetIndex:e.targetIndex,toPage:e.toPage,toContent:{left:null,right:null},width:e.width,t:0},this.#n.emit(`flipStart`,{from:this.#b,to:e.toPage}),this.#le(e.targetIndex,e.direction)))}async#le(e,t){let n=this.#v[e],r=n?await this.#Re(n):{left:null,right:null};this.#I?.targetIndex===e&&(this.#I.toContent=r,this.#M?.beginFlip(this.#x,r,t,{fill:this.#m,curl:this.#s,anchor:{y:this.#c}}),this.#M?.setFlipProgress(this.#I.t,t))}#ue(e,t){if(this.#U)return;if(this.#H){if(!this.#M)return;let n=this.#M.measure(),[r,i]=this.#te(this.#H.baseTx+e,this.#H.baseTy+t,this.#k,n.containerWidth,n.containerHeight);this.#A=r,this.#j=i,this.#M.setViewTransform(this.#k,r,i);return}this.#L&&Math.hypot(e,t)>Z&&this.#ce();let n=this.#I;n&&(n.t=Q((n.direction===`forward`?-e:e)/n.width,0,1),this.#M?.setFlipProgress(n.t,n.direction))}#de(e){if(this.#U)return;if(this.#H){this.#H=null,this.#i.send(`panEnd`);return}let t=this.#I;if(!t){this.#L=null,this.#fe(e);return}this.#I=null,this.#i.send(`release`);let n=e.swipe&&(t.direction===`forward`?e.dx<0:e.dx>0);t.t>=.5||n?this.#ie(t.t,1,t.direction,()=>this.#ae(t.targetIndex,t.toPage,t.toContent)):this.#ie(t.t,0,t.direction,()=>this.#ge())}#fe(e){if(this.#l===`off`||this.#k>1||!this.#R||Math.abs(e.dx)>Z||Math.abs(e.dy)>Z)return;let t=this.#me(this.#R);if(!t)return;let n=t===`forward`?1:-1;if(this.#y+n<0||this.#y+n>=this.#v.length)return;this.#c=Q(this.#R.y/this.#pe().height,0,1);let r=()=>this.#ne(this.#y+n);if(this.#he(),this.#f<=0){this.#Q(r);return}this.#z=setTimeout(()=>{this.#z=null,this.#Q(r)},this.#f)}#pe(){let e=this.#M.measure();return e.content??e.book??{x:0,y:0,width:e.containerWidth,height:e.containerHeight}}#me(e){if(!this.#M)return null;let t=this.#pe().width,n;if(n=this.#l===`half`?e.x>t/2?`right`:`left`:e.x<=this.#u?`left`:e.x>=t-this.#u?`right`:null,!n)return null;let r=this.#a===`rtl`?`left`:`right`;return n===r?`forward`:`backward`}#he(){this.#z!==null&&(clearTimeout(this.#z),this.#z=null)}#ge(){let e=this.#v[this.#y];e&&this.#Ne(e,this.#x),this.#i.send(`settle`),this.#n.emit(`flipEnd`,{page:this.#b}),this.#ee()}#_e(){if(this.#L=null,this.#he(),this.#I){this.#I=null,this.#i.send(`release`),this.#i.send(`settle`);let e=this.#v[this.#y];e&&this.#Ne(e,this.#x)}else this.#H&&(this.#H=null,this.#i.send(`panEnd`));this.#U=!0,this.#W=this.#k}#ve(e,t,n){if(!this.#U)return;let r=this.#e.getBoundingClientRect();this.setZoom(this.#W*n,{x:e-r.left,y:t-r.top})}#ye(){this.#U=!1}#be(){let e=e=>{if(!this.#w||!this.#C||!(e.ctrlKey||e.metaKey))return;e.preventDefault();let t=this.#e.getBoundingClientRect(),n=Math.exp(-e.deltaY*Je);this.setZoom(this.#k*n,{x:e.clientX-t.left,y:e.clientY-t.top})};this.#e.addEventListener(`wheel`,e,{passive:!1}),this.#J=()=>this.#e.removeEventListener(`wheel`,e)}#xe(){let e=e=>{let t=this.#T;if(!this.#C||t===null)return;if(this.#k<=1&&this.#l!==`off`&&!this.#d){let t=this.#e.getBoundingClientRect(),n={x:e.clientX-t.left,y:e.clientY-t.top};if(this.#me(n)!==null)return}this.#he(),e.preventDefault();let n=t.find(e=>e>this.#k+1e-6)??t[0]??this.#k,r=this.#e.getBoundingClientRect();this.setZoom(n,{x:e.clientX-r.left,y:e.clientY-r.top})};this.#e.addEventListener(`dblclick`,e),this.#Y=()=>this.#e.removeEventListener(`dblclick`,e)}async#Se(e){let t=X(e);typeof this.#t.open==`function`&&(await this.#t.open(),this.#He()),this.#t.prefetch([this.#b]);let n=await t,r=await this.#Ce(n);this.#M=r,this.#t.onPageUpdate?.(e=>this.#Fe(e)),this.#je(r.measure().containerWidth);let i=new p({onStart:e=>this.#se(e.x,e.y),onMove:e=>this.#ue(e.dx,e.dy),onEnd:e=>this.#de(e)}),a=new g({onPinchStart:()=>this.#_e(),onPinchMove:e=>this.#ve(e.centerX,e.centerY,e.scale),onPinchEnd:()=>this.#ye()});this.#q=m(this.#e,{pointer:i,pinch:a}),this.#be(),this.#xe(),this.#Te(),this.#X=this.#Ee(),await this.#Me(),this.#Ie(),this.#Be(),this.#Oe(),this.#n.emit(`ready`)}async#Ce(e){try{return await e.mount(this.#e),e.onFatal?.(()=>{this.#we()}),e}catch{e.destroy();let t=await X(`css`);return await t.mount(this.#e),this.#N=!0,this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`}),t}}async#we(){if(this.#N||this.#P)return;this.#N=!0,this.#M?.destroy(),this.#M=null;let e=await X(`css`);if(this.#P){e.destroy();return}await e.mount(this.#e),this.#M=e,this.#je(e.measure().containerWidth),await this.#Me(),this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`})}#Te(){if(typeof matchMedia!=`function`)return;let e=matchMedia(`(prefers-reduced-motion: reduce)`);this.#G=e.matches,e.addEventListener?.(`change`,e=>{this.#G=e.matches})}#Ee(){let e=this.#e,t=e.ownerDocument;if(!t||typeof e.setAttribute!=`function`)return null;e.hasAttribute(`tabindex`)||(e.tabIndex=0),e.setAttribute(`aria-roledescription`,`flipbook`);let n=e=>this.#De(e);e.addEventListener(`keydown`,n);let r=t.createElement(`div`);return r.setAttribute(`aria-live`,`polite`),r.setAttribute(`aria-atomic`,`true`),r.style.cssText=`position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;`,e.appendChild(r),this.#K=r,()=>{e.removeEventListener(`keydown`,n),r.remove(),this.#K=null}}#De(e){let t=this.#a===`rtl`?`ArrowLeft`:`ArrowRight`;switch(e.key){case`ArrowRight`:case`ArrowLeft`:e.key===t?this.flipNext():this.flipPrev(),e.preventDefault();break;case`Home`:this.flipTo(0),e.preventDefault();break;case`End`:this.flipTo(this.#t.pageCount-1),e.preventDefault();break;default:break}}#Oe(){this.#K&&(this.#K.textContent=`Page ${this.#b+1} of ${this.#t.pageCount}`)}#ke(){return this.#G?0:this.#S*(this.#m?Xe:1)}update(){!this.#M||this.#i.state!==`idle`||(this.#je(this.#M.measure().containerWidth),this.#Me())}#Ae(){return this.#h||this.#o===`single`?`single`:this.#o}#je(e){let t=a(e,this.#p);if(t===this.#h)return;this.#h=t;let n=this.#Ae();this.#m=n===`single`,this.#v=i(this.#t.pageCount,{direction:this.#a,mode:n}),this.#y=this.#Ve(this.#b)}async#Me(){let e=this.#v[this.#y];!e||!this.#M||(this.#x=await this.#Re(e),this.#Ne(e,this.#x))}#Ne(e,t){this.#M?.renderSpread(e,t,{fill:this.#m}),this.#Pe()}#Pe(){let e=this.#M?.measure().book;if(!e||e.width<=0||e.height<=0)return;let t=(e.width/e.height).toFixed(4);t!==this.#g&&(this.#g=t,this.#e.style.aspectRatio=t)}#Fe(e){if(this.#i.state!==`idle`)return;let t=this.#v[this.#y];t&&(t.left===e||t.right===e)&&this.#Me()}#Ie(){typeof ResizeObserver>`u`||(this.#D=new ResizeObserver(()=>this.#Le()),this.#D.observe(this.#e))}#Le(){this.#O||(this.#O=!0,requestAnimationFrame(()=>{this.#O=!1,this.update()}))}async#Re(e){let[t,n]=await Promise.all([this.#ze(e.left),this.#ze(e.right)]);return{left:t,right:n}}async#ze(e){if(e===null)return null;try{return await this.#t.get(e)}catch(t){return this.#n.emit(`sourceError`,{index:e,error:t}),null}}#Be(){let{toMount:e}=this.#r.update(this.#y,this.#v.length),t=[];for(let n of e){let e=this.#v[n];e?.left!=null&&t.push(e.left),e?.right!=null&&t.push(e.right)}this.#t.prefetch(t)}#Ve(e){let t=this.#v.findIndex(t=>t.left===e||t.right===e);return t===-1?0:t}#He(){let e=this.#t.pageCount;if(!Number.isInteger(e)||e<1)throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);let t=this.#_;if(t!==void 0&&(!Number.isInteger(t)||t<0||t>=e))throw Error(`Zine: startPage ${JSON.stringify(t)} is out of range for a ${e}-page book (valid 0..${e-1}).`);let n=this.#Ae();this.#m=n===`single`,this.#v=i(e,{direction:this.#a,mode:n}),this.#b=Q(t??0,0,e-1),this.#y=this.#Ve(this.#b)}};function Q(e,t,n){return e<t?t:e>n?n:e}function Qe(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function $e(e){return 1-(1-Qe(e))**1.3}function et(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function tt(e,t){if(typeof e!=`object`||!e||typeof e.appendChild!=`function`||typeof e.addEventListener!=`function`)throw Error(`Zine: container must be a DOM element; received ${et(e)}.`);if(typeof t!=`object`||!t)throw Error("Zine: an options object with a `source` is required.");let n=t,r=n.source;if(typeof r!=`object`||!r||typeof r.get!=`function`||typeof r.pageCount!=`number`)throw Error("Zine: `source` is required and must be a Source, e.g. new ImageSource(urls).");let i=n.startPage;if(i!==void 0&&(typeof i!=`number`||!Number.isInteger(i)||i<0))throw Error(`Zine: startPage must be a non-negative integer; got ${JSON.stringify(i)}.`);let a=n.direction;if(a!==void 0&&a!==`ltr`&&a!==`rtl`)throw Error(`Zine: direction must be 'ltr' or 'rtl'; got ${JSON.stringify(a)}.`);let o=n.clickToFlip;if(o!==void 0&&![`edge`,`half`,`off`].includes(o))throw Error(`Zine: clickToFlip must be 'edge', 'half', or 'off'; got ${JSON.stringify(o)}.`);let s=n.curl;if(s!==void 0&&!v.includes(s))throw Error(`Zine: curl must be one of ${v.join(`, `)}; got ${JSON.stringify(s)}.`);let c=n.spreadMode;if(c!==void 0&&![`double`,`single`,`cover`,`book`].includes(c))throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(c)}.`);for(let e of[`frontCover`,`backCover`]){let t=n[e];if(t!==void 0&&typeof t!=`string`)throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`)}let l=n.pages;if(l!==void 0&&(typeof l!=`object`||!l||Array.isArray(l)))throw Error(`Zine: pages must be an object mapping page indices to image URLs.`);$(n.width,`width`,1),$(n.height,`height`,1),$(n.flipDuration,`flipDuration`,0),$(n.clickZoneSize,`clickZoneSize`,0),$(n.clickFlipDelay,`clickFlipDelay`,0),$(n.singlePageThreshold,`singlePageThreshold`,0),nt(n.zoom),rt(n.renderer)}function $(e,t,n){if(e!==void 0&&(typeof e!=`number`||!Number.isFinite(e)||e<n))throw Error(`Zine: ${t} must be a number >= ${n}; got ${JSON.stringify(e)}.`)}function nt(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Zine: zoom must be an object, e.g. { max: 4 }.`);let t=e;if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)throw Error(`Zine: zoom.enabled must be a boolean; got ${JSON.stringify(t.enabled)}.`);if(t.wheel!==void 0&&typeof t.wheel!=`boolean`)throw Error(`Zine: zoom.wheel must be a boolean; got ${JSON.stringify(t.wheel)}.`);if(t.doubleClickInFlipZone!==void 0&&typeof t.doubleClickInFlipZone!=`boolean`)throw Error(`Zine: zoom.doubleClickInFlipZone must be a boolean; got ${JSON.stringify(t.doubleClickInFlipZone)}.`);if(t.doubleClick!==void 0&&t.doubleClick!==!1){let e=t.doubleClick;if(!Array.isArray(e)||e.some(e=>typeof e!=`number`||!Number.isFinite(e)||e<1))throw Error(`Zine: zoom.doubleClick must be false or an array of zoom levels >= 1, e.g. [1, 2, 4].`)}$(t.max,`zoom.max`,1)}function rt(e){if(e!==void 0){if(typeof e==`string`){if(e!==`auto`&&e!==`css`&&e!==`webgl2`)throw Error(`Zine: renderer '${e}' is not recognized; use 'auto', 'css', 'webgl2', an array of those, or a custom Renderer.`);return}if(Array.isArray(e)){for(let t of e)if(t!==`css`&&t!==`webgl2`)throw Error(`Zine: renderer order array may only contain 'css' or 'webgl2'; got ${JSON.stringify(t)}.`);return}if(!(typeof e==`object`&&e&&typeof e.mount==`function`))throw Error(`Zine: renderer must be 'auto', 'css', 'webgl2', an array of those, or a custom Renderer instance.`)}}var it=class{pageCount;fit;#e;#t;#n=new Map;constructor(e,t={}){this.#e=e,this.pageCount=e.length,this.#t=t.preload??1,this.fit=t.fit??`contain`}get(e){let t=this.#r(e);for(let t=1;t<=this.#t;t++)this.prefetch([e-t,e+t]);return t}prefetch(e){for(let t of e)t>=0&&t<this.pageCount&&this.#r(t).catch(()=>{})}destroy(){for(let e of this.#n.values())e.then(e=>e.close()).catch(()=>{});this.#n.clear()}#r(e){let t=this.#n.get(e);if(t)return t;let n=this.#e[e];if(n===void 0)return Promise.reject(RangeError(`ImageSource: page ${e} is out of range (0..${this.pageCount-1}).`));let r=(async()=>{let t=await fetch(n);if(!t.ok)throw Error(`ImageSource: failed to fetch page ${e} (${n}) — HTTP ${t.status}.`);return createImageBitmap(await t.blob())})().catch(t=>{throw this.#n.delete(e),t});return this.#n.set(e,r),r}};b(),e.CURL_TYPES=v,e.ImageSource=it,e.Zine=Ze});
90
+ }`,P=28,F=36,$e=.7,et=.8,tt=4e3,nt=256*1024*1024,rt=class{#e=null;#t=null;#n=null;#r=null;#i=null;#a=null;#o=null;#s=null;#c=null;#l=0;#u=se(P,F);#d=new Map;#f=0;#p=null;#m={};#h={};#g={scale:1,tx:0,ty:0};#_=1;#v=null;#y=!1;#b=null;#x=0;#S=E;#C={y:.5};#w=0;#T=0;#E=0;#D=0;#O=0;#k=0;#A=!1;#j=!1;#M=null;#N=null;mount(e){this.#e=e;let t=e.ownerDocument,n=t.createElement(`canvas`);return n.style.cssText=`display:block;width:100%;height:100%;`,e.append(n),this.#t=n,n.addEventListener(`webglcontextlost`,this.#L),n.addEventListener(`webglcontextrestored`,this.#R),t.addEventListener(`visibilitychange`,this.#z),this.#n=Be(n),this.#H(),Promise.resolve()}destroy(){this.#V();let e=this.#t;e!==null&&(e.removeEventListener(`webglcontextlost`,this.#L),e.removeEventListener(`webglcontextrestored`,this.#R),e.ownerDocument.removeEventListener(`visibilitychange`,this.#z));let t=this.#n;if(t!==null){for(let e of this.#d.values())t.deleteTexture(e.tex);this.#p!==null&&t.deleteTexture(this.#p),this.#a!==null&&t.deleteVertexArray(this.#a),this.#o!==null&&t.deleteVertexArray(this.#o),this.#r!==null&&t.deleteProgram(this.#r),this.#i!==null&&t.deleteProgram(this.#i),t.getExtension(`WEBGL_lose_context`)?.loseContext()}e?.remove(),this.#d.clear(),this.#f=0,this.#p=null,this.#e=null,this.#t=null,this.#n=null,this.#v=null,this.#b=null}onFatal(e){this.#N=e}renderSpread(e,t,n){this.#v=t,this.#y=n?.fill??!1,this.#b=null,this.#P(t),this.#G()}#P(e){let t=e.left??e.right;t&&t.height&&(this.#D=t.width/t.height)}beginFlip(e,t,n,r){let i=r?.fill??!1;this.#x=0,r?.curl&&(this.#S=r.curl),r?.anchor&&(this.#C=r.anchor),this.#T=i?0:N(e),this.#E=i?0:N(t),this.#P(t),i?this.#b={underLeft:null,underRight:null,underFull:t.right??t.left,front:e.right??e.left,back:e.right??e.left,dir:n===`forward`?1:-1,fill:!0}:n===`forward`?this.#b={underLeft:e.left,underRight:t.right,underFull:null,front:e.right,back:t.left,dir:1,fill:!1}:this.#b={underLeft:t.left,underRight:e.right,underFull:null,front:e.left,back:t.right,dir:-1,fill:!1},this.#G()}setFlipProgress(e,t){this.#x=e,this.#G()}setViewTransform(e,t,n){this.#g={scale:e,tx:t,ty:n},this.#G()}measure(){let e=this.#e,t=e?.clientWidth??0,n=e?.clientHeight??0,r=this.#D>0,i=r?this.#F():void 0,a=r?this.#I():void 0;return{containerWidth:t,containerHeight:n,pageWidth:t/2,pageHeight:n,book:i,content:a}}#F(){let e=this.#e,t=e?.clientWidth??0,n=e?.clientHeight??0;if(this.#D<=0||t<=0||n<=0)return{x:0,y:0,width:t,height:n};let r=(this.#y?1:2)*this.#D,i=t,a=n;return r>t/n?a=t/r:i=n*r,{x:(t-i)/2,y:(n-a)/2,width:i,height:a}}#I(){let e=this.#F();return!this.#y&&this.#v!==null&&N(this.#v)!==0?{x:e.x+e.width/4,y:e.y,width:e.width/2,height:e.height}:e}#L=e=>{e.preventDefault(),this.#A=!0,this.#M===null&&(this.#M=setTimeout(()=>this.#B(),tt))};#R=()=>{this.#V(),this.#A=!1,this.#H(),this.#G()};#z=()=>{this.#t?.ownerDocument.visibilityState===`visible`&&this.#G()};#B(){this.#j||(this.#j=!0,this.#N?.())}#V(){this.#M!==null&&(clearTimeout(this.#M),this.#M=null)}#H(){let e=this.#n;if(e!==null){this.#r=He(e,Ye,Xe),this.#i=He(e,Ze,Qe);for(let t of[`uViewport`,`uRect`,`uView`,`uTex`,`uGutterSide`])this.#m[t]=e.getUniformLocation(this.#r,t);for(let t of[`uViewport`,`uView`,`uOriginX`,`uDir`,`uLeafW`,`uFront`,`uBack`,`uGloss`,`uAlpha`])this.#h[t]=e.getUniformLocation(this.#i,t);this.#a=this.#U(e,this.#r),this.#W(e,this.#i),this.#d.clear(),this.#f=0,this.#p=this.#te(e),e.useProgram(this.#r),e.uniform1i(this.#m.uTex??null,0),e.useProgram(this.#i),e.uniform1i(this.#h.uFront??null,0),e.uniform1i(this.#h.uBack??null,1),e.clearColor(0,0,0,0),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}}#U(e,t){let n=e.createVertexArray(),r=e.createBuffer();if(n===null||r===null)throw Error(`WebglRenderer: could not create buffers.`);e.bindVertexArray(n),e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW);let i=e.getAttribLocation(t,`aUnit`);return e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),n}#W(e,t){let n=[];for(let e=0;e<F;e++)for(let t=0;t<P;t++){let r=e*29+t,i=r+1,a=r+29,o=a+1;n.push(r,a,i,i,a,o)}this.#l=n.length;let r=e.createVertexArray();this.#s=e.createBuffer(),this.#c=e.createBuffer();let i=e.createBuffer(),a=e.createBuffer();if(r===null||this.#s===null||this.#c===null||i===null||a===null)throw Error(`WebglRenderer: could not create mesh buffers.`);e.bindVertexArray(r),e.bindBuffer(e.ARRAY_BUFFER,this.#s),e.bufferData(e.ARRAY_BUFFER,this.#u.positions,e.DYNAMIC_DRAW);let o=e.getAttribLocation(t,`aPos`);e.enableVertexAttribArray(o),e.vertexAttribPointer(o,3,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#c),e.bufferData(e.ARRAY_BUFFER,this.#u.normals,e.DYNAMIC_DRAW);let s=e.getAttribLocation(t,`aNormal`);e.enableVertexAttribArray(s),e.vertexAttribPointer(s,3,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,this.#u.uvs,e.STATIC_DRAW);let c=e.getAttribLocation(t,`aUv`);e.enableVertexAttribArray(c),e.vertexAttribPointer(c,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(n),e.STATIC_DRAW),e.bindVertexArray(null),this.#o=r}#G(){let e=this.#n,t=this.#t;e===null||t===null||this.#A||e.isContextLost()||(this.#ne(),e.clear(e.COLOR_BUFFER_BIT),this.#K(),this.#b===null?this.#v!==null&&this.#q():this.#J())}#K(){let e=this.#n,t=this.#t,n=t.width,r=t.height;if(this.#D>0){let e=(this.#y?1:2)*this.#D;e>n/r?(this.#O=n,this.#k=Math.round(n/e)):(this.#k=r,this.#O=Math.round(r*e))}else this.#O=n,this.#k=r;let i=Math.round((n-this.#O)/2),a=Math.round((r-this.#k)/2);e.viewport(i,a,this.#O,this.#k)}#q(){let e=this.#O,t=this.#k,n=this.#v;this.#w=this.#y?0:N(n)*(e/4),this.#X(),this.#y?this.#Z({x:0,y:0,w:e,h:t},n.right??n.left):(this.#Z({x:0,y:0,w:e/2,h:t},n.left,+!!n.right),this.#Z({x:e/2,y:0,w:e/2,h:t},n.right,n.left?-1:0))}#J(){let e=this.#n,t=this.#O,n=this.#k,r=this.#b;if(this.#w=r.fill?0:(this.#T+(this.#E-this.#T)*this.#x)*(t/4),this.#X(),r.fill?this.#Z({x:0,y:0,w:t,h:n},r.underFull):(this.#Z({x:0,y:0,w:t/2,h:n},r.underLeft,1),this.#Z({x:t/2,y:0,w:t/2,h:n},r.underRight,-1)),r.front===null&&r.back===null)return;let i=r.fill?t:t/2,a=r.fill?r.dir>0?0:t:t/2;Re[this.#S].deform(this.#u,i,n,this.#x,{y:this.#C.y,fill:r.fill}),e.bindBuffer(e.ARRAY_BUFFER,this.#s),e.bufferSubData(e.ARRAY_BUFFER,0,this.#u.positions),e.bindBuffer(e.ARRAY_BUFFER,this.#c),e.bufferSubData(e.ARRAY_BUFFER,0,this.#u.normals),this.#Q(e.TEXTURE0,r.front),this.#Q(e.TEXTURE1,r.back),e.activeTexture(e.TEXTURE0),e.useProgram(this.#i),e.bindVertexArray(this.#o),e.uniform2f(this.#h.uViewport??null,t,n),e.uniform3f(this.#h.uView??null,this.#g.scale,this.#g.tx*this.#_+this.#w,this.#g.ty*this.#_),e.uniform1f(this.#h.uOriginX??null,a),e.uniform1f(this.#h.uDir??null,r.dir),e.uniform1f(this.#h.uLeafW??null,i),e.uniform1f(this.#h.uGloss??null,this.#S===`simple`?0:1),e.uniform1f(this.#h.uAlpha??null,r.fill?this.#Y():1),e.drawElements(e.TRIANGLES,this.#l,e.UNSIGNED_SHORT,0)}#Y(){let e=this.#S===`roll`||this.#S===`simple`?$e:et,t=(this.#x-e)/(1-e);return t<=0?1:t>=1?0:(1-t)**1.5}#X(){let e=this.#n;e.useProgram(this.#r),e.bindVertexArray(this.#a),e.activeTexture(e.TEXTURE0),e.uniform2f(this.#m.uViewport??null,this.#O,this.#k),e.uniform3f(this.#m.uView??null,this.#g.scale,this.#g.tx*this.#_+this.#w,this.#g.ty*this.#_)}#Z(e,t,n=0){let r=this.#n;t!==null&&(this.#Q(r.TEXTURE0,t),r.uniform4f(this.#m.uRect??null,e.x,e.y,e.w,e.h),r.uniform1f(this.#m.uGutterSide??null,n),r.drawArrays(r.TRIANGLE_STRIP,0,4))}#Q(e,t){let n=this.#n;n.activeTexture(e),n.bindTexture(n.TEXTURE_2D,t===null?this.#p:this.#$(t))}#$(e){let t=this.#n,n=this.#d.get(e);if(n!==void 0)return this.#d.delete(e),this.#d.set(e,n),n.tex;let r=Ge(t);Ke(t,r,e);let i=e,a=i.width*i.height*4;return this.#d.set(e,{tex:r,bytes:a}),this.#f+=a,this.#ee(),r}#ee(){let e=this.#n;for(let[t,n]of this.#d){if(this.#f<=nt||this.#d.size<=4)break;this.#d.delete(t),this.#f-=n.bytes,e.deleteTexture(n.tex)}}#te(e){let t=Ge(e);return e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,0])),t}#ne(){let e=this.#n,t=this.#t,n=this.#e;if(e===null||t===null||n===null)return;this.#_=typeof devicePixelRatio==`number`?devicePixelRatio:1;let r=Math.max(1,Math.round(n.clientWidth*this.#_)),i=Math.max(1,Math.round(n.clientHeight*this.#_));(t.width!==r||t.height!==i)&&(t.width=r,t.height=i,e.viewport(0,0,r,i))}}})),at={css:async()=>new(await(Promise.resolve().then(()=>(oe(),ne)))).CssRenderer,webgl2:async()=>new(await(Promise.resolve().then(()=>(it(),Je)))).WebglRenderer},ot=!0;function st(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.mount==`function`}function ct(e){return e.gpu&&ot?[`webgl2`,`css`]:[`css`]}function lt(){return{gpu:ut()}}function ut(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)}catch{return!1}}async function dt(e=`auto`,t=lt()){if(st(e))return e;let n=Array.isArray(e)?e:e===`auto`?ct(t):[e];for(let e of n){if(e===`webgl2`&&!t.gpu)continue;let n=at[e];if(n)return n()}throw n.length===1&&n[0]===`webgl2`&&!t.gpu?Error(`renderer: 'webgl2' was forced but this device has no WebGL2. Use 'css' or 'auto'.`):Error(`renderer: none of [${n.join(`, `)}] could be loaded — use 'css' or 'auto'.`)}function ft(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i<=n||a<=r?null:{x:n,y:r,width:i-n,height:a-r}}function pt(e,t,n){let{scale:r,tx:i,ty:a}=t;if(r<=1)return[];let o={x:(n.x-i)/r,y:(n.y-a)/r,width:n.width/r,height:n.height/r},s=[];for(let t of e){let e=ft(t.rect,o);!e||t.rect.width<=0||t.rect.height<=0||s.push({index:t.index,request:{scale:r,region:{x:(e.x-t.rect.x)/t.rect.width,y:(e.y-t.rect.y)/t.rect.height,width:e.width/t.rect.width,height:e.height/t.rect.height}},dest:e})}return s}function mt(e,t){if(e.index!==t.index||e.request.scale!==t.request.scale)return!1;let n=e.request.region,r=t.request.region,i=1e-4;return Math.abs(n.x-r.x)<i&&Math.abs(n.y-r.y)<i&&Math.abs(n.width-r.width)<i&&Math.abs(n.height-r.height)<i}var ht=class{#e;#t;#n=[];constructor(e,t){this.#e=e.createElement(`canvas`),this.#e.className=`zine-zoom-overlay`,this.#e.style.cssText=`position:absolute;inset:0;pointer-events:none;opacity:0;transition:opacity 120ms linear;`,t.append(this.#e),this.#t=this.#e.getContext(`2d`)}clear(){if(this.#n.length===0)return;this.#n=[],this.#e.style.opacity=`0`;let e=this.#t;e&&e.clearRect(0,0,this.#e.width,this.#e.height)}get shown(){return this.#n}draw(e,t,n){let r=this.#t;if(!r)return;if(e.length===0){this.clear();return}let i=typeof devicePixelRatio==`number`?devicePixelRatio:1,a=Math.max(1,Math.ceil(n.width*i)),o=Math.max(1,Math.ceil(n.height*i));(this.#e.width!==a||this.#e.height!==o)&&(this.#e.width=a,this.#e.height=o),r.setTransform(i,0,0,i,0,0),r.clearRect(0,0,n.width,n.height),r.translate(t.tx,t.ty),r.scale(t.scale,t.scale);for(let{plan:t,content:n}of e){let e=t.dest;r.drawImage(n,e.x,e.y,e.width,e.height)}this.#n=e.map(e=>e.plan),this.#e.style.opacity=`1`}destroy(){this.#e.remove(),this.#t=null}};function gt(e,t){let n=typeof t.frontCover==`string`,r=typeof t.backCover==`string`,i=t.pages!=null&&Object.keys(t.pages).length>0;return!n&&!r&&!i?e:new vt(e,t)}function _t(e){return fetch(e).then(t=>{if(!t.ok)throw Error(`zine: could not load image "${e}" (HTTP ${t.status}).`);return t.blob()}).then(e=>createImageBitmap(e))}var vt=class{#e;#t;#n;#r;#i=new Map;#a=new Map;open;onPageUpdate;getText;getDownload;getOutline;constructor(e,t){this.#e=e,this.#t=typeof t.frontCover==`string`?t.frontCover:null,this.#n=typeof t.backCover==`string`?t.backCover:null,this.#r=t.pages??{},typeof e.open==`function`?this.open=async()=>{await e.open(),this.#o()}:this.#o(),typeof e.onPageUpdate==`function`&&(this.onPageUpdate=t=>{e.onPageUpdate(e=>t(e+(this.#t===null?0:1)))}),typeof e.getText==`function`&&(this.getText=async t=>{let n=this.#t===null?0:1;if(this.#t!==null&&t===0||this.#n!==null&&t===this.pageCount-1)return``;let r=t-n;return this.#i.has(r)?``:e.getText(r)}),typeof e.getDownload==`function`&&(this.getDownload=()=>e.getDownload()),typeof e.getOutline==`function`&&(this.getOutline=async()=>{let t=await e.getOutline(),n=this.#t===null?0:1;if(n===0)return t;let r=e=>e.map(e=>({...e,page:e.page===null?null:e.page+n,children:r(e.children)}));return r(t)})}get pageCount(){return this.#e.pageCount+(this.#t===null?0:1)+(this.#n===null?0:1)}get(e,t){let n=this.#t===null?0:1;if(this.#t!==null&&e===0)return this.#s(this.#t);if(this.#n!==null&&e===this.pageCount-1)return this.#s(this.#n);let r=e-n,i=this.#i.get(r);return i===void 0?this.#e.get(r,t):this.#s(i)}prefetch(e){let t=this.#t===null?0:1,n=[];for(let r of e)if(this.#t!==null&&r===0)this.#s(this.#t).catch(()=>{});else if(this.#n!==null&&r===this.pageCount-1)this.#s(this.#n).catch(()=>{});else{let e=r-t,i=this.#i.get(e);i===void 0?n.push(e):this.#s(i).catch(()=>{})}this.#e.prefetch(n)}destroy(){this.#e.destroy();for(let e of this.#a.values())e.then(e=>e.close()).catch(()=>{});this.#a.clear()}#o(){let e=this.#e.pageCount;this.#i.clear();for(let[t,n]of Object.entries(this.#r)){let r=Number(t),i=r<0?e+r:r;Number.isInteger(i)&&i>=0&&i<e&&this.#i.set(i,n)}}#s(e){let t=this.#a.get(e);return t===void 0&&(t=_t(e).catch(t=>{throw this.#a.delete(e),t}),this.#a.set(e,t)),t}};function I(e,t){let n=e.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`1.75`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`),n.innerHTML=t,n}var L,R=n((()=>{L={prev:`<path d="m15 18-6-6 6-6"/>`,next:`<path d="m9 18 6-6-6-6"/>`,first:`<path d="m11 17-5-5 5-5"/><path d="m18 17-5-5 5-5"/>`,last:`<path d="m6 17 5-5-5-5"/><path d="m13 17 5-5-5-5"/>`,zoomIn:`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M11 8v6"/><path d="M8 11h6"/>`,zoomOut:`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M8 11h6"/>`,search:`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>`,share:`<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><path d="m8.6 13.5 6.8 4"/><path d="m15.4 6.5-6.8 4"/>`,menu:`<circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/>`,fullscreen:`<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>`,exitFullscreen:`<path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/>`,thumbnails:`<path d="M7 2h10"/><path d="M5 6h14"/><rect width="18" height="12" x="3" y="10" rx="2"/>`,outline:`<path d="M21 12h-8"/><path d="M21 6h-8"/><path d="M21 18h-8"/><path d="M3 6v4c0 1.1.9 2 2 2h3"/><path d="M3 10v6c0 1.1.9 2 2 2h3"/>`,twoPages:`<path d="M12 7v14"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"/>`,onePage:`<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v5h6"/>`,print:`<path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect width="12" height="8" x="6" y="14" rx="1"/>`,download:`<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="M7 10l5 5 5-5"/><path d="M12 15V3"/>`,close:`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`}}));function z(e){return B.set(e.id,e),e}function yt(e){return B.get(e)}function bt(e){if(typeof e==`string`){let t=B.get(e);if(!t)throw Error(`controls: unknown control '${e}'. Register it with defineControl() or pass a definition object.`);return t}let t=B.get(e.id);return t?{...t,...e}:e}var B,V,H=n((()=>{B=new Map,V=[`prev`,`pageInput`,`next`,`|`,`zoomOut`,`zoomIn`,`search`,`share`,`menu`,`fullscreen`]})),U,xt,St=n((()=>{U=encodeURIComponent,xt=[{id:`facebook`,label:`Facebook`,icon:`<path fill="currentColor" stroke="none" d="M22 12a10 10 0 1 0-11.56 9.88v-6.99H7.9V12h2.54V9.8c0-2.5 1.49-3.89 3.77-3.89 1.1 0 2.24.2 2.24.2v2.46h-1.26c-1.24 0-1.63.77-1.63 1.56V12h2.78l-.45 2.89h-2.33v6.99A10 10 0 0 0 22 12Z"/>`,href:e=>`https://www.facebook.com/sharer/sharer.php?u=${U(e)}`},{id:`x`,label:`X (Twitter)`,icon:`<path fill="currentColor" stroke="none" d="M17.53 3h3.06l-6.69 7.64L21.75 21h-6.16l-4.82-6.3L5.24 21H2.18l7.15-8.17L2.25 3h6.32l4.36 5.77L17.53 3Zm-1.07 16.17h1.69L7.62 4.73H5.8l10.66 14.44Z"/>`,href:(e,t)=>`https://twitter.com/intent/tweet?url=${U(e)}&text=${U(t)}`},{id:`linkedin`,label:`LinkedIn`,icon:`<path fill="currentColor" stroke="none" d="M20.45 20.45h-3.56v-5.57c0-1.33-.02-3.04-1.85-3.04-1.85 0-2.14 1.45-2.14 2.94v5.67H9.35V9h3.41v1.56h.05a3.74 3.74 0 0 1 3.37-1.85c3.6 0 4.27 2.37 4.27 5.46v6.28ZM5.34 7.43a2.07 2.07 0 1 1 0-4.13 2.07 2.07 0 0 1 0 4.13Zm1.78 13.02H3.55V9h3.57v11.45ZM22.22 0H1.77C.79 0 0 .77 0 1.72v20.56C0 23.23.79 24 1.77 24h20.45c.98 0 1.78-.77 1.78-1.72V1.72C24 .77 23.2 0 22.22 0Z"/>`,href:e=>`https://www.linkedin.com/sharing/share-offsite/?url=${U(e)}`},{id:`whatsapp`,label:`WhatsApp`,icon:`<path fill="currentColor" stroke="none" d="M12.04 2a9.9 9.9 0 0 0-8.5 14.9L2 22l5.25-1.38A9.9 9.9 0 1 0 12.04 2Zm5.8 14.06c-.25.7-1.44 1.33-1.99 1.38-.53.05-1.02.24-3.44-.72-2.9-1.14-4.73-4.1-4.87-4.29-.14-.19-1.16-1.54-1.16-2.94s.73-2.08 1-2.37c.26-.28.57-.35.76-.35h.55c.17 0 .42-.07.65.5.24.58.8 2 .87 2.14.07.14.12.31.02.5-.09.19-.14.3-.28.47l-.42.48c-.14.14-.28.29-.12.57.16.28.7 1.16 1.51 1.88 1.04.93 1.91 1.21 2.19 1.35.28.15.44.12.6-.07.17-.19.7-.81.88-1.09.19-.28.37-.23.63-.14.25.1 1.63.77 1.9.91.29.14.48.21.55.33.07.11.07.67-.18 1.37Z"/>`,href:(e,t)=>`https://api.whatsapp.com/send?text=${U(`${t} ${e}`)}`},{id:`pinterest`,label:`Pinterest`,icon:`<path fill="currentColor" stroke="none" d="M12 2a10 10 0 0 0-3.65 19.31c-.09-.78-.17-1.98.03-2.83.19-.78 1.2-4.98 1.2-4.98s-.3-.61-.3-1.52c0-1.42.82-2.48 1.85-2.48.87 0 1.3.66 1.3 1.44 0 .88-.56 2.2-.85 3.42-.24 1.02.51 1.86 1.52 1.86 1.83 0 3.23-1.93 3.23-4.7 0-2.46-1.77-4.18-4.29-4.18-2.92 0-4.64 2.19-4.64 4.46 0 .88.34 1.83.76 2.35a.3.3 0 0 1 .07.29l-.28 1.16c-.05.19-.15.23-.34.14-1.28-.6-2.08-2.47-2.08-3.98 0-3.24 2.35-6.21 6.79-6.21 3.56 0 6.33 2.54 6.33 5.93 0 3.54-2.23 6.39-5.32 6.39-1.04 0-2.02-.54-2.35-1.18l-.64 2.44c-.23.89-.86 2.01-1.28 2.69A10 10 0 1 0 12 2Z"/>`,href:(e,t)=>`https://pinterest.com/pin/create/button/?url=${U(e)}&description=${U(t)}`},{id:`email`,label:`Email`,icon:`<path fill="currentColor" stroke="none" d="M20 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2Zm0 4.24-7.47 4.67a1 1 0 0 1-1.06 0L4 8.24V6.4l8 5 8-5v1.84Z"/>`,href:(e,t)=>`mailto:?subject=${U(t)}&body=${U(e)}`}]}));function Ct(e){let t=new Uint8Array([1]);for(let n=0;n<e;n++){let e=new Uint8Array(t.length+1);for(let r=0;r<t.length;r++)e[r]=e[r]^t[r],e[r+1]=e[r+1]^Y(t[r],q[n]);t=e}return t}function wt(e,t){let n=Ct(t),r=new Uint8Array(t);for(let i of e){let e=i^r[0];if(r.copyWithin(0,1),r[t-1]=0,e!==0)for(let i=0;i<t;i++)r[i]=r[i]^Y(n[i+1],e)}return r}function Tt(e){let t=0|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;return(t<<10|n)^21522}function W(e,t,n){for(let r=-1;r<=7;r++)for(let i=-1;i<=7;i++){let a=t+i,o=n+r;if(a<0||o<0||a>=e.size||o>=e.size)continue;let s=Math.max(Math.abs(i-3),Math.abs(r-3));X(e,a,o,s!==2&&s<=3)}}function Et(e){let t=new TextEncoder().encode(e),n=G.findIndex(e=>t.length+2<=e)+1;if(n===0)throw Error(`qr: ${t.length} bytes is too long for this encoder (max 214).`);let r=G[n-1],i=[],a=(e,t)=>{for(let n=t-1;n>=0;n--)i.push(e>>>n&1)};a(4,4),a(t.length,n<10?8:16);for(let e of t)a(e,8);for(a(0,Math.min(4,r*8-i.length));i.length%8;)i.push(0);let o=new Uint8Array(r);for(let e=0;e<i.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|i[e+n];o[e/8]=t}for(let e=i.length/8,t=0;e<r;e++,t++)o[e]=t%2==0?236:17;let s=kt[n-1],c=Ot[n-1],l=Math.floor(r/s),u=r%s,d=[],f=[];for(let e=0,t=0;e<s;e++){let n=l+ +(e>=s-u),r=o.subarray(t,t+n);t+=n,d.push(r),f.push(wt(r,c))}let p=[];for(let e=0;e<l+1;e++)for(let t of d)e<t.length&&p.push(t[e]);for(let e=0;e<c;e++)for(let t of f)p.push(t[e]);let m=n*4+17,h={size:m,modules:new Uint8Array(m*m),reserved:new Uint8Array(m*m)};W(h,0,0),W(h,m-7,0),W(h,0,m-7);for(let e=8;e<m-8;e++){let t=e%2==0;X(h,e,6,t),X(h,6,e,t)}for(let e of K[n-1])for(let t of K[n-1])if(!(e<9&&t<9||e<9&&t>m-10||e>m-10&&t<9))for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)X(h,e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1);X(h,8,m-8,!0);for(let e=0;e<9;e++)e!==6&&(X(h,e,8,!1),X(h,8,e,!1));for(let e=0;e<8;e++)X(h,m-1-e,8,!1),X(h,8,m-1-e,!1);X(h,8,m-8,!0);let g=0,_=p.length*8;for(let e=m-1;e>=1;e-=2){e===6&&(e=5);for(let t=0;t<m;t++)for(let n=0;n<2;n++){let r=e-n,i=e+1&2?t:m-1-t;if(h.reserved[i*m+r])continue;let a=!1;g<_&&(a=(p[g>>>3]>>>7-(g&7)&1)==1,g++),(r+i)%2==0&&(a=!a),X(h,r,i,a,!1)}}let v=Tt(0);for(let e=0;e<15;e++){let t=(v>>>e&1)==1,n=e<6?e:e<8?e+1:8,r=e<8?8:e<9?7:14-e;X(h,n,8,t),X(h,8,r,t),e<8?X(h,m-1-e,8,t):X(h,8,m-15+e,t)}return X(h,8,m-8,!0),{size:m,modules:h.modules}}function Dt(e,t){let{size:n,modules:r}=Et(e),i=``;for(let e=0;e<n;e++)for(let t=0;t<n;t++)r[e*n+t]&&(i+=`M${t} ${e}h1v1h-1z`);let a=n+4;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${a} ${a}" shape-rendering="crispEdges"><rect width="${a}" height="${a}" fill="#fff"/><g transform="translate(2 2)" fill="#000">${`<path d="${i}"/>`}</g></svg>`}var G,Ot,kt,K,q,J,Y,X,At=n((()=>{G=[16,28,44,64,86,108,124,154,182,216],Ot=[10,16,26,18,24,16,18,22,22,26],kt=[1,1,1,2,2,4,4,4,5,5],K=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],q=new Uint8Array(512),J=new Uint8Array(256);for(let e=0,t=1;e<255;e++)q[e]=t,J[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)q[e]=q[e-255];Y=(e,t)=>e===0||t===0?0:q[(J[e]+J[t])%255],X=(e,t,n,r,i=!0)=>{e.modules[n*e.size+t]=+!!r,i&&(e.reserved[n*e.size+t]=1)}})),jt=r({ShareDialog:()=>Pt}),Mt,Nt,Pt,Ft=n((()=>{R(),St(),At(),Mt=132,Nt=1600,Pt=class{#e;#t;#n;#r;#i=null;#a;constructor(e,t){let n=t.ownerDocument;this.#e=n,this.#r=n.activeElement;let r=e.pageLink(),i=n.title||`Flipbook`;this.#t=n.createElement(`div`),this.#t.className=`zine-share-backdrop`,this.#t.addEventListener(`pointerdown`,e=>{e.target===this.#t&&this.close()}),this.#n=n.createElement(`div`),this.#n.className=`zine-share`,this.#n.setAttribute(`role`,`dialog`),this.#n.setAttribute(`aria-modal`,`true`),this.#n.setAttribute(`aria-label`,`Share`),this.#t.appendChild(this.#n);let a=n.createElement(`div`);a.className=`zine-share-head`;let o=n.createElement(`strong`);o.textContent=`Share`;let s=n.createElement(`button`);s.type=`button`,s.className=`zine-share-close`,s.setAttribute(`aria-label`,`Close`),s.appendChild(I(n,L.close)),s.addEventListener(`click`,()=>this.close()),a.append(o,s),this.#n.append(a,this.#s(n,r),this.#l(n,r,i));let c=this.#o(n,r);c&&this.#n.insertBefore(c,this.#n.children[1]),t.ownerDocument.body.appendChild(this.#t),this.#a=e=>{e.key===`Escape`&&this.close(),e.key===`Tab`&&this.#u(e)},this.#t.addEventListener(`keydown`,this.#a),s.focus()}#o(e,t){if(!t)return null;try{let n=e.createElement(`div`);return n.className=`zine-share-qr`,n.innerHTML=Dt(t,Mt),n.setAttribute(`aria-label`,`QR code for this page`),n.setAttribute(`role`,`img`),n}catch{return null}}#s(e,t){let n=e.createElement(`div`);n.className=`zine-share-link`;let r=e.createElement(`input`);r.type=`text`,r.readOnly=!0,r.value=t,r.setAttribute(`aria-label`,`Link to this page`),r.addEventListener(`focus`,()=>r.select());let i=e.createElement(`button`);return i.type=`button`,i.className=`zine-share-copy`,i.textContent=`Copy`,i.addEventListener(`click`,()=>{this.#c(t,i)}),n.append(r,i),n}async#c(e,t){try{await navigator.clipboard?.writeText(e),t.textContent=`Copied`}catch{t.textContent=`Press Ctrl+C`}this.#i&&clearTimeout(this.#i),this.#i=setTimeout(()=>{t.textContent=`Copy`},Nt)}#l(e,t,n){let r=e.createElement(`div`);r.className=`zine-share-socials`;for(let i of xt){let a=e.createElement(`a`);a.className=`zine-share-social`,a.href=i.href(t,n),a.title=i.label,a.setAttribute(`aria-label`,`Share on ${i.label}`),i.id!==`email`&&(a.target=`_blank`,a.rel=`noopener noreferrer`),a.appendChild(I(e,i.icon)),r.appendChild(a)}return r}#u(e){let t=[...this.#n.querySelectorAll(`button, a[href], input`)].filter(e=>!e.hasAttribute(`disabled`));if(t.length===0)return;let n=t[0],r=t.at(-1),i=this.#e.activeElement;e.shiftKey&&i===n?(r.focus(),e.preventDefault()):!e.shiftKey&&i===r&&(n.focus(),e.preventDefault())}close(){this.destroy()}destroy(){this.#i&&clearTimeout(this.#i),this.#i=null,this.#t.removeEventListener(`keydown`,this.#a),this.#t.remove(),this.#r?.focus?.()}}}));function It(){z({id:`prev`,title:`Previous page`,icon:L.prev,isDisabled:e=>!e.zine.canFlipPrev(),action:e=>e.zine.flipPrev()}),z({id:`next`,title:`Next page`,icon:L.next,isDisabled:e=>!e.zine.canFlipNext(),action:e=>e.zine.flipNext()});let e=e=>e.zine.getDirection()===`rtl`;z({id:`first`,title:`First page`,icon:t=>e(t)?L.last:L.first,isDisabled:e=>!e.zine.canFlipPrev(),action:e=>{e.zine.flipTo(0),e.close()}}),z({id:`last`,title:`Last page`,icon:t=>e(t)?L.first:L.last,isDisabled:e=>!e.zine.canFlipNext(),action:e=>{e.zine.flipTo(e.zine.getPageCount()-1),e.close()}}),z({id:`zoomIn`,title:`Zoom in`,icon:L.zoomIn,isDisabled:e=>e.zine.getZoom()>=e.zine.getMaxZoom()-1e-6,action:e=>e.zine.setZoom(e.zine.getZoom()*Lt)}),z({id:`zoomOut`,title:`Zoom out`,icon:L.zoomOut,isDisabled:e=>e.zine.getZoom()<=1.000001,action:e=>e.zine.setZoom(e.zine.getZoom()/Lt)}),z({id:`fullscreen`,title:`Fullscreen`,icon:L.fullscreen,isVisible:e=>typeof e.zine.container.requestFullscreen==`function`,isActive:Rt,action:e=>{let t=e.zine.container.ownerDocument;Rt(e)?t?.exitFullscreen?.():e.zine.container.requestFullscreen?.(),e.close()}}),z({id:`share`,title:`Share`,icon:L.share,action:e=>{e.close(),Promise.resolve().then(()=>(Ft(),jt)).then(({ShareDialog:t})=>new t(e.zine,e.zine.container)).catch(()=>{navigator.clipboard?.writeText(e.zine.pageLink()).catch(()=>{})})}}),z({id:`download`,title:`Download PDF`,icon:L.download,isVisible:e=>e.zine.canDownload(),action:e=>{e.zine.download(),e.close()}}),z({id:`spread`,title:e=>e.zine.isSinglePage()?`Show two pages`:`Show one page`,icon:e=>e.zine.isSinglePage()?L.twoPages:L.onePage,isVisible:e=>!e.zine.isResponsiveSingle(),action:e=>{e.zine.toggleSpreadMode(),e.close()}}),z({id:`print`,title:`Print`,icon:L.print,isVisible:e=>e.zine.canPrint(),action:e=>{e.zine.print(),e.close()}}),z({id:`menu`,title:`More`,icon:L.menu,children:[`first`,`last`,`spread`,`thumbnails`,`outline`,`print`,`download`]})}var Lt,Rt,zt=n((()=>{R(),H(),Lt=Math.SQRT2,Rt=e=>e.zine.container.ownerDocument?.fullscreenElement===e.zine.container}));function Bt(e){if(e.getElementById(Vt))return;let t=e.createElement(`style`);t.id=Vt,t.textContent=Ht,(e.head??e.documentElement)?.appendChild(t)}var Vt,Ht,Ut=n((()=>{Vt=`zine-controls-style`,Ht=`
91
+ /* Docked mode wraps the book so the bar can sit beside it without shrinking the container,
92
+ whose measured box the renderer and hit-testing both depend on.
93
+ The wrapper deliberately does not stretch or grow its children: the container keeps whatever
94
+ width, aspect-ratio and auto-margins the consumer's own CSS gave it. */
95
+ .zine-controls-wrap { display: flex; }
96
+ /* Stacked: children keep their own width (so a percentage or auto-margin still resolves against
97
+ the wrapper) and take only the height they ask for. */
98
+ .zine-controls-wrap-top,
99
+ .zine-controls-wrap-bottom { flex-direction: column; align-items: stretch; }
100
+ /* Side by side: the bar is only as wide as its buttons, and both are vertically centred. */
101
+ .zine-controls-wrap-left,
102
+ .zine-controls-wrap-right { flex-direction: row; align-items: center; }
103
+ /* min-height:0 matters as much as min-width here. A flex item's automatic minimum size floors it
104
+ at its content, so once the canvas has grown for a taller layout the book cannot shrink back —
105
+ its aspect-ratio is restored but ignored, leaving the extra height behind. */
106
+ .zine-controls-wrap > * { flex: 0 0 auto; min-width: 0; min-height: 0; }
107
+
108
+ .zine-controls {
109
+ position: relative;
110
+ display: flex;
111
+ gap: 4px;
112
+ padding: 5px;
113
+ z-index: 2;
114
+ box-sizing: border-box;
115
+ font: 500 12px/1.2 system-ui, sans-serif;
116
+ color: var(--zine-controls-fg, #f4f4f5);
117
+ touch-action: auto;
118
+ -webkit-user-select: none;
119
+ user-select: none;
120
+ }
121
+ .zine-controls-docked { flex: 0 0 auto; justify-content: center; align-items: center; }
122
+ .zine-controls-floating {
123
+ position: absolute;
124
+ /* Transparent to the book except on the buttons themselves, so gaps stay draggable. */
125
+ pointer-events: none;
126
+ }
127
+ .zine-controls-bar {
128
+ display: flex;
129
+ align-items: center;
130
+ gap: 1px;
131
+ padding: 3px;
132
+ border-radius: 8px;
133
+ pointer-events: auto;
134
+ background: var(--zine-controls-bg, rgba(24, 24, 27, 0.82));
135
+ backdrop-filter: blur(8px);
136
+ }
137
+ /* Floating: lifted off the page it covers. Docked: flat, with an outline so it reads as a
138
+ control strip rather than a shadow hanging in empty space. */
139
+ .zine-controls-floating .zine-controls-bar { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28); }
140
+ .zine-controls-docked .zine-controls-bar {
141
+ border: 1px solid var(--zine-controls-hover, rgba(255, 255, 255, 0.14));
142
+ }
143
+ .zine-controls-floating.zine-controls-bottom { inset: auto 0 0 0; justify-content: center; }
144
+ .zine-controls-floating.zine-controls-top { inset: 0 0 auto 0; justify-content: center; }
145
+ .zine-controls-floating.zine-controls-left { inset: 0 auto 0 0; align-items: center; }
146
+ .zine-controls-floating.zine-controls-right { inset: 0 0 0 auto; align-items: center; }
147
+ /* A bar on a vertical edge stacks its buttons, docked or floating. */
148
+ .zine-controls-left .zine-controls-bar,
149
+ .zine-controls-right .zine-controls-bar { flex-direction: column; }
150
+
151
+ .zine-controls-btn {
152
+ display: inline-flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ width: 26px;
156
+ height: 26px;
157
+ padding: 0;
158
+ border: 0;
159
+ border-radius: 6px;
160
+ background: transparent;
161
+ color: inherit;
162
+ cursor: pointer;
163
+ font: inherit;
164
+ }
165
+ .zine-controls-btn svg { width: 15px; height: 15px; }
166
+ .zine-controls-btn:hover:not(:disabled) { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
167
+ .zine-controls-btn:focus-visible {
168
+ outline: 2px solid var(--zine-controls-accent, #7dd3fc);
169
+ outline-offset: 1px;
170
+ }
171
+ .zine-controls-btn:disabled { opacity: 0.38; cursor: default; }
172
+ /* A custom widget cannot always be disabled itself, so it is marked instead and reads the same. */
173
+ .zine-controls-off { opacity: 0.38; }
174
+ .zine-controls-off[aria-disabled='true'] { pointer-events: none; }
175
+ .zine-controls-btn[aria-pressed="true"],
176
+ .zine-controls-btn[aria-expanded="true"] { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
177
+
178
+ .zine-controls-sep {
179
+ width: 1px;
180
+ align-self: stretch;
181
+ margin: 3px 3px;
182
+ background: currentColor;
183
+ opacity: 0.22;
184
+ }
185
+ .zine-controls-left .zine-controls-sep,
186
+ .zine-controls-right .zine-controls-sep { width: auto; height: 1px; margin: 3px 3px; }
187
+
188
+ .zine-controls-page {
189
+ display: inline-flex;
190
+ align-items: center;
191
+ gap: 3px;
192
+ padding: 0 3px;
193
+ pointer-events: auto;
194
+ white-space: nowrap;
195
+ }
196
+ .zine-controls-page input {
197
+ width: 2.2em;
198
+ padding: 2px 3px;
199
+ border: 1px solid var(--zine-controls-hover, rgba(255,255,255,0.2));
200
+ border-radius: 4px;
201
+ background: rgba(0, 0, 0, 0.25);
202
+ color: inherit;
203
+ font: inherit;
204
+ text-align: center;
205
+ -moz-appearance: textfield;
206
+ }
207
+ .zine-controls-page input::-webkit-outer-spin-button,
208
+ .zine-controls-page input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
209
+ .zine-controls-page input:focus-visible {
210
+ outline: 2px solid var(--zine-controls-accent, #7dd3fc);
211
+ outline-offset: 0;
212
+ }
213
+
214
+ .zine-controls-menu {
215
+ position: absolute;
216
+ display: flex;
217
+ flex-direction: column;
218
+ gap: 1px;
219
+ min-width: 152px;
220
+ padding: 4px;
221
+ border-radius: 8px;
222
+ pointer-events: auto;
223
+ background: var(--zine-controls-bg, rgba(24, 24, 27, 0.94));
224
+ box-shadow: 0 6px 22px rgba(0, 0, 0, 0.36);
225
+ backdrop-filter: blur(8px);
226
+ }
227
+ .zine-controls-menu .zine-controls-btn {
228
+ width: 100%;
229
+ height: auto;
230
+ gap: 8px;
231
+ padding: 6px 8px;
232
+ justify-content: flex-start;
233
+ }
234
+
235
+ /* Search shares the rail: a query field pinned at the top over a scrolling list of hits. */
236
+ .zine-search { gap: 0; overflow: hidden; }
237
+ .zine-search-input {
238
+ flex: 0 0 auto;
239
+ width: 100%;
240
+ padding: 6px 8px;
241
+ border: 1px solid var(--zine-controls-hover, rgba(255,255,255,0.2));
242
+ border-radius: 6px;
243
+ background: rgba(0, 0, 0, 0.25);
244
+ color: inherit;
245
+ font: inherit;
246
+ box-sizing: border-box;
247
+ }
248
+ .zine-search-hits {
249
+ flex: 1 1 auto;
250
+ overflow-y: auto;
251
+ overscroll-behavior: contain;
252
+ margin-top: 5px;
253
+ scrollbar-width: thin;
254
+ }
255
+ .zine-search-hit {
256
+ display: block;
257
+ width: 100%;
258
+ padding: 6px 8px;
259
+ border: 0;
260
+ border-radius: 5px;
261
+ background: transparent;
262
+ color: inherit;
263
+ font: inherit;
264
+ text-align: left;
265
+ cursor: pointer;
266
+ box-sizing: border-box;
267
+ }
268
+ .zine-search-hit:hover { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
269
+ .zine-search-hit:focus-visible {
270
+ outline: 2px solid var(--zine-controls-accent, #7dd3fc);
271
+ outline-offset: -2px;
272
+ }
273
+ .zine-search-page { display: block; font-size: 0.9em; opacity: 0.85; }
274
+ .zine-search-hit small {
275
+ display: block;
276
+ margin-top: 2px;
277
+ opacity: 0.62;
278
+ line-height: 1.35;
279
+ overflow-wrap: anywhere;
280
+ }
281
+
282
+ /* Page-turn arrows flanking the book. Like the docked toolbar and the side panels, they sit
283
+ outside the container so they never shrink the book or intercept its gestures. */
284
+ .zine-arrows-wrap {
285
+ display: flex;
286
+ align-items: center;
287
+ gap: 4px;
288
+ min-width: 0;
289
+ }
290
+ .zine-arrows-wrap > *:not(.zine-arrow) { flex: 1 1 auto; min-width: 0; min-height: 0; }
291
+ .zine-arrow {
292
+ flex: 0 0 auto;
293
+ display: inline-flex;
294
+ align-items: center;
295
+ justify-content: center;
296
+ width: 40px;
297
+ height: 40px;
298
+ padding: 0;
299
+ border: 0;
300
+ border-radius: 50%;
301
+ background: var(--zine-controls-bg, rgba(24, 24, 27, 0.82));
302
+ color: var(--zine-controls-fg, #f4f4f5);
303
+ cursor: pointer;
304
+ backdrop-filter: blur(8px);
305
+ -webkit-user-select: none;
306
+ user-select: none;
307
+ }
308
+ .zine-arrow svg { width: 22px; height: 22px; }
309
+ .zine-arrow:hover:not(:disabled) { background: var(--zine-controls-hover, rgba(255,255,255,0.22)); }
310
+ .zine-arrow:focus-visible {
311
+ outline: 2px solid var(--zine-controls-accent, #7dd3fc);
312
+ outline-offset: 2px;
313
+ }
314
+ /* Nothing to turn to: invisible, but still occupying its slot so the book does not slide across
315
+ as the reader reaches a cover. */
316
+ .zine-arrow-hidden { visibility: hidden; }
317
+ /* No room to flank on a narrow screen; the toolbar's own prev/next still work. */
318
+ @media (max-width: 640px) {
319
+ .zine-arrow { display: none; }
320
+ }
321
+ @media (prefers-reduced-motion: no-preference) {
322
+ .zine-arrow { transition: background 120ms ease; }
323
+ }
324
+
325
+ /* Side panels (thumbnails, outline). The rail wraps the book and its docked toolbar so it sits
326
+ beside them without shrinking the container the renderer measures. */
327
+ .zine-panel-wrap { display: flex; align-items: stretch; gap: 8px; }
328
+
329
+ /* The holder stretches to the book's height; the rail is absolutely positioned inside it so a
330
+ long list scrolls rather than growing the row and running past the bottom of the book. */
331
+ .zine-panel-holder {
332
+ position: relative;
333
+ flex: 0 0 auto;
334
+ align-self: stretch;
335
+ min-height: 0;
336
+ }
337
+ .zine-panel {
338
+ position: absolute;
339
+ inset: 0;
340
+ display: flex;
341
+ flex-direction: column;
342
+ gap: 6px;
343
+ overflow-y: auto;
344
+ overscroll-behavior: contain;
345
+ padding: 6px;
346
+ box-sizing: border-box;
347
+ border-radius: 8px;
348
+ background: var(--zine-controls-bg, rgba(24, 24, 27, 0.82));
349
+ color: var(--zine-controls-fg, #f4f4f5);
350
+ font: 500 11px/1.2 system-ui, sans-serif;
351
+ scrollbar-width: thin;
352
+ touch-action: auto;
353
+ -webkit-user-select: none;
354
+ user-select: none;
355
+ }
356
+ /* Overlay fallback, used when the container has no parent to wrap. */
357
+ .zine-panel-overlay { position: absolute; inset: 0 auto 0 0; z-index: 3; }
358
+ .zine-panel-active { background: var(--zine-controls-hover, rgba(255,255,255,0.18)); }
359
+ .zine-panel-note { padding: 8px; opacity: 0.66; line-height: 1.4; }
360
+
361
+ .zine-thumbs { align-items: center; }
362
+
363
+ .zine-thumbs-row {
364
+ display: flex;
365
+ flex-wrap: wrap;
366
+ justify-content: center;
367
+ gap: 2px;
368
+ width: 100%;
369
+ padding: 4px;
370
+ border: 0;
371
+ border-radius: 6px;
372
+ background: transparent;
373
+ color: inherit;
374
+ font: inherit;
375
+ cursor: pointer;
376
+ box-sizing: border-box;
377
+ }
378
+ .zine-thumbs-row:hover { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
379
+ .zine-thumbs-row:focus-visible {
380
+ outline: 2px solid var(--zine-controls-accent, #7dd3fc);
381
+ outline-offset: -2px;
382
+ }
383
+ .zine-thumbs-row.zine-panel-active .zine-thumbs-cell {
384
+ outline: 1px solid var(--zine-controls-accent, #7dd3fc);
385
+ }
386
+
387
+ /* Outline: a single column of headings, indented by depth. */
388
+ .zine-outline { gap: 1px; }
389
+ .zine-outline-row {
390
+ display: block;
391
+ width: 100%;
392
+ padding: 6px 8px;
393
+ border: 0;
394
+ border-radius: 5px;
395
+ background: transparent;
396
+ color: inherit;
397
+ font: inherit;
398
+ text-align: left;
399
+ line-height: 1.35;
400
+ cursor: pointer;
401
+ box-sizing: border-box;
402
+ overflow-wrap: anywhere;
403
+ }
404
+ .zine-outline-row:hover:not(:disabled) {
405
+ background: var(--zine-controls-hover, rgba(255,255,255,0.14));
406
+ }
407
+ .zine-outline-row:focus-visible {
408
+ outline: 2px solid var(--zine-controls-accent, #7dd3fc);
409
+ outline-offset: -2px;
410
+ }
411
+ /* A heading whose destination could not be resolved: shown, but nothing to click through to. */
412
+ .zine-outline-row:disabled { opacity: 0.5; cursor: default; }
413
+
414
+ .zine-thumbs-cell {
415
+ flex: 1 1 0;
416
+ min-width: 0;
417
+ min-height: 24px;
418
+ display: flex;
419
+ background: rgba(0, 0, 0, 0.3);
420
+ border-radius: 2px;
421
+ overflow: hidden;
422
+ }
423
+ /* A lone page in a book that pairs elsewhere (a cover, a back page) keeps one page's width and
424
+ centres, instead of stretching across both columns. */
425
+ .zine-thumbs-row-lone .zine-thumbs-cell { flex: 0 0 calc(50% - 1px); }
426
+ .zine-thumbs-img { display: block; width: 100%; height: auto; }
427
+ .zine-thumbs-caption { flex: 1 0 100%; text-align: center; opacity: 0.7; }
428
+
429
+ /* Share dialog. Centred over the page rather than in the side rail: a QR and six destinations
430
+ need more room than the rail gives, and sharing is a brief interruption, not a browsing mode. */
431
+ .zine-share-backdrop {
432
+ position: fixed;
433
+ inset: 0;
434
+ z-index: 2147483000;
435
+ display: flex;
436
+ align-items: center;
437
+ justify-content: center;
438
+ padding: 16px;
439
+ background: rgba(0, 0, 0, 0.55);
440
+ font: 500 13px/1.4 system-ui, sans-serif;
441
+ color: var(--zine-controls-fg, #f4f4f5);
442
+ }
443
+ .zine-share {
444
+ width: min(320px, 100%);
445
+ max-height: 100%;
446
+ overflow-y: auto;
447
+ display: flex;
448
+ flex-direction: column;
449
+ gap: 12px;
450
+ padding: 14px;
451
+ border-radius: 12px;
452
+ background: var(--zine-share-bg, #1c1c20);
453
+ box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
454
+ box-sizing: border-box;
455
+ }
456
+ .zine-share-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
457
+ .zine-share-head strong { font-size: 15px; }
458
+ .zine-share-close {
459
+ display: inline-flex;
460
+ width: 26px;
461
+ height: 26px;
462
+ align-items: center;
463
+ justify-content: center;
464
+ padding: 0;
465
+ border: 0;
466
+ border-radius: 6px;
467
+ background: transparent;
468
+ color: inherit;
469
+ cursor: pointer;
470
+ }
471
+ .zine-share-close svg { width: 16px; height: 16px; }
472
+ .zine-share-close:hover { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
473
+
474
+ .zine-share-qr {
475
+ align-self: center;
476
+ line-height: 0;
477
+ padding: 8px;
478
+ border-radius: 8px;
479
+ background: #fff;
480
+ }
481
+ .zine-share-qr svg { display: block; }
482
+
483
+ .zine-share-link { display: flex; gap: 6px; }
484
+ .zine-share-link input {
485
+ flex: 1 1 auto;
486
+ min-width: 0;
487
+ padding: 7px 9px;
488
+ border: 1px solid var(--zine-controls-hover, rgba(255,255,255,0.2));
489
+ border-radius: 7px;
490
+ background: rgba(0, 0, 0, 0.3);
491
+ color: inherit;
492
+ font: inherit;
493
+ }
494
+ .zine-share-copy {
495
+ flex: 0 0 auto;
496
+ min-width: 74px;
497
+ padding: 7px 12px;
498
+ border: 0;
499
+ border-radius: 7px;
500
+ background: var(--zine-controls-accent, #7dd3fc);
501
+ color: #06202c;
502
+ font: inherit;
503
+ font-weight: 600;
504
+ cursor: pointer;
505
+ }
506
+
507
+ .zine-share-socials { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
508
+ .zine-share-social {
509
+ display: inline-flex;
510
+ width: 38px;
511
+ height: 38px;
512
+ align-items: center;
513
+ justify-content: center;
514
+ border-radius: 8px;
515
+ background: rgba(255, 255, 255, 0.08);
516
+ color: inherit;
517
+ text-decoration: none;
518
+ }
519
+ .zine-share-social svg { width: 19px; height: 19px; }
520
+ .zine-share-social:hover { background: var(--zine-controls-hover, rgba(255,255,255,0.18)); }
521
+ .zine-share-close:focus-visible,
522
+ .zine-share-copy:focus-visible,
523
+ .zine-share-social:focus-visible,
524
+ .zine-share-link input:focus-visible {
525
+ outline: 2px solid var(--zine-controls-accent, #7dd3fc);
526
+ outline-offset: 2px;
527
+ }
528
+
529
+ @media (prefers-reduced-motion: no-preference) {
530
+ .zine-controls-btn { transition: background 120ms ease; }
531
+ }
532
+ `})),Z,Wt=n((()=>{Z=class{root;#e;#t=null;constructor(e,t,n){this.#e=e.createElement(`div`),this.#e.className=`zine-panel-holder`,this.#e.style.width=`${n.width}px`,this.root=e.createElement(`div`),this.root.className=`zine-panel ${n.className}`,this.root.setAttribute(`role`,`listbox`),this.root.setAttribute(`aria-label`,n.label),this.#e.appendChild(this.root);for(let e of[`pointerdown`,`pointerup`,`pointermove`,`click`,`dblclick`,`wheel`])this.root.addEventListener(e,e=>e.stopPropagation());this.#n(e,t)}setWidth(e){this.#e.style.width=`${e}px`}#n(e,t){if(!t.parentNode){this.#e.classList.add(`zine-panel-overlay`),t.appendChild(this.#e);return}let n=t.closest(`.zine-controls-wrap`)??t,r=e.createElement(`div`);r.className=`zine-panel-wrap`,n.parentNode.insertBefore(r,n),r.append(this.#e,n),this.#t=r}destroy(){this.#e.remove();let e=this.#t;if(e?.parentNode){for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);e.remove()}this.#t=null}}})),Gt,Kt,qt=n((()=>{Wt(),Gt=78,Kt=class{#e;#t;#n;#r=[];#i=null;#a=[];constructor(e,t){this.#e=e;let n=t.ownerDocument;this.#t=n,this.#n=new Z(n,t,{className:`zine-thumbs`,label:`Pages`,width:90}),this.#o(),this.#a.push(e.on(`pageChanged`,()=>this.#l())),this.#l()}#o(){let e=this.#e.getSpreads(),t=this.#e.getDirection()===`rtl`,n=e.some(e=>e.left!==null&&e.right!==null);this.#n.root.classList.toggle(`zine-thumbs-solo`,!n),n&&this.#n.setWidth(170);for(let[r,i]of e.entries()){let e=this.#t.createElement(`button`);e.type=`button`,e.className=`zine-thumbs-row`,e.setAttribute(`role`,`option`),t&&(e.style.flexDirection=`row-reverse`);let a=[i.left,i.right].filter(e=>e!==null);n&&a.length===1&&e.classList.add(`zine-thumbs-row-lone`);for(let t of a){let n=this.#t.createElement(`span`);n.className=`zine-thumbs-cell`,n.dataset.page=String(t),e.appendChild(n)}let o=[...a].sort((e,t)=>e-t).map(e=>e+1);e.setAttribute(`aria-label`,o.length>1?`Pages ${o[0]}–${o.at(-1)}`:`Page ${o[0]??``}`);let s=this.#t.createElement(`span`);s.className=`zine-thumbs-caption`,s.textContent=o.join(`–`),e.appendChild(s),e.addEventListener(`click`,()=>{a.length>0&&this.#e.flipTo(Math.min(...a))}),this.#n.root.appendChild(e),this.#r.push({el:e,spread:r})}this.#s()}#s(){let e=[...this.#n.root.querySelectorAll(`.zine-thumbs-cell[data-page]`)];if(typeof IntersectionObserver>`u`){for(let t of e)this.#c(t);return}this.#i=new IntersectionObserver((e,t)=>{for(let n of e)n.isIntersecting&&(t.unobserve(n.target),this.#c(n.target))},{root:this.#n.root,rootMargin:`200px`});for(let t of e)this.#i.observe(t)}async#c(e){let t=Number(e.dataset.page),n=await this.#e.getPageImage(t);if(!n||!e.isConnected)return;let r=n.width,i=n.height;if(!r||!i)return;let a=Math.min(2,globalThis.devicePixelRatio||1),o=this.#t.createElement(`canvas`);o.width=Math.max(1,Math.round(Gt*a)),o.height=Math.max(1,Math.round(Gt*i/r*a)),o.className=`zine-thumbs-img`;let s=o.getContext(`2d`);if(s){try{s.drawImage(n,0,0,o.width,o.height)}catch{return}e.replaceChildren(o)}}#l(){let e=this.#e.getSpreadIndex();for(let{el:t,spread:n}of this.#r){let r=n===e;t.classList.toggle(`zine-panel-active`,r),t.setAttribute(`aria-selected`,String(r)),r&&t.scrollIntoView?.({block:`nearest`})}}destroy(){for(let e of this.#a)e();this.#a=[],this.#i?.disconnect(),this.#i=null,this.#n.destroy()}}})),Jt,Yt,Xt,Zt=n((()=>{Wt(),Jt=208,Yt=12,Xt=class{#e;#t;#n;#r=[];#i=[];constructor(e,t){this.#e=e;let n=t.ownerDocument;this.#t=n,this.#n=new Z(n,t,{className:`zine-outline`,label:`Outline`,width:Jt}),this.#a(`Loading…`),this.#o(),this.#i.push(e.on(`pageChanged`,()=>this.#c()))}#a(e){let t=this.#t.createElement(`div`);t.className=`zine-panel-note`,t.textContent=e,this.#n.root.replaceChildren(t)}async#o(){let e=await this.#e.getOutline();if(this.#n.root.isConnected){if(e.length===0){this.#a(`This document has no outline.`);return}this.#n.root.replaceChildren(),this.#s(e,0),this.#c()}}#s(e,t){for(let n of e){let e=this.#t.createElement(`button`);if(e.type=`button`,e.className=`zine-outline-row`,e.setAttribute(`role`,`option`),e.style.paddingLeft=`${8+t*Yt}px`,e.textContent=n.title,e.title=n.title,n.page===null)e.disabled=!0;else{let t=n.page;e.setAttribute(`aria-label`,`${n.title}, page ${t+1}`),e.addEventListener(`click`,()=>this.#e.flipTo(t)),this.#r.push({el:e,page:t})}this.#n.root.appendChild(e),n.children.length>0&&this.#s(n.children,t+1)}}#c(){let e=this.#e.getPage(),t=null,n=-1;for(let{el:r,page:i}of this.#r)r.classList.remove(`zine-panel-active`),r.removeAttribute(`aria-selected`),i<=e&&i>=n&&(t=r,n=i);t&&(t.classList.add(`zine-panel-active`),t.setAttribute(`aria-selected`,`true`),t.scrollIntoView?.({block:`nearest`}))}destroy(){for(let e of this.#i)e();this.#i=[],this.#n.destroy()}}})),Qt,$t,en,tn,nn=n((()=>{Wt(),Qt=208,$t=180,en=2,tn=class{#e;#t;#n;#r;#i;#a=0;#o=null;constructor(e,t){this.#e=e;let n=t.ownerDocument;this.#t=n,this.#n=new Z(n,t,{className:`zine-search`,label:`Search results`,width:Qt}),this.#r=n.createElement(`input`),this.#r.type=`search`,this.#r.className=`zine-search-input`,this.#r.placeholder=`Search…`,this.#r.setAttribute(`aria-label`,`Search the document`),this.#r.addEventListener(`input`,()=>{this.#o&&clearTimeout(this.#o),this.#o=setTimeout(()=>void this.#c(),$t)}),this.#r.addEventListener(`keydown`,e=>{e.key===`Enter`&&(this.#o&&clearTimeout(this.#o),this.#c())}),this.#i=n.createElement(`div`),this.#i.className=`zine-search-hits`,this.#n.root.append(this.#r,this.#i),this.#r.focus()}#s(e){let t=this.#t.createElement(`div`);t.className=`zine-panel-note`,t.textContent=e,this.#i.replaceChildren(t)}async#c(){let e=this.#r.value.trim(),t=++this.#a;if(e.length<en){this.#i.replaceChildren();return}this.#s(`Searching…`);let n=await this.#e.search(e);if(!(t!==this.#a||!this.#n.root.isConnected)){if(n.length===0){this.#s(`No matches for “${e}”`);return}this.#i.replaceChildren(...n.map(e=>{let t=this.#t.createElement(`button`);t.type=`button`,t.className=`zine-search-hit`,t.setAttribute(`role`,`option`),t.setAttribute(`aria-label`,`Page ${e.page+1}: ${e.excerpt}`);let n=this.#t.createElement(`span`);n.className=`zine-search-page`,n.textContent=`Page ${e.page+1}`;let r=this.#t.createElement(`small`);return r.textContent=e.excerpt,t.append(n,r),t.addEventListener(`click`,()=>this.#e.flipTo(e.page)),t}))}}destroy(){this.#o&&clearTimeout(this.#o),this.#o=null,this.#a++,this.#n.destroy()}}})),rn,an=n((()=>{R(),rn=class{#e;#t;#n;#r=null;#i=[];constructor(e,t){this.#e=e;let n=t.ownerDocument,r=e.getDirection()===`rtl`;this.#t=this.#a(n,r?L.next:L.prev,`Previous page`,()=>e.flipPrev()),this.#n=this.#a(n,r?L.prev:L.next,`Next page`,()=>e.flipNext()),this.#o(n,t);let i=()=>this.#s();this.#i.push(e.on(`pageChanged`,i)),this.#i.push(e.on(`flipEnd`,i)),this.#s()}#a(e,t,n,r){let i=e.createElement(`button`);i.type=`button`,i.className=`zine-arrow`,i.title=n,i.setAttribute(`aria-label`,n),i.appendChild(I(e,t)),i.addEventListener(`click`,r);for(let e of[`pointerdown`,`pointerup`,`click`])i.addEventListener(e,e=>e.stopPropagation());return i}#o(e,t){let n=t.closest(`.zine-panel-wrap`)??t.closest(`.zine-controls-wrap`)??t,r=n.parentNode;if(!r)return;let i=e.createElement(`div`);i.className=`zine-arrows-wrap`,r.insertBefore(i,n),i.append(this.#t,n,this.#n),this.#r=i}#s(){for(let[e,t]of[[this.#t,this.#e.canFlipPrev()],[this.#n,this.#e.canFlipNext()]])e.disabled=!t,e.classList.toggle(`zine-arrow-hidden`,!t)}destroy(){for(let e of this.#i)e();this.#i=[],this.#t.remove(),this.#n.remove();let e=this.#r;if(e?.parentNode){for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);e.remove()}this.#r=null}}}));function on(e){It(),z({id:`thumbnails`,title:()=>e.openPanel()===`thumbnails`?`Hide thumbnails`:`Show thumbnails`,icon:L.thumbnails,isVisible:e=>e.zine.isDocument(),isActive:()=>e.openPanel()===`thumbnails`,action:t=>{e.togglePanel(`thumbnails`),t.close()}}),z({id:`outline`,title:()=>e.openPanel()===`outline`?`Hide outline`:`Show outline`,icon:L.outline,isVisible:()=>e.hasOutline(),isActive:()=>e.openPanel()===`outline`,action:t=>{e.togglePanel(`outline`),t.close()}}),z({id:`pageInput`,title:`Page`,render:()=>e.makePageInput()}),z({id:`search`,title:()=>e.openPanel()===`search`?`Hide search`:`Search`,icon:L.search,isVisible:e=>e.zine.canSearch(),isActive:()=>e.openPanel()===`search`,action:()=>e.togglePanel(`search`)})}var sn,cn,ln,un=n((()=>{R(),H(),zt(),Ut(),qt(),Zt(),nn(),an(),sn={thumbnails:Kt,outline:Xt,search:tn},cn=[`pointerdown`,`pointerup`,`pointermove`,`click`,`dblclick`,`wheel`,`keydown`],ln=class{#e;#t;#n;#r;#i=[];#a=null;#o=[];#s=null;#c=null;#l;#u=null;#d=null;#f=null;#p=null;constructor(e,t,n){this.#e=e,this.#l=t;let r=t.ownerDocument;this.#t=r,Bt(r);let i=n.position??`bottom`,a=n.docked??!0;this.#n=r.createElement(`div`),this.#n.className=[`zine-controls`,`zine-controls-${i}`,a?`zine-controls-docked`:`zine-controls-floating`,n.className].filter(Boolean).join(` `),this.#n.setAttribute(`role`,`toolbar`),this.#n.setAttribute(`aria-label`,`Flipbook controls`),this.#r=r.createElement(`div`),this.#r.className=`zine-controls-bar`,this.#n.appendChild(this.#r),this.#n.addEventListener(`keydown`,e=>this.#E(e));for(let e of cn)this.#n.addEventListener(e,e=>this.#h(e));this.#m(t,i,a);let o=()=>this.#D();this.#o.push(e.on(`pageChanged`,o)),this.#o.push(e.on(`zoomChanged`,o)),this.#o.push(e.on(`flipEnd`,o));let s=e=>{this.#a&&!this.#a.el.contains(e.target)&&this.#T()};r.addEventListener(`pointerdown`,s,!0),this.#o.push(()=>r.removeEventListener(`pointerdown`,s,!0))}#m(e,t,n){if(!n){e.appendChild(this.#n);return}let r=e.parentNode;if(!r){this.#n.classList.replace(`zine-controls-docked`,`zine-controls-floating`),e.appendChild(this.#n);return}let i=this.#t.createElement(`div`);i.className=`zine-controls-wrap zine-controls-wrap-${t}`,r.insertBefore(i,e),i.appendChild(e),t===`top`||t===`left`?i.insertBefore(this.#n,e):i.appendChild(this.#n),this.#c=i}mount(e){this.#_(e.items??V),(e.arrows??!0)&&(this.#p=new rn(this.#e,this.#l)),this.#D(),this.#A()}destroy(){for(let e of this.#o)e();this.#o=[],this.#T(),this.#u?.destroy(),this.#u=null,this.#d=null,this.#n.remove();let e=this.#c;e?.parentNode&&(e.parentNode.insertBefore(e.firstChild,e),e.remove()),this.#c=null,this.#p?.destroy(),this.#p=null}#h(e){e.stopPropagation()}#g(e=()=>this.#T()){return{zine:this.#e,close:e}}#_(e){for(let t of e){if(t===`|`){let e=this.#t.createElement(`div`);e.className=`zine-controls-sep`,this.#r.appendChild(e);continue}let e=bt(t),n;e.render?(n=e.render(this.#g()),this.#i.push({el:n,def:e})):n=this.#b(e,`zine-controls-btn`),this.#r.appendChild(n)}}#v(e){return typeof e.title==`function`?e.title(this.#g()):e.title}#y(e){return typeof e.icon==`function`?e.icon(this.#g()):e.icon}#b(e,t,n=!1){let r=this.#t.createElement(`button`),i=this.#v(e),a=this.#y(e);if(r.type=`button`,r.className=t,r.title=i,r.setAttribute(`aria-label`,i),a&&r.appendChild(I(this.#t,a)),n||!a){let e=this.#t.createElement(`span`);e.className=`zine-controls-label`,e.textContent=i,r.appendChild(e)}return r.addEventListener(`click`,()=>this.#x(e,r)),this.#i.push({el:r,def:e}),r}#x(e,t){if(!e.isDisabled?.(this.#g())){if(e.children){this.#a?.trigger===t?this.#T():this.#S(e,t);return}e.action?.(this.#g()),this.#D()}}#S(e,t){this.#T();let n=this.#t.createElement(`div`);n.className=`zine-controls-menu`,n.setAttribute(`role`,`menu`);let r=this.#g();for(let t of e.children??[]){if(t===`|`)continue;let e=bt(t);if(e.isVisible&&!e.isVisible(r))continue;let i;e.render?(i=e.render(this.#g()),this.#i.push({el:i,def:e})):i=this.#b(e,`zine-controls-btn`,!0),i.setAttribute(`role`,`menuitem`),n.appendChild(i)}this.#C(n,t),this.#D(),n.querySelector(`button`)?.focus()}#C(e,t){this.#n.appendChild(e),this.#a={el:e,trigger:t},t.setAttribute(`aria-expanded`,`true`),this.#w(e,t)}#w(e,t){let n=this.#n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(!n.width||!i.width)return;let a=r.left-n.left+r.width/2-i.width/2;a=Math.max(4,Math.min(a,n.width-i.width-4)),e.style.left=`${a}px`;let o=r.bottom-n.top+6,s=r.top-n.top-i.height-6;e.style.top=`${s>=0?s:o}px`}#T(){if(!this.#a)return;let{el:e,trigger:t}=this.#a;this.#a=null,t.removeAttribute(`aria-expanded`),this.#i=this.#i.filter(t=>!e.contains(t.el)),e.remove(),this.#t.activeElement&&e.contains(this.#t.activeElement)&&t.focus()}#E(e){if(e.key===`Escape`&&this.#a){let{trigger:t}=this.#a;this.#T(),t.focus(),e.preventDefault();return}let t=[...this.#n.querySelectorAll(`button, input`)],n=t.indexOf(this.#t.activeElement);if(n<0||this.#t.activeElement instanceof HTMLInputElement)return;let r=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;r!==0&&(t[(n+r+t.length)%t.length]?.focus(),e.preventDefault())}#D(){let e=this.#g();for(let{el:t,def:n}of this.#i){let r=n.children?this.#k(n,e):n.isVisible?.(e);r!==void 0&&(t.style.display=r?``:`none`);let i=n.isDisabled?.(e)??!1;for(let e of this.#O(t))e.disabled=i;if(this.#O(t).length||t.setAttribute(`aria-disabled`,String(i)),t.classList.toggle(`zine-controls-off`,i),n.isActive&&t.setAttribute(`aria-pressed`,String(n.isActive(e))),typeof n.title==`function`){let r=n.title(e);t.title=r,t.setAttribute(`aria-label`,r);let i=t.querySelector(`.zine-controls-label`);i&&(i.textContent=r)}typeof n.icon==`function`&&t.querySelector(`svg`)?.replaceWith(I(this.#t,n.icon(e)))}this.#s&&this.#t.activeElement!==this.#s&&(this.#s.value=String(this.#e.getPage()+1))}#O(e){return e instanceof HTMLButtonElement||e instanceof HTMLInputElement?[e]:[...e.querySelectorAll(`button, input`)]}#k(e,t){return e.isVisible&&!e.isVisible(t)?!1:(e.children??[]).some(e=>{if(e===`|`)return!1;let n=bt(e);return!n.isVisible||n.isVisible(t)})}makePageInput(){let e=this.#t.createElement(`div`);e.className=`zine-controls-page`;let t=this.#t.createElement(`input`);t.type=`number`,t.min=`1`,t.max=String(this.#e.getPageCount()),t.value=String(this.#e.getPage()+1),t.setAttribute(`aria-label`,`Page number`);let n=this.#t.createElement(`span`);n.textContent=`/ ${this.#e.getPageCount()}`;let r=()=>{let e=Number(t.value);Number.isFinite(e)&&this.#e.flipTo(Math.round(e)-1),t.value=String(this.#e.getPage()+1)};return t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(r(),t.blur())}),t.addEventListener(`blur`,r),e.append(t,n),this.#s=t,e}openPanel(){return this.#d}hasOutline(){return this.#f===!0}#A(){this.#f!==null||!this.#e.canOutline()||(this.#f=!1,this.#e.getOutline().then(e=>{if(e.length===0)return;this.#f=!0,this.#D();let t=this.#a;if(t){let e=this.#i.find(e=>e.el===t.trigger)?.def;this.#T(),e&&this.#S(e,t.trigger)}}))}togglePanel(e){let t=this.#d;this.#u?.destroy(),this.#u=null,this.#d=null,t!==e&&(this.#u=new sn[e](this.#e,this.#l),this.#d=e),this.#D()}}})),dn=r({DEFAULT_ITEMS:()=>V,ICONS:()=>L,createIcon:()=>I,defineControl:()=>z,getControl:()=>yt,mountControls:()=>fn});function fn(e,t,n={}){let r=new ln(e,t,n);return on(r),r.mount(n),()=>r.destroy()}var pn=n((()=>{un(),H(),R()}));D();var mn=.25,hn=.0015,gn=6,_n=250,vn=1.55,yn=32,bn=120;function xn(e,t,n){let r=Math.max(0,t-yn),i=Math.min(e.length,t+n+yn),a=e.slice(r,i).replace(/\s+/g,` `).trim();return`${r>0?`…`:``}${a}${i<e.length?`…`:``}`}var Sn=class{#e;#t;#n=new c;#r=new s(2);#i=new d;#a;#o;#s;#c;#l=1;#u;#d;#f;#p;#m;#h=!1;#g=null;#_=!1;#v;#y=``;#b;#x;#S;#C=null;#w=null;#T=[];#E=0;#D=0;#O={left:null,right:null};#k;#A;#j;#M;#N;#P=null;#F=!1;#I=1;#L=0;#R=0;#z=null;#B=!1;#V=!1;#H=null;#U=null;#W=null;#G=null;#K=null;#q=null;#J=null;#Y=0;#X=null;#Z=!1;#Q=1;#$=!1;#ee=null;#te=null;#ne=null;#re=null;#ie=null;#ae=null;#oe=null;#se=new Set;#ce;#le=null;#ue=null;#de=0;#fe=null;#pe;debug={setFlipProgress:(e,t)=>{this.#z?.setFlipProgress(e,t)}};constructor(e,t){En(e,t),this.#e=e,t.width!==void 0&&(e.style.width=`${t.width}px`),t.height!==void 0&&(e.style.height=`${t.height}px`),this.#t=gt(t.source,{frontCover:t.frontCover,backCover:t.backCover,pages:t.pages});let n=t.direction??`ltr`;this.#a=n,this.#x=(t.deepLink??!0)&&b(),this.#S=t.disableContextMenu??!1,this.#o=t.spreadMode??`cover`,this.#s=this.#o,this.#c=t.curl??`cone`,this.#u=t.clickToFlip??`edge`,this.#d=t.clickZoneSize??64,this.#m=t.singlePageThreshold??640,this.#v=t.responsiveSpread??!0,this.#ce=t.controls??!0,this.#b=t.startPage,typeof this.#t.open!=`function`&&this.#mt(),this.#k=t.flipDuration??800,this.#A=t.zoom?.enabled??!0,this.#j=t.zoom?.wheel??!0;let r=t.zoom?.doubleClick,i=r===!1?[]:[...r??[1,2,4]].sort((e,t)=>e-t);this.#M=i.length>0?i:null,this.#N=t.zoom?.max??4;let a=this.#A&&this.#M!==null,o=t.zoom?.doubleClickInFlipZone??this.#u===`half`;this.#f=this.#u!==`off`&&a&&o&&t.clickFlipDelay!==0,this.#p=this.#f?t.clickFlipDelay??_n:0,this.#pe=this.#Ve(t.renderer??`auto`)}get ready(){return this.#pe}getPageCount(){return this.#t.pageCount}getPage(){return this.#D}get container(){return this.#e}getSpreads(){return this.#T}getSpreadIndex(){return this.#E}getDirection(){return this.#a}getSpreadMode(){return this.#o}isSinglePage(){return this.#h}setSpreadMode(e){e!==this.#o&&(this.#o=e,this.#_=!1,this.#$e(),this.#et())}toggleSpreadMode(){this.setSpreadMode(this.#o===`single`?this.#s===`single`?`double`:this.#s:`single`)}getResponsiveSpread(){return this.#v}isResponsiveSingle(){return this.#_&&this.#o!==`single`}setResponsiveSpread(e){if(e!==this.#v){if(this.#v=e,e){let e=this.#z?.measure().containerWidth;if(e===void 0)return;this.#_=!1,this.#Qe(e)}else{if(!this.#_)return;this.#_=!1,this.#$e()}this.#et()}}getPageImage(e){return this.#dt(e)}canFlipNext(){return this.#E+1<this.#T.length}canFlipPrev(){return this.#E>0}getMaxZoom(){return this.#N}canSearch(){return typeof this.#t.getText==`function`}canDownload(){return typeof this.#t.getDownload==`function`}isDocument(){return typeof this.#t.getOutline==`function`||typeof this.#t.getText==`function`}canPrint(){return typeof this.#t.getDownload==`function`}async print(){let e=await this.getSourceFile(),t=this.#e.ownerDocument;if(!e||!t)return!1;let n=t.createElement(`iframe`);return n.style.cssText=`position:fixed;right:0;bottom:0;width:1px;height:1px;opacity:0;border:0;`,n.setAttribute(`aria-hidden`,`true`),n.src=e.url,new Promise(r=>{let i=!1,a=t=>{i||(i=!0,setTimeout(()=>{n.remove(),e.revoke&&URL.revokeObjectURL(e.url)},6e4),r(t))};n.addEventListener(`load`,()=>{try{let e=n.contentWindow;if(!e)return a(!1);e.focus(),e.print(),a(!0)}catch{a(!1)}}),n.addEventListener(`error`,()=>a(!1)),t.body.appendChild(n)})}canOutline(){return typeof this.#t.getOutline==`function`}getOutline(){if(!this.#oe){let e=this.#t.getOutline;this.#oe=typeof e==`function`?Promise.resolve(e.call(this.#t)).catch(()=>[]):Promise.resolve([])}return this.#oe}async getSourceFile(){let e=this.#t.getDownload;return typeof e==`function`?await e.call(this.#t)??null:null}async download(){let e=await this.getSourceFile();if(!e)return!1;let t=this.#e.ownerDocument;if(!t)return!1;let n=t.createElement(`a`);return n.href=e.url,n.download=e.filename,n.rel=`noopener`,t.body.appendChild(n),n.click(),n.remove(),e.revoke&&setTimeout(()=>URL.revokeObjectURL(e.url),1e4),!0}async search(e,t={}){let n=this.#t.getText,r=e.trim().toLowerCase();if(typeof n!=`function`||r===``)return[];let i=t.limit??50,a=[];for(let e=0;e<this.#t.pageCount&&a.length<i;e++){let t;try{t=await n.call(this.#t,e)}catch(t){this.#n.emit(`sourceError`,{index:e,error:t});continue}let i=t.toLowerCase().indexOf(r);i<0||a.push({page:e,excerpt:xn(t,i,r.length)})}return a}flipNext(){this.#me(1)}flipPrev(){this.#me(-1)}#me(e){this.#he(()=>this.#ye(this.#E+e))}flipTo(e){let t=Q(e,0,Math.max(0,this.#t.pageCount-1));this.#he(()=>this.#ye(this.#pt(t)))}#he(e){this.#i.state===`idle`?e():this.#J?(this.#q=null,this.#ge(),e()):this.#q=e}#ge(){let e=this.#J;e&&(this.#J=null,this.#H!==null&&(cancelAnimationFrame(this.#H),this.#H=null),this.#z?.setFlipProgress(e.toT,e.direction),e.onDone())}#_e(){let e=this.#q;if(!e){this.#st();return}this.#q=null,e()}getZoom(){return this.#I}setZoom(e,t){if(!this.#z||!this.#A)return;let n=Q(e,1,this.#N),r=this.#z.measure(),i=t??{x:r.containerWidth/2,y:r.containerHeight/2},a=this.#I,o=n===1?0:i.x-n/a*(i.x-this.#L),s=n===1?0:i.y-n/a*(i.y-this.#R);[o,s]=this.#ve(o,s,n,r.containerWidth,r.containerHeight),this.#I=n,this.#L=o,this.#R=s,this.#z.setViewTransform(n,o,s),this.#it(),this.#n.emit(`zoomChanged`,{scale:n})}resetZoom(){this.setZoom(1)}#ve(e,t,n,r,i){return[Q(e,r*(1-n),0),Q(t,i*(1-n),0)]}on(e,t){return this.#n.on(e,t)}destroy(){this.#V=!0,this.#H!==null&&cancelAnimationFrame(this.#H),this.#J=null,this.#q=null,this.#Ne(),this.#P?.disconnect(),this.#C?.stop(),this.#C=null,this.#w?.(),this.#x&&x(),this.#le?.(),this.#ae?.(),this.#ne?.(),this.#ie?.(),this.#re?.(),this.#te?.(),this.#fe!==null&&clearTimeout(this.#fe),this.#de++,this.#ue?.destroy(),this.#ue=null,this.#z?.destroy(),this.#z=null,this.#t.destroy(),this.#n.clear()}#ye(e){if(e<0||e>=this.#T.length||e===this.#E||this.#i.send(`flip`)===null)return;let t=e>this.#E?`forward`:`backward`,n=this.#Ce(e);this.#n.emit(`flipStart`,{from:this.#D,to:n}),this.#be(e,t,n,++this.#Y)}async#be(e,t,n,r){let i=this.#T[e],a=i?await this.#ut(i):{left:null,right:null};r===this.#Y&&(this.#z?.beginFlip(this.#O,a,t,{fill:this.#h,curl:this.#c,anchor:{y:this.#l}}),this.#xe(0,1,t,()=>this.#Se(e,n,a)))}#xe(e,t,n,r){let i=this.#Xe()*Math.abs(t-e);if(i<=0){this.#z?.setFlipProgress(t,n),r();return}let a={toT:t,direction:n,onDone:r};this.#J=a;let o=performance.now(),s=c=>{if(this.#J!==a)return;let l=Math.min(1,(c-o)/i),u=this.#h?wn(l):Cn(l);this.#z?.setFlipProgress(e+(t-e)*u,n),l<1?this.#H=requestAnimationFrame(s):(this.#H=null,this.#J=null,r())};this.#H=requestAnimationFrame(s)}#Se(e,t,n){let r=this.#T[e];this.#E=e,this.#D=t,this.#O=n,r&&this.#tt(r,n),this.#ft(),this.#i.send(`settle`),this.#Ye(),this.#n.emit(`pageChanged`,{page:t}),this.#n.emit(`flipEnd`,{page:t}),this.#_e()}#Ce(e){let t=this.#T[e];if(!t)return this.#D;let n=[t.left,t.right].filter(e=>e!==null);return n.length>0?Math.min(...n):this.#D}#we(e,t){if(this.#Z||!this.#z)return;if(this.#Ne(),this.#I>1){if(this.#i.send(`panStart`)===null)return;this.#X={baseTx:this.#L,baseTy:this.#R};return}let n=this.#Ae(),r=this.#je(e,t);if(this.#G=r,this.#i.state!==`idle`){this.#W=null;return}let i=Math.min(n.width,n.height)*mn;if(_(r,{width:n.width,height:n.height},i)!==`corner`)return;this.#l=Q(r.y/n.height,0,1);let a=r.x>n.width/2,o=this.#a===`rtl`?!a:a,s=this.#E+(o?1:-1);s<0||s>=this.#T.length||(this.#W={direction:o?`forward`:`backward`,targetIndex:s,toPage:this.#Ce(s),width:n.width})}#Te(){let e=this.#W;e&&(this.#W=null,this.#i.send(`grab`)!==null&&(this.#U={direction:e.direction,targetIndex:e.targetIndex,toPage:e.toPage,toContent:{left:null,right:null},width:e.width,t:0},this.#n.emit(`flipStart`,{from:this.#D,to:e.toPage}),this.#Ee(e.targetIndex,e.direction)))}async#Ee(e,t){let n=this.#T[e],r=n?await this.#ut(n):{left:null,right:null};this.#U?.targetIndex===e&&(this.#U.toContent=r,this.#z?.beginFlip(this.#O,r,t,{fill:this.#h,curl:this.#c,anchor:{y:this.#l}}),this.#z?.setFlipProgress(this.#U.t,t))}#De(e,t){if(this.#Z)return;if(this.#X){if(!this.#z)return;let n=this.#z.measure(),[r,i]=this.#ve(this.#X.baseTx+e,this.#X.baseTy+t,this.#I,n.containerWidth,n.containerHeight);this.#L=r,this.#R=i,this.#z.setViewTransform(this.#I,r,i),this.#it();return}this.#W&&Math.hypot(e,t)>gn&&this.#Te();let n=this.#U;n&&(n.t=Q((n.direction===`forward`?-e:e)/n.width,0,1),this.#z?.setFlipProgress(n.t,n.direction))}#Oe(e){if(this.#Z)return;if(this.#X){this.#X=null,this.#i.send(`panEnd`);return}let t=this.#U;if(!t){this.#W=null,this.#ke(e);return}this.#U=null,this.#i.send(`release`);let n=e.swipe&&(t.direction===`forward`?e.dx<0:e.dx>0);t.t>=.5||n?this.#xe(t.t,1,t.direction,()=>this.#Se(t.targetIndex,t.toPage,t.toContent)):this.#xe(t.t,0,t.direction,()=>this.#Pe())}#ke(e){if(this.#u===`off`||this.#I>1||!this.#G||Math.abs(e.dx)>gn||Math.abs(e.dy)>gn)return;let t=this.#Me(this.#G);if(!t)return;let n=t===`forward`?1:-1;if(this.#E+n<0||this.#E+n>=this.#T.length)return;this.#l=Q(this.#G.y/this.#Ae().height,0,1);let r=()=>this.#ye(this.#E+n);if(this.#Ne(),this.#p<=0){this.#he(r);return}this.#K=setTimeout(()=>{this.#K=null,this.#he(r)},this.#p)}#Ae(){let e=this.#z.measure();return e.content??e.book??{x:0,y:0,width:e.containerWidth,height:e.containerHeight}}#je(e,t){let n=this.#e.getBoundingClientRect(),r=this.#Ae();return{x:e-n.left-r.x,y:t-n.top-r.y}}#Me(e){if(!this.#z)return null;let t=this.#Ae().width,n;if(n=this.#u===`half`?e.x>t/2?`right`:`left`:e.x<=this.#d?`left`:e.x>=t-this.#d?`right`:null,!n)return null;let r=this.#a===`rtl`?`left`:`right`;return n===r?`forward`:`backward`}#Ne(){this.#K!==null&&(clearTimeout(this.#K),this.#K=null)}#Pe(){let e=this.#T[this.#E];e&&this.#tt(e,this.#O),this.#i.send(`settle`),this.#n.emit(`flipEnd`,{page:this.#D}),this.#_e()}#Fe(){if(this.#W=null,this.#Ne(),this.#U){this.#U=null,this.#i.send(`release`),this.#i.send(`settle`);let e=this.#T[this.#E];e&&this.#tt(e,this.#O)}else this.#X&&(this.#X=null,this.#i.send(`panEnd`));this.#Z=!0,this.#Q=this.#I}#Ie(e,t,n){if(!this.#Z)return;let r=this.#e.getBoundingClientRect();this.setZoom(this.#Q*n,{x:e-r.left,y:t-r.top})}#Le(){this.#Z=!1}#Re(){if(!this.#S)return;let e=e=>e.preventDefault();this.#e.addEventListener(`contextmenu`,e),this.#re=()=>this.#e.removeEventListener(`contextmenu`,e)}#ze(){let e=e=>{if(!this.#j||!this.#A||!(e.ctrlKey||e.metaKey))return;e.preventDefault();let t=this.#e.getBoundingClientRect(),n=Math.exp(-e.deltaY*hn);this.setZoom(this.#I*n,{x:e.clientX-t.left,y:e.clientY-t.top})};this.#e.addEventListener(`wheel`,e,{passive:!1}),this.#ne=()=>this.#e.removeEventListener(`wheel`,e)}#Be(){let e=e=>{let t=this.#M;if(!this.#A||t===null||!this.#z)return;if(this.#I<=1&&this.#u!==`off`&&!this.#f){let t=this.#je(e.clientX,e.clientY);if(this.#Me(t)!==null)return}this.#Ne(),e.preventDefault();let n=t.find(e=>e>this.#I+1e-6)??t[0]??this.#I,r=this.#e.getBoundingClientRect();this.setZoom(n,{x:e.clientX-r.left,y:e.clientY-r.top})};this.#e.addEventListener(`dblclick`,e),this.#ie=()=>this.#e.removeEventListener(`dblclick`,e)}async#Ve(e){let t=dt(e);typeof this.#t.open==`function`&&(await this.#t.open(),this.#mt()),this.#t.prefetch([this.#D]);let n=await t,r=await this.#He(n);this.#z=r,this.#t.onPageUpdate?.(e=>this.#rt(e)),this.#Qe(r.measure().containerWidth);let i=new p({onStart:e=>this.#we(e.x,e.y),onMove:e=>this.#De(e.dx,e.dy),onEnd:e=>this.#Oe(e)}),a=new g({onPinchStart:()=>this.#Fe(),onPinchMove:e=>this.#Ie(e.centerX,e.centerY,e.scale),onPinchEnd:()=>this.#Le()});this.#te=m(this.#e,{pointer:i,pinch:a}),this.#ze(),this.#Be(),this.#Re(),this.#We(),this.#ae=this.#qe(),await this.#et(),this.#ct(),this.#ft(),this.#Ye(),this.#Ke(),await this.#Ge(),this.#n.emit(`ready`)}async#He(e){try{return await e.mount(this.#e),e.onFatal?.(()=>{this.#Ue()}),e}catch{e.destroy();let t=await dt(`css`);return await t.mount(this.#e),this.#B=!0,this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`}),t}}async#Ue(){if(this.#B||this.#V)return;this.#B=!0,this.#z?.destroy(),this.#z=null;let e=await dt(`css`);if(this.#V){e.destroy();return}await e.mount(this.#e),this.#z=e,this.#Qe(e.measure().containerWidth),await this.#et(),this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`})}#We(){if(typeof matchMedia!=`function`)return;let e=matchMedia(`(prefers-reduced-motion: reduce)`);this.#$=e.matches,e.addEventListener?.(`change`,e=>{this.#$=e.matches})}async#Ge(){if(this.#ce===!1||this.#V)return;let e=this.#e;if(!(!e.ownerDocument||typeof e.appendChild!=`function`))try{let{mountControls:t}=await Promise.resolve().then(()=>(pn(),dn));if(this.#V)return;let n=this.#ce===!0?{}:this.#ce;this.#le=t(this,e,n)}catch{}}#Ke(){if(!this.#x||globalThis.location===void 0)return;let e=globalThis;this.#C=w(e,e=>{e!==this.#D&&this.flipTo(e)}),this.#C.push(this.#D),this.#w=this.#n.on(`pageChanged`,({page:e})=>{this.#C?.push(e)})}pageLink(e=this.#D){let t=globalThis.location?.href??``;if(!t)return``;let n=new URL(t);return n.hash=C(n.hash,Q(e,0,Math.max(0,this.#t.pageCount-1))),n.toString()}#qe(){let e=this.#e,t=e.ownerDocument;if(!t||typeof e.setAttribute!=`function`)return null;e.hasAttribute(`tabindex`)||(e.tabIndex=0),e.setAttribute(`aria-roledescription`,`flipbook`);let n=e=>this.#Je(e);e.addEventListener(`keydown`,n);let r=t.createElement(`div`);return r.setAttribute(`aria-live`,`polite`),r.setAttribute(`aria-atomic`,`true`),r.style.cssText=`position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;`,e.appendChild(r),this.#ee=r,()=>{e.removeEventListener(`keydown`,n),r.remove(),this.#ee=null}}#Je(e){let t=this.#a===`rtl`?`ArrowLeft`:`ArrowRight`;switch(e.key){case`ArrowRight`:case`ArrowLeft`:e.key===t?this.flipNext():this.flipPrev(),e.preventDefault();break;case`Home`:this.flipTo(0),e.preventDefault();break;case`End`:this.flipTo(this.#t.pageCount-1),e.preventDefault();break;default:break}}#Ye(){this.#ee&&(this.#ee.textContent=`Page ${this.#D+1} of ${this.#t.pageCount}`)}#Xe(){return this.#$?0:this.#k*(this.#h?vn:1)}update(){!this.#z||this.#i.state!==`idle`||(this.#Qe(this.#z.measure().containerWidth),this.#et())}#Ze(){return this.#_||this.#o===`single`?`single`:this.#o}#Qe(e){let t=this.#v&&a(e,this.#m);t!==this.#_&&(this.#_=t,this.#$e())}#$e(){let e=this.#Ze(),t=e!==this.#g;this.#g=e,this.#h=e===`single`,this.#T=i(this.#t.pageCount,{direction:this.#a,mode:e}),this.#E=this.#pt(this.#D),t&&this.#n.emit(`spreadChanged`,{mode:e,singlePage:this.#h})}async#et(){let e=this.#T[this.#E];!e||!this.#z||(this.#O=await this.#ut(e),this.#tt(e,this.#O))}#tt(e,t){this.#z?.renderSpread(e,t,{fill:this.#h}),this.#nt(),this.#ue?.clear(),this.#it()}#nt(){let e=this.#z?.measure().book;if(!e||e.width<=0||e.height<=0)return;let t=(e.width/e.height).toFixed(4);t!==this.#y&&(this.#y=t,this.#e.style.aspectRatio=t)}#rt(e){if(this.#i.state!==`idle`){this.#se.add(e);return}let t=this.#T[this.#E];t&&(t.left===e||t.right===e)&&this.#et()}#it(){if(this.#fe!==null&&clearTimeout(this.#fe),this.#I<=1){this.#ue?.clear(),this.#de++;return}this.#fe=setTimeout(()=>{this.#fe=null,this.#at()},bn)}async#at(){let e=this.#z,t=this.#T[this.#E];if(!e||!t||this.#I<=1)return;let n=e.measure(),r=n.content??n.book;if(!r)return;let i=[],a=t.left===null||t.right===null,o=a?r.width:r.width/2;t.left!==null&&i.push({index:t.left,rect:{...r,width:o}}),t.right!==null&&i.push({index:t.right,rect:{...r,x:r.x+(a?0:o),width:o}});let s={scale:this.#I,tx:this.#L,ty:this.#R},c={x:0,y:0,width:n.containerWidth,height:n.containerHeight},l=pt(i,s,c),u=this.#ue?.shown??[];if(l.length===u.length&&l.every((e,t)=>mt(e,u[t])))return;let d=++this.#de,f=await Promise.all(l.map(async e=>{try{let t=await this.#t.get(e.index,e.request),n=e.dest.width/e.dest.height*1,r=t.width/t.height;return Math.abs(n-r)/n>.02?null:{plan:e,content:t}}catch(t){return this.#n.emit(`sourceError`,{index:e.index,error:t}),null}}));if(d!==this.#de||this.#I<=1)return;let p=f.filter(e=>e!==null);p.length!==0&&(this.#ue??=this.#ot(),this.#ue?.draw(p,s,c))}#ot(){let e=this.#e.ownerDocument;return!e||typeof this.#e.append!=`function`?null:new ht(e,this.#e)}#st(){if(this.#se.size===0)return;let e=this.#T[this.#E],t=e!==void 0&&[e.left,e.right].some(e=>e!==null&&this.#se.has(e));this.#se.clear(),t&&this.#et()}#ct(){typeof ResizeObserver>`u`||(this.#P=new ResizeObserver(()=>this.#lt()),this.#P.observe(this.#e))}#lt(){this.#F||(this.#F=!0,requestAnimationFrame(()=>{this.#F=!1,this.update()}))}async#ut(e){let[t,n]=await Promise.all([this.#dt(e.left),this.#dt(e.right)]);return{left:t,right:n}}async#dt(e){if(e===null)return null;try{return await this.#t.get(e)}catch(t){return this.#n.emit(`sourceError`,{index:e,error:t}),null}}#ft(){let{toMount:e}=this.#r.update(this.#E,this.#T.length),t=[];for(let n of e){let e=this.#T[n];e?.left!=null&&t.push(e.left),e?.right!=null&&t.push(e.right)}this.#t.prefetch(t)}#pt(e){let t=this.#T.findIndex(t=>t.left===e||t.right===e);return t===-1?0:t}#mt(){let e=this.#t.pageCount;if(!Number.isInteger(e)||e<1)throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);let t=this.#b;if(t!==void 0&&(!Number.isInteger(t)||t<0||t>=e))throw Error(`Zine: startPage ${JSON.stringify(t)} is out of range for a ${e}-page book (valid 0..${e-1}).`);let n=this.#Ze();this.#h=n===`single`,this.#T=i(e,{direction:this.#a,mode:n});let r=this.#x?S(globalThis.location?.hash??``):null;this.#D=Q(r??t??0,0,e-1),this.#E=this.#pt(this.#D)}};function Q(e,t,n){return e<t?t:e>n?n:e}function Cn(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function wn(e){return 1-(1-Cn(e))**1.3}function Tn(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function En(e,t){if(typeof e!=`object`||!e||typeof e.appendChild!=`function`||typeof e.addEventListener!=`function`)throw Error(`Zine: container must be a DOM element; received ${Tn(e)}.`);if(typeof t!=`object`||!t)throw Error("Zine: an options object with a `source` is required.");let n=t,r=n.source;if(typeof r!=`object`||!r||typeof r.get!=`function`||typeof r.pageCount!=`number`)throw Error("Zine: `source` is required and must be a Source, e.g. new ImageSource(urls).");let i=n.startPage;if(i!==void 0&&(typeof i!=`number`||!Number.isInteger(i)||i<0))throw Error(`Zine: startPage must be a non-negative integer; got ${JSON.stringify(i)}.`);let a=n.direction;if(a!==void 0&&a!==`ltr`&&a!==`rtl`)throw Error(`Zine: direction must be 'ltr' or 'rtl'; got ${JSON.stringify(a)}.`);let o=n.clickToFlip;if(o!==void 0&&![`edge`,`half`,`off`].includes(o))throw Error(`Zine: clickToFlip must be 'edge', 'half', or 'off'; got ${JSON.stringify(o)}.`);let s=n.curl;if(s!==void 0&&!T.includes(s))throw Error(`Zine: curl must be one of ${T.join(`, `)}; got ${JSON.stringify(s)}.`);for(let e of[`deepLink`,`disableContextMenu`,`responsiveSpread`])if(n[e]!==void 0&&typeof n[e]!=`boolean`)throw Error(`Zine: ${e} must be a boolean; got ${Tn(n[e])}.`);let c=n.controls;if(c!==void 0&&typeof c!=`boolean`&&(typeof c!=`object`||!c))throw Error(`Zine: controls must be a boolean or an options object; got ${Tn(c)}.`);let l=c?.position;if(l!==void 0&&![`top`,`bottom`,`left`,`right`].includes(l))throw Error(`Zine: controls.position must be 'top', 'bottom', 'left', or 'right'; got ${JSON.stringify(l)}.`);let u=n.spreadMode;if(u!==void 0&&![`double`,`single`,`cover`,`book`].includes(u))throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(u)}.`);for(let e of[`frontCover`,`backCover`]){let t=n[e];if(t!==void 0&&typeof t!=`string`)throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`)}let d=n.pages;if(d!==void 0&&(typeof d!=`object`||!d||Array.isArray(d)))throw Error(`Zine: pages must be an object mapping page indices to image URLs.`);$(n.width,`width`,1),$(n.height,`height`,1),$(n.flipDuration,`flipDuration`,0),$(n.clickZoneSize,`clickZoneSize`,0),$(n.clickFlipDelay,`clickFlipDelay`,0),$(n.singlePageThreshold,`singlePageThreshold`,0),Dn(n.zoom),On(n.renderer)}function $(e,t,n){if(e!==void 0&&(typeof e!=`number`||!Number.isFinite(e)||e<n))throw Error(`Zine: ${t} must be a number >= ${n}; got ${JSON.stringify(e)}.`)}function Dn(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Zine: zoom must be an object, e.g. { max: 4 }.`);let t=e;if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)throw Error(`Zine: zoom.enabled must be a boolean; got ${JSON.stringify(t.enabled)}.`);if(t.wheel!==void 0&&typeof t.wheel!=`boolean`)throw Error(`Zine: zoom.wheel must be a boolean; got ${JSON.stringify(t.wheel)}.`);if(t.doubleClickInFlipZone!==void 0&&typeof t.doubleClickInFlipZone!=`boolean`)throw Error(`Zine: zoom.doubleClickInFlipZone must be a boolean; got ${JSON.stringify(t.doubleClickInFlipZone)}.`);if(t.doubleClick!==void 0&&t.doubleClick!==!1){let e=t.doubleClick;if(!Array.isArray(e)||e.some(e=>typeof e!=`number`||!Number.isFinite(e)||e<1))throw Error(`Zine: zoom.doubleClick must be false or an array of zoom levels >= 1, e.g. [1, 2, 4].`)}$(t.max,`zoom.max`,1)}function On(e){if(e!==void 0){if(typeof e==`string`){if(e!==`auto`&&e!==`css`&&e!==`webgl2`)throw Error(`Zine: renderer '${e}' is not recognized; use 'auto', 'css', 'webgl2', an array of those, or a custom Renderer.`);return}if(Array.isArray(e)){for(let t of e)if(t!==`css`&&t!==`webgl2`)throw Error(`Zine: renderer order array may only contain 'css' or 'webgl2'; got ${JSON.stringify(t)}.`);return}if(!(typeof e==`object`&&e&&typeof e.mount==`function`))throw Error(`Zine: renderer must be 'auto', 'css', 'webgl2', an array of those, or a custom Renderer instance.`)}}var kn=class{pageCount;fit;#e;#t;#n=new Map;constructor(e,t={}){this.#e=e,this.pageCount=e.length,this.#t=t.preload??1,this.fit=t.fit??`contain`}get(e){let t=this.#r(e);for(let t=1;t<=this.#t;t++)this.prefetch([e-t,e+t]);return t}prefetch(e){for(let t of e)t>=0&&t<this.pageCount&&this.#r(t).catch(()=>{})}destroy(){for(let e of this.#n.values())e.then(e=>e.close()).catch(()=>{});this.#n.clear()}#r(e){let t=this.#n.get(e);if(t)return t;let n=this.#e[e];if(n===void 0)return Promise.reject(RangeError(`ImageSource: page ${e} is out of range (0..${this.pageCount-1}).`));let r=(async()=>{let t=await fetch(n);if(!t.ok)throw Error(`ImageSource: failed to fetch page ${e} (${n}) — HTTP ${t.status}.`);return createImageBitmap(await t.blob())})().catch(t=>{throw this.#n.delete(e),t});return this.#n.set(e,r),r}};H(),D(),e.CURL_TYPES=T,e.DEFAULT_ITEMS=V,e.ImageSource=kn,e.Zine=Sn,e.defineControl=z,e.getControl=yt});
91
533
  //# sourceMappingURL=index.umd.js.map