@zinejs/core 0.7.4 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -91,7 +91,7 @@ void main() {
91
91
  // Premultiplied alpha (blendFunc ONE, ONE_MINUS_SRC_ALPHA): scale colour as well as alpha,
92
92
  // or fading would brighten the sheet additively instead of dissolving it.
93
93
  outColor = vec4(c.rgb * uAlpha, c.a * uAlpha);
94
- }`,Re=28,ze=36,Be=.7,Ve=.8,He=4e3,Ue=256*1024*1024,We=class{#e=null;#t=null;#n=null;#r=null;#i=null;#a=null;#o=null;#s=null;#c=null;#l=0;#u=ce(Re,ze);#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=A[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=Te(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=xe(r.curl)),r?.anchor&&(this.#C=r.anchor),this.#T=i?0:j(e),this.#E=i?0:j(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,o=a?e=>{let t=this.#w/this.#_;return{x:(a.x-t)*e+t,y:a.y*e,width:a.width*e,height:a.height*e}}:void 0;return{containerWidth:t,containerHeight:n,pageWidth:t/2,pageHeight:n,book:i,content:a,screenAt:o}}#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&&j(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(),He))};#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=De(e,Pe,Fe),this.#i=De(e,Ie,Le);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`,`uCrease`])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<ze;e++)for(let t=0;t<Re;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:j(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;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.gloss===!1?0:1),e.uniform1f(this.#h.uAlpha??null,r.fill?this.#Y():1),e.uniform1f(this.#h.uCrease??null,r.fill?Math.min(1,this.#x/.2):1),e.drawElements(e.TRIANGLES,this.#l,e.UNSIGNED_SHORT,0)}#Y(){let e=this.#S.flat?Be:Ve,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=Ae(t);je(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<=Ue||this.#d.size<=4)break;this.#d.delete(t),this.#f-=n.bytes,e.deleteTexture(n.tex)}}#te(e){let t=Ae(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))}}})),Ke={css:async()=>new(await(Promise.resolve().then(()=>(se(),ne)))).CssRenderer,webgl2:async()=>new(await(Promise.resolve().then(()=>(Ge(),Ne)))).WebglRenderer},qe=!0;function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.mount==`function`}function Ye(e){return e.gpu&&qe?[`webgl2`,`css`]:[`css`]}function Xe(){return{gpu:Ze()}}function Ze(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)}catch{return!1}}async function M(e=`auto`,t=Xe()){if(Je(e))return e;let n=Array.isArray(e)?e:e===`auto`?Ye(t):[e];for(let e of n){if(e===`webgl2`&&!t.gpu)continue;let n=Ke[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 Qe(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 et(e,t)}function $e(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 et=class{#e;#t;#n;#r;#i=new Map;#a=new Map;open;onPageUpdate;onProgress;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.onProgress==`function`&&(this.onProgress=t=>e.onProgress(t)),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=$e(e).catch(t=>{throw this.#a.delete(e),t}),this.#a.set(e,t)),t}},tt=r({CSS:()=>P,mountLoading:()=>rt});function nt(e){if(e.getElementById(N))return;let t=e.createElement(`style`);t.id=N,t.textContent=P,(e.head??e.documentElement)?.appendChild(t)}function rt(e){let t=e.ownerDocument;nt(t);let n=t.createElement(`div`);n.className=`zine-loading`,n.setAttribute(`role`,`status`),n.setAttribute(`aria-live`,`polite`);let r=t.createElement(`div`);r.className=`zine-loading-spinner`,r.setAttribute(`aria-hidden`,`true`);let i=t.createElement(`div`);i.className=`zine-loading-text`,i.textContent=`Opening document…`;let a=t.createElement(`div`);a.className=`zine-loading-bar`,a.style.display=`none`;let o=t.createElement(`div`);o.className=`zine-loading-fill`,a.appendChild(o),n.append(r,i,a),e.appendChild(n);let s=null,c=typeof globalThis.getComputedStyle==`function`?globalThis.getComputedStyle(e):null;(!c||c.position===`static`||c.position===``)&&(s=e.style.position,e.style.position=`relative`);let l=!1,u=setTimeout(()=>{l=!0,n.classList.add(`zine-loading-shown`)},it);return{update(e){if(e.total>0){let t=Math.min(100,Math.round(e.loaded/e.total*100));i.textContent=`Downloading document… ${t}%`,a.style.display=``,o.style.width=`${t}%`}else i.textContent=`Downloading document… ${at(e.loaded)}`,a.style.display=`none`},preparing(){i.textContent=`Preparing pages…`,a.style.display=`none`},destroy(){l||clearTimeout(u),n.remove(),s!==null&&(e.style.position=s)}}}var N,it,P,at,ot=n((()=>{N=`zine-loading-style`,it=150,P=`
94
+ }`,Re=28,ze=36,Be=.7,Ve=.8,He=4e3,Ue=256*1024*1024,We=class{#e=null;#t=null;#n=null;#r=null;#i=null;#a=null;#o=null;#s=null;#c=null;#l=0;#u=ce(Re,ze);#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=A[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=Te(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=xe(r.curl)),r?.anchor&&(this.#C=r.anchor),this.#T=i?0:j(e),this.#E=i?0:j(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,o=a?e=>{let t=this.#w/this.#_;return{x:(a.x-t)*e+t,y:a.y*e,width:a.width*e,height:a.height*e}}:void 0;return{containerWidth:t,containerHeight:n,pageWidth:t/2,pageHeight:n,book:i,content:a,screenAt:o}}#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&&j(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(),He))};#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=De(e,Pe,Fe),this.#i=De(e,Ie,Le);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`,`uCrease`])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<ze;e++)for(let t=0;t<Re;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:j(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;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.gloss===!1?0:1),e.uniform1f(this.#h.uAlpha??null,r.fill?this.#Y():1),e.uniform1f(this.#h.uCrease??null,r.fill?Math.min(1,this.#x/.2):1),e.drawElements(e.TRIANGLES,this.#l,e.UNSIGNED_SHORT,0)}#Y(){let e=this.#S.flat?Be:Ve,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=Ae(t);je(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<=Ue||this.#d.size<=4)break;this.#d.delete(t),this.#f-=n.bytes,e.deleteTexture(n.tex)}}#te(e){let t=Ae(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))}}})),Ke={css:async()=>new(await(Promise.resolve().then(()=>(se(),ne)))).CssRenderer,webgl2:async()=>new(await(Promise.resolve().then(()=>(Ge(),Ne)))).WebglRenderer},qe=!0;function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.mount==`function`}function Ye(e){return e.gpu&&qe?[`webgl2`,`css`]:[`css`]}function Xe(){return{gpu:Ze()}}function Ze(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)}catch{return!1}}async function Qe(e=`auto`,t=Xe()){if(Je(e))return e;let n=Array.isArray(e)?e:e===`auto`?Ye(t):[e];for(let e of n){if(e===`webgl2`&&!t.gpu)continue;let n=Ke[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 $e(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 tt(e,t)}function et(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 tt=class{#e;#t;#n;#r;#i=new Map;#a=new Map;open;onPageUpdate;onProgress;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.onProgress==`function`&&(this.onProgress=t=>e.onProgress(t)),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=et(e).catch(t=>{throw this.#a.delete(e),t}),this.#a.set(e,t)),t}},nt=r({CSS:()=>N,mountLoading:()=>it});function rt(e){if(e.getElementById(M))return;let t=e.createElement(`style`);t.id=M,t.textContent=N,(e.head??e.documentElement)?.appendChild(t)}function it(e){let t=e.ownerDocument;rt(t);let n=t.createElement(`div`);n.className=`zine-loading`,n.setAttribute(`role`,`status`),n.setAttribute(`aria-live`,`polite`);let r=t.createElement(`div`);r.className=`zine-loading-spinner`,r.setAttribute(`aria-hidden`,`true`);let i=t.createElement(`div`);i.className=`zine-loading-text`,i.textContent=`Opening document…`;let a=t.createElement(`div`);a.className=`zine-loading-bar`,a.style.display=`none`;let o=t.createElement(`div`);o.className=`zine-loading-fill`,a.appendChild(o),n.append(r,i,a),e.appendChild(n);let s=null,c=typeof globalThis.getComputedStyle==`function`?globalThis.getComputedStyle(e):null;(!c||c.position===`static`||c.position===``)&&(s=e.style.position,e.style.position=`relative`);let l=!1,u=setTimeout(()=>{l=!0,n.classList.add(`zine-loading-shown`)},at);return{update(e){if(e.total>0){let t=Math.min(100,Math.round(e.loaded/e.total*100));i.textContent=`Downloading document… ${t}%`,a.style.display=``,o.style.width=`${t}%`}else i.textContent=`Downloading document… ${ot(e.loaded)}`,a.style.display=`none`},preparing(){i.textContent=`Preparing pages…`,a.style.display=`none`},destroy(){l||clearTimeout(u),n.remove(),s!==null&&(e.style.position=s)}}}var M,at,N,ot,st=n((()=>{M=`zine-loading-style`,at=150,N=`
95
95
  .zine-loading {
96
96
  position: absolute;
97
97
  inset: 0;
@@ -105,8 +105,8 @@ void main() {
105
105
  box-sizing: border-box;
106
106
  text-align: center;
107
107
  font: 500 14px/1.4 system-ui, sans-serif;
108
- color: var(--zine-loading-fg, #d4d4d8);
109
- background: var(--zine-loading-bg, #0c0c11);
108
+ color: var(--zine-loading-fg, light-dark(#3f3f46, #d4d4d8));
109
+ background: var(--zine-loading-bg, light-dark(#fafafa, #0c0c11));
110
110
  border-radius: inherit;
111
111
  opacity: 0;
112
112
  transition: opacity 150ms ease;
@@ -115,8 +115,8 @@ void main() {
115
115
  .zine-loading-spinner {
116
116
  width: 32px;
117
117
  height: 32px;
118
- border: 3px solid var(--zine-loading-track, rgba(255, 255, 255, 0.14));
119
- border-top-color: var(--zine-loading-accent, #7dd3fc);
118
+ border: 3px solid var(--zine-loading-track, light-dark(rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0.14)));
119
+ border-top-color: var(--zine-loading-accent, light-dark(#0284c7, #7dd3fc));
120
120
  border-radius: 50%;
121
121
  animation: zine-loading-spin 0.8s linear infinite;
122
122
  }
@@ -125,14 +125,14 @@ void main() {
125
125
  .zine-loading-bar {
126
126
  width: min(240px, 70%);
127
127
  height: 6px;
128
- background: var(--zine-loading-track, rgba(255, 255, 255, 0.14));
128
+ background: var(--zine-loading-track, light-dark(rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0.14)));
129
129
  border-radius: 3px;
130
130
  overflow: hidden;
131
131
  }
132
132
  .zine-loading-fill {
133
133
  width: 0;
134
134
  height: 100%;
135
- background: var(--zine-loading-accent, #7dd3fc);
135
+ background: var(--zine-loading-accent, light-dark(#0284c7, #7dd3fc));
136
136
  border-radius: 3px;
137
137
  transition: width 150ms ease-out;
138
138
  }
@@ -141,7 +141,7 @@ void main() {
141
141
  .zine-loading-spinner { animation-duration: 2s; }
142
142
  .zine-loading-fill { transition: none; }
143
143
  }
144
- `,at=e=>`${(e/1024/1024).toFixed(1)} MB`}));function F(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 I,L=n((()=>{I={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 R(e){return z.set(e.id,e),e}function st(e){return z.get(e)}function ct(e){if(typeof e==`string`){let t=z.get(e);if(!t)throw Error(`controls: unknown control '${e}'. Register it with defineControl() or pass a definition object.`);return t}let t=z.get(e.id);return t?{...t,...e}:e}var z,B,V=n((()=>{z=new Map,B=[`prev`,`pageInput`,`next`,`|`,`zoomOut`,`zoomIn`,`search`,`share`,`menu`,`fullscreen`]})),H,lt,ut=n((()=>{H=encodeURIComponent,lt=[{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=${H(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=${H(e)}&text=${H(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=${H(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=${H(`${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=${H(e)}&description=${H(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=${H(t)}&body=${H(e)}`}]}));function dt(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]^J(t[r],K[n]);t=e}return t}function ft(e,t){let n=dt(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]^J(n[i+1],e)}return r}function pt(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 U(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));Y(e,a,o,s!==2&&s<=3)}}function mt(e){let t=new TextEncoder().encode(e),n=W.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=W[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=_t[n-1],c=gt[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(ft(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)};U(h,0,0),U(h,m-7,0),U(h,0,m-7);for(let e=8;e<m-8;e++){let t=e%2==0;Y(h,e,6,t),Y(h,6,e,t)}for(let e of G[n-1])for(let t of G[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++)Y(h,e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1);Y(h,8,m-8,!0);for(let e=0;e<9;e++)e!==6&&(Y(h,e,8,!1),Y(h,8,e,!1));for(let e=0;e<8;e++)Y(h,m-1-e,8,!1),Y(h,8,m-1-e,!1);Y(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),Y(h,r,i,a,!1)}}let v=pt(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;Y(h,n,8,t),Y(h,8,r,t),e<8?Y(h,m-1-e,8,t):Y(h,8,m-15+e,t)}return Y(h,8,m-8,!0),{size:m,modules:h.modules}}function ht(e,t){let{size:n,modules:r}=mt(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 W,gt,_t,G,K,q,J,Y,vt=n((()=>{W=[16,28,44,64,86,108,124,154,182,216],gt=[10,16,26,18,24,16,18,22,22,26],_t=[1,1,1,2,2,4,4,4,5,5],G=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],K=new Uint8Array(512),q=new Uint8Array(256);for(let e=0,t=1;e<255;e++)K[e]=t,q[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)K[e]=K[e-255];J=(e,t)=>e===0||t===0?0:K[(q[e]+q[t])%255],Y=(e,t,n,r,i=!0)=>{e.modules[n*e.size+t]=+!!r,i&&(e.reserved[n*e.size+t]=1)}})),yt=r({ShareDialog:()=>St}),bt,xt,St,Ct=n((()=>{L(),ut(),vt(),bt=132,xt=1600,St=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(F(n,I.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=ht(t,bt),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`},xt)}#l(e,t,n){let r=e.createElement(`div`);r.className=`zine-share-socials`;for(let i of lt){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(F(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 wt(){R({id:`prev`,title:`Previous page`,icon:I.prev,isDisabled:e=>!e.zine.canFlipPrev(),action:e=>e.zine.flipPrev()}),R({id:`next`,title:`Next page`,icon:I.next,isDisabled:e=>!e.zine.canFlipNext(),action:e=>e.zine.flipNext()});let e=e=>e.zine.getDirection()===`rtl`;R({id:`first`,title:`First page`,icon:t=>e(t)?I.last:I.first,isDisabled:e=>!e.zine.canFlipPrev(),action:e=>{e.zine.flipTo(0),e.close()}}),R({id:`last`,title:`Last page`,icon:t=>e(t)?I.first:I.last,isDisabled:e=>!e.zine.canFlipNext(),action:e=>{e.zine.flipTo(e.zine.getPageCount()-1),e.close()}}),R({id:`zoomIn`,title:`Zoom in`,icon:I.zoomIn,isDisabled:e=>e.zine.getZoom()>=e.zine.getMaxZoom()-1e-6,action:e=>e.zine.setZoom(e.zine.getZoom()*Tt)}),R({id:`zoomOut`,title:`Zoom out`,icon:I.zoomOut,isDisabled:e=>e.zine.getZoom()<=1.000001,action:e=>e.zine.setZoom(e.zine.getZoom()/Tt)}),R({id:`fullscreen`,title:`Fullscreen`,icon:I.fullscreen,isVisible:e=>typeof e.zine.container.requestFullscreen==`function`,isActive:Et,action:e=>{let t=e.zine.container.ownerDocument;Et(e)?t?.exitFullscreen?.():e.zine.container.requestFullscreen?.(),e.close()}}),R({id:`share`,title:`Share`,icon:I.share,action:e=>{e.close(),Promise.resolve().then(()=>(Ct(),yt)).then(({ShareDialog:t})=>new t(e.zine,e.zine.container)).catch(()=>{navigator.clipboard?.writeText(e.zine.pageLink()).catch(()=>{})})}}),R({id:`download`,title:`Download PDF`,icon:I.download,isVisible:e=>e.zine.canDownload(),action:e=>{e.zine.download(),e.close()}}),R({id:`spread`,title:e=>e.zine.isSinglePage()?`Show two pages`:`Show one page`,icon:e=>e.zine.isSinglePage()?I.twoPages:I.onePage,isVisible:e=>!e.zine.isResponsiveSingle(),action:e=>{e.zine.toggleSpreadMode(),e.close()}}),R({id:`print`,title:`Print`,icon:I.print,isVisible:e=>e.zine.canPrint(),action:e=>{e.zine.print(),e.close()}}),R({id:`menu`,title:`More`,icon:I.menu,children:[`first`,`last`,`spread`,`thumbnails`,`outline`,`print`,`download`]})}var Tt,Et,Dt=n((()=>{L(),V(),Tt=Math.SQRT2,Et=e=>e.zine.container.ownerDocument?.fullscreenElement===e.zine.container}));function Ot(e){if(e.getElementById(kt))return;let t=e.createElement(`style`);t.id=kt,t.textContent=At,(e.head??e.documentElement)?.appendChild(t)}var kt,At,jt=n((()=>{kt=`zine-controls-style`,At=`
144
+ `,ot=e=>`${(e/1024/1024).toFixed(1)} MB`}));function P(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 F,I=n((()=>{F={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 L(e){return R.set(e.id,e),e}function ct(e){return R.get(e)}function lt(e){if(typeof e==`string`){let t=R.get(e);if(!t)throw Error(`controls: unknown control '${e}'. Register it with defineControl() or pass a definition object.`);return t}let t=R.get(e.id);return t?{...t,...e}:e}var R,z,B=n((()=>{R=new Map,z=[`prev`,`pageInput`,`next`,`|`,`zoomOut`,`zoomIn`,`search`,`share`,`menu`,`fullscreen`]})),V,ut,dt=n((()=>{V=encodeURIComponent,ut=[{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=${V(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=${V(e)}&text=${V(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=${V(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=${V(`${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=${V(e)}&description=${V(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=${V(t)}&body=${V(e)}`}]}));function ft(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]^q(t[r],G[n]);t=e}return t}function pt(e,t){let n=ft(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]^q(n[i+1],e)}return r}function mt(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 H(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));J(e,a,o,s!==2&&s<=3)}}function ht(e){let t=new TextEncoder().encode(e),n=U.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=U[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=vt[n-1],c=_t[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(pt(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)};H(h,0,0),H(h,m-7,0),H(h,0,m-7);for(let e=8;e<m-8;e++){let t=e%2==0;J(h,e,6,t),J(h,6,e,t)}for(let e of W[n-1])for(let t of W[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++)J(h,e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1);J(h,8,m-8,!0);for(let e=0;e<9;e++)e!==6&&(J(h,e,8,!1),J(h,8,e,!1));for(let e=0;e<8;e++)J(h,m-1-e,8,!1),J(h,8,m-1-e,!1);J(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),J(h,r,i,a,!1)}}let v=mt(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;J(h,n,8,t),J(h,8,r,t),e<8?J(h,m-1-e,8,t):J(h,8,m-15+e,t)}return J(h,8,m-8,!0),{size:m,modules:h.modules}}function gt(e,t){let{size:n,modules:r}=ht(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 U,_t,vt,W,G,K,q,J,yt=n((()=>{U=[16,28,44,64,86,108,124,154,182,216],_t=[10,16,26,18,24,16,18,22,22,26],vt=[1,1,1,2,2,4,4,4,5,5],W=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],G=new Uint8Array(512),K=new Uint8Array(256);for(let e=0,t=1;e<255;e++)G[e]=t,K[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)G[e]=G[e-255];q=(e,t)=>e===0||t===0?0:G[(K[e]+K[t])%255],J=(e,t,n,r,i=!0)=>{e.modules[n*e.size+t]=+!!r,i&&(e.reserved[n*e.size+t]=1)}}));function bt(e){if(e.getElementById(xt))return;let t=e.createElement(`style`);t.id=xt,t.textContent=St,(e.head??e.documentElement)?.appendChild(t)}function Y(e,t){t!==`auto`&&(e.style.colorScheme=t)}var xt,St,Ct=n((()=>{xt=`zine-controls-style`,St=`
145
145
  /* Docked mode wraps the book so the bar can sit beside it without shrinking the container,
146
146
  whose measured box the renderer and hit-testing both depend on.
147
147
  The wrapper deliberately does not stretch or grow its children: the container keeps whatever
@@ -167,7 +167,7 @@ void main() {
167
167
  z-index: 2;
168
168
  box-sizing: border-box;
169
169
  font: 500 12px/1.2 system-ui, sans-serif;
170
- color: var(--zine-controls-fg, #f4f4f5);
170
+ color: var(--zine-controls-fg, light-dark(#18181b, #f4f4f5));
171
171
  touch-action: auto;
172
172
  -webkit-user-select: none;
173
173
  user-select: none;
@@ -185,14 +185,14 @@ void main() {
185
185
  padding: 3px;
186
186
  border-radius: 8px;
187
187
  pointer-events: auto;
188
- background: var(--zine-controls-bg, rgba(24, 24, 27, 0.82));
188
+ background: var(--zine-controls-bg, light-dark(rgba(255, 255, 255, 0.94), rgba(24, 24, 27, 0.82)));
189
189
  backdrop-filter: blur(8px);
190
190
  }
191
191
  /* Floating: lifted off the page it covers. Docked: flat, with an outline so it reads as a
192
192
  control strip rather than a shadow hanging in empty space. */
193
193
  .zine-controls-floating .zine-controls-bar { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28); }
194
194
  .zine-controls-docked .zine-controls-bar {
195
- border: 1px solid var(--zine-controls-hover, rgba(255, 255, 255, 0.14));
195
+ border: 1px solid var(--zine-controls-hover, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.14)));
196
196
  }
197
197
  .zine-controls-floating.zine-controls-bottom { inset: auto 0 0 0; justify-content: center; }
198
198
  .zine-controls-floating.zine-controls-top { inset: 0 0 auto 0; justify-content: center; }
@@ -217,17 +217,46 @@ void main() {
217
217
  font: inherit;
218
218
  }
219
219
  .zine-controls-btn svg { width: 15px; height: 15px; }
220
- .zine-controls-btn:hover:not(:disabled) { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
220
+ .zine-controls-btn:hover:not(:disabled) { background: var(--zine-controls-hover, light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.14))); }
221
221
  .zine-controls-btn:focus-visible {
222
- outline: 2px solid var(--zine-controls-accent, #7dd3fc);
222
+ outline: 2px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
223
223
  outline-offset: 1px;
224
224
  }
225
225
  .zine-controls-btn:disabled { opacity: 0.38; cursor: default; }
226
+ /* A button mid-slow-action (fetching a file to save or print): a spinner, kept full-strength
227
+ rather than dimmed so it reads as "working", not "disabled". */
228
+ .zine-controls-btn.zine-controls-busy { opacity: 1; cursor: default; position: relative; }
229
+ .zine-controls-btn.zine-controls-busy::after {
230
+ content: '';
231
+ box-sizing: border-box;
232
+ width: 14px;
233
+ height: 14px;
234
+ border: 2px solid currentColor;
235
+ border-top-color: transparent;
236
+ border-radius: 50%;
237
+ opacity: 0.7;
238
+ animation: zine-controls-spin 0.7s linear infinite;
239
+ }
240
+ /* Icon-only bar button: hide the glyph and center the spinner over its place. */
241
+ .zine-controls-btn.zine-controls-busy > svg { visibility: hidden; }
242
+ .zine-controls-btn.zine-controls-busy::after {
243
+ position: absolute;
244
+ top: 50%;
245
+ left: 50%;
246
+ margin: -7px 0 0 -7px;
247
+ }
248
+ /* Menu item (glyph + label): let the glyph and label stand, and trail the spinner after them. */
249
+ .zine-controls-menu .zine-controls-btn.zine-controls-busy > svg { visibility: visible; }
250
+ .zine-controls-menu .zine-controls-btn.zine-controls-busy::after { position: static; }
251
+ @keyframes zine-controls-spin { to { transform: rotate(360deg); } }
252
+ @media (prefers-reduced-motion: reduce) {
253
+ .zine-controls-btn.zine-controls-busy::after { animation-duration: 1.6s; }
254
+ }
226
255
  /* A custom widget cannot always be disabled itself, so it is marked instead and reads the same. */
227
256
  .zine-controls-off { opacity: 0.38; }
228
257
  .zine-controls-off[aria-disabled='true'] { pointer-events: none; }
229
258
  .zine-controls-btn[aria-pressed="true"],
230
- .zine-controls-btn[aria-expanded="true"] { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
259
+ .zine-controls-btn[aria-expanded="true"] { background: var(--zine-controls-hover, light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.14))); }
231
260
 
232
261
  .zine-controls-sep {
233
262
  width: 1px;
@@ -250,9 +279,9 @@ void main() {
250
279
  .zine-controls-page input {
251
280
  width: 2.2em;
252
281
  padding: 2px 3px;
253
- border: 1px solid var(--zine-controls-hover, rgba(255,255,255,0.2));
282
+ border: 1px solid var(--zine-controls-hover, light-dark(rgba(0,0,0,0.14), rgba(255,255,255,0.2)));
254
283
  border-radius: 4px;
255
- background: rgba(0, 0, 0, 0.25);
284
+ background: light-dark(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.25));
256
285
  color: inherit;
257
286
  font: inherit;
258
287
  text-align: center;
@@ -261,7 +290,7 @@ void main() {
261
290
  .zine-controls-page input::-webkit-outer-spin-button,
262
291
  .zine-controls-page input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
263
292
  .zine-controls-page input:focus-visible {
264
- outline: 2px solid var(--zine-controls-accent, #7dd3fc);
293
+ outline: 2px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
265
294
  outline-offset: 0;
266
295
  }
267
296
 
@@ -274,7 +303,7 @@ void main() {
274
303
  padding: 4px;
275
304
  border-radius: 8px;
276
305
  pointer-events: auto;
277
- background: var(--zine-controls-bg, rgba(24, 24, 27, 0.94));
306
+ background: var(--zine-controls-bg, light-dark(rgba(255, 255, 255, 0.94), rgba(24, 24, 27, 0.94)));
278
307
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.36);
279
308
  backdrop-filter: blur(8px);
280
309
  }
@@ -292,17 +321,25 @@ void main() {
292
321
  flex: 0 0 auto;
293
322
  width: 100%;
294
323
  padding: 6px 8px;
295
- border: 1px solid var(--zine-controls-hover, rgba(255,255,255,0.2));
324
+ border: 1px solid var(--zine-controls-hover, light-dark(rgba(0,0,0,0.14), rgba(255,255,255,0.2)));
296
325
  border-radius: 6px;
297
- background: rgba(0, 0, 0, 0.25);
326
+ background: light-dark(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.25));
298
327
  color: inherit;
299
328
  font: inherit;
300
329
  box-sizing: border-box;
301
330
  }
331
+ /* Replace the browser's default (white) focus ring with the accent ring the other controls use. */
332
+ .zine-search-input:focus-visible {
333
+ outline: none;
334
+ border-color: var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
335
+ box-shadow: 0 0 0 1px var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
336
+ }
302
337
  .zine-search-hits {
303
338
  flex: 1 1 auto;
304
339
  overflow-y: auto;
305
- overscroll-behavior: contain;
340
+ /* Chain overscroll up to the page: once the list is at its end (or too short to scroll at all),
341
+ a further wheel scrolls the page behind, the same as scrolling over the book itself does. */
342
+ overscroll-behavior: auto;
306
343
  margin-top: 5px;
307
344
  scrollbar-width: thin;
308
345
  }
@@ -319,9 +356,9 @@ void main() {
319
356
  cursor: pointer;
320
357
  box-sizing: border-box;
321
358
  }
322
- .zine-search-hit:hover { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
359
+ .zine-search-hit:hover { background: var(--zine-controls-hover, light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.14))); }
323
360
  .zine-search-hit:focus-visible {
324
- outline: 2px solid var(--zine-controls-accent, #7dd3fc);
361
+ outline: 2px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
325
362
  outline-offset: -2px;
326
363
  }
327
364
  .zine-search-page { display: block; font-size: 0.9em; opacity: 0.85; }
@@ -347,38 +384,106 @@ void main() {
347
384
  display: inline-flex;
348
385
  align-items: center;
349
386
  justify-content: center;
350
- width: 40px;
351
- height: 40px;
387
+ width: 44px;
388
+ height: 44px;
352
389
  padding: 0;
353
390
  border: 0;
354
- border-radius: 50%;
355
- background: var(--zine-controls-bg, rgba(24, 24, 27, 0.82));
356
- color: var(--zine-controls-fg, #f4f4f5);
391
+ background: none;
392
+ /* Light on a light page, dark on a dark one. The shadow below carries the contrast. */
393
+ color: var(--zine-controls-fg, light-dark(#f4f4f5, #18181b));
357
394
  cursor: pointer;
358
- backdrop-filter: blur(8px);
359
395
  -webkit-user-select: none;
360
396
  user-select: none;
397
+ /* No grey tap box on touch; the :active tint below is the press feedback instead. */
398
+ -webkit-tap-highlight-color: transparent;
399
+ }
400
+ .zine-arrow svg {
401
+ width: 36px;
402
+ height: 36px;
403
+ stroke-width: 2.25;
404
+ /* No backing disc, so a subtle offset shadow keeps the chevron from disappearing into a
405
+ matching background. It contrasts the fill: a light chevron (light mode) casts a soft dark
406
+ shadow, a dark chevron (dark mode) a soft light one, offset rather than a glowing halo. */
407
+ filter: drop-shadow(0 1px 2px light-dark(rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.35)));
408
+ }
409
+ /* Feedback intensifies the chevron toward its extreme (white in light mode, black in dark)
410
+ rather than tinting it, so no new colour is introduced. Not tied to --zine-controls-fg: that
411
+ sets the resting fill, and hover has to differ from it to read as feedback. :active clears on
412
+ release, so tap and click feel the same; :hover is behind (hover: hover) so it never sticks on
413
+ touch. */
414
+ .zine-arrow:active:not(:disabled) { color: light-dark(#ffffff, #000000); }
415
+ @media (hover: hover) {
416
+ .zine-arrow:hover:not(:disabled) { color: light-dark(#ffffff, #000000); }
361
417
  }
362
- .zine-arrow svg { width: 22px; height: 22px; }
363
- .zine-arrow:hover:not(:disabled) { background: var(--zine-controls-hover, rgba(255,255,255,0.22)); }
364
418
  .zine-arrow:focus-visible {
365
- outline: 2px solid var(--zine-controls-accent, #7dd3fc);
419
+ outline: 2px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
366
420
  outline-offset: 2px;
421
+ border-radius: 8px;
367
422
  }
368
423
  /* Nothing to turn to: invisible, but still occupying its slot so the book does not slide across
369
424
  as the reader reaches a cover. */
370
425
  .zine-arrow-hidden { visibility: hidden; }
371
- /* No room to flank on a narrow screen; the toolbar's own prev/next still work. */
426
+ /* Device-scoped arrows (controls.arrows: 'desktop' | 'mobile'). The split follows the same 640px
427
+ breakpoint as the flank/overlay layouts below, so the arrows appear and disappear live as the
428
+ window crosses it. */
372
429
  @media (max-width: 640px) {
373
- .zine-arrow { display: none; }
430
+ .zine-arrows-desktop > .zine-arrow { display: none; }
431
+ }
432
+ @media (min-width: 641px) {
433
+ .zine-arrows-mobile > .zine-arrow { display: none; }
434
+ }
435
+ /* Too narrow to flank without squeezing the pages, so overlay the arrows on the book's edges
436
+ instead. The wrap sits outside the container, so painting them over it leaves the container's
437
+ measured box (which sizes the book and maps taps) untouched. */
438
+ @media (max-width: 640px) {
439
+ .zine-arrows-wrap { position: relative; }
440
+ .zine-arrow {
441
+ position: absolute;
442
+ top: 50%;
443
+ transform: translateY(-50%);
444
+ z-index: 2;
445
+ /* Sit back over the page so the reader can look at the book. */
446
+ opacity: 0.7;
447
+ }
448
+ .zine-arrow:first-child { left: -2px; }
449
+ .zine-arrow:last-child { right: -2px; }
374
450
  }
375
451
  @media (prefers-reduced-motion: no-preference) {
376
452
  .zine-arrow { transition: background 120ms ease; }
377
453
  }
378
454
 
379
- /* Side panels (thumbnails, outline). The rail wraps the book and its docked toolbar so it sits
380
- beside them without shrinking the container the renderer measures. */
381
- .zine-panel-wrap { display: flex; align-items: stretch; gap: 8px; }
455
+ /* Side panels (thumbnails, outline, search). The rail wraps the book and its docked toolbar so it
456
+ sits beside them as a flex sibling. On a wide screen the book shrinks to make room (below); on a
457
+ narrow one the rail becomes a drawer over the book.
458
+ align-items:flex-start, not stretch: the book sizes its height from its width through its own
459
+ aspect-ratio, and that height is 'auto' from flex's point of view, so a stretch would override it
460
+ and blow the book (and the rail matched to it) up to the flex line's cross size. Left as auto, the
461
+ book keeps its aspect height and the holder alone stretches down to meet it (below). */
462
+ .zine-panel-wrap { display: flex; align-items: flex-start; gap: 8px; position: relative; }
463
+
464
+ /* The book-side slot (the bare container, or the docked-toolbar wrapper around it) yields space to
465
+ the fixed-width rail instead of overflowing: flex-shrink lets it fall below its own width, and
466
+ min-width:0 removes the automatic content floor that would otherwise stop it. The book only
467
+ actually shrinks if its width is elastic (a %, max-width, or the demo's min(...) with a % term);
468
+ a hard-coded pixel width has nothing for the % to resolve smaller against. */
469
+ .zine-panel-wrap > *:not(.zine-panel-holder):not(.zine-panel-scrim) {
470
+ flex: 0 1 auto;
471
+ min-width: 0;
472
+ }
473
+ /* With a docked toolbar the book lives inside .zine-controls-wrap, whose children are pinned
474
+ flex:0 0 auto (so the bar keeps its size). Inside a panel wrap the book child — everything but
475
+ the bar itself — must instead be allowed to shrink, so left/right docking flanks like the rest.
476
+ Top/bottom docking already shrinks through the container's own % width. */
477
+ .zine-panel-wrap .zine-controls-wrap > *:not(.zine-controls) {
478
+ flex: 0 1 auto;
479
+ min-width: 0;
480
+ min-height: 0;
481
+ }
482
+ @media (prefers-reduced-motion: no-preference) {
483
+ .zine-panel-wrap > *:not(.zine-panel-holder):not(.zine-panel-scrim) {
484
+ transition: flex-basis 160ms ease, width 160ms ease;
485
+ }
486
+ }
382
487
 
383
488
  /* The holder stretches to the book's height; the rail is absolutely positioned inside it so a
384
489
  long list scrolls rather than growing the row and running past the bottom of the book. */
@@ -388,6 +493,10 @@ void main() {
388
493
  align-self: stretch;
389
494
  min-height: 0;
390
495
  }
496
+ /* The scrim dims the book behind the narrow-screen drawer. It exists on every screen but only
497
+ shows under the breakpoint below, so on a wide screen it takes no flex slot and never intercepts
498
+ a click. */
499
+ .zine-panel-scrim { display: none; }
391
500
  .zine-panel {
392
501
  position: absolute;
393
502
  inset: 0;
@@ -395,22 +504,147 @@ void main() {
395
504
  flex-direction: column;
396
505
  gap: 6px;
397
506
  overflow-y: auto;
398
- overscroll-behavior: contain;
507
+ /* Chain overscroll up to the page: once the list is at its end (or too short to scroll at all),
508
+ a further wheel scrolls the page behind, the same as scrolling over the book itself does. */
509
+ overscroll-behavior: auto;
510
+ /* Reserve the scrollbar's lane whether or not it is showing, so rows never sit under the bar
511
+ and the close button (inset past this lane below) has a fixed edge to clear. */
512
+ scrollbar-gutter: stable;
399
513
  padding: 6px;
400
514
  box-sizing: border-box;
401
515
  border-radius: 8px;
402
- background: var(--zine-controls-bg, rgba(24, 24, 27, 0.82));
403
- color: var(--zine-controls-fg, #f4f4f5);
516
+ background: var(--zine-controls-bg, light-dark(rgba(255, 255, 255, 0.94), rgba(24, 24, 27, 0.82)));
517
+ color: var(--zine-controls-fg, light-dark(#18181b, #f4f4f5));
404
518
  font: 500 11px/1.2 system-ui, sans-serif;
405
519
  scrollbar-width: thin;
406
520
  touch-action: auto;
407
521
  -webkit-user-select: none;
408
522
  user-select: none;
409
523
  }
524
+ /* The rail sits flush against the book's reading-start edge (left, or right in RTL), so its outer
525
+ corners there would round away from that edge and leave a gap. Square them; keep the interior
526
+ corners, which face the page, rounded. */
527
+ .zine-panel { border-radius: 0 8px 8px 0; }
528
+ .zine-panel-wrap-rtl .zine-panel { border-radius: 8px 0 0 8px; }
410
529
  /* Overlay fallback, used when the container has no parent to wrap. */
411
530
  .zine-panel-overlay { position: absolute; inset: 0 auto 0 0; z-index: 3; }
412
- .zine-panel-active { background: var(--zine-controls-hover, rgba(255,255,255,0.18)); }
531
+ .zine-panel-active { background: var(--zine-controls-hover, light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.18))); }
413
532
  .zine-panel-note { padding: 8px; opacity: 0.66; line-height: 1.4; }
533
+ /* Discoverable dismiss, floated in the rail's trailing-top (interior) corner, away from the book.
534
+ It sits in the holder above the scrolling list so the list scrolls under it. A translucent
535
+ backdrop keeps the glyph legible over a thumbnail or a line of text. */
536
+ .zine-panel-close {
537
+ position: absolute;
538
+ top: 6px;
539
+ /* Inset past the reserved scrollbar gutter so the button never overlaps the bar. */
540
+ right: 12px;
541
+ z-index: 1;
542
+ display: inline-flex;
543
+ width: 24px;
544
+ height: 24px;
545
+ align-items: center;
546
+ justify-content: center;
547
+ padding: 0;
548
+ border: 0;
549
+ border-radius: 6px;
550
+ /* Opaque so a light thumbnail underneath never shows through and dims the glyph. */
551
+ background: light-dark(#f4f4f5, #27272a);
552
+ color: inherit;
553
+ cursor: pointer;
554
+ }
555
+ .zine-panel-close svg { width: 15px; height: 15px; }
556
+ /* Opaque hover, not the translucent hover token: a see-through backdrop over a light thumbnail
557
+ would wash the glyph out. Solid neutrals keep the X readable in both themes over anything. */
558
+ .zine-panel-close:hover { background: light-dark(#e4e4e7, #3f3f46); }
559
+ .zine-panel-close:focus-visible {
560
+ outline: 2px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
561
+ outline-offset: -2px;
562
+ }
563
+ .zine-panel-wrap-rtl .zine-panel-close { right: auto; left: 12px; }
564
+ /* End the search field just before the close button rather than running under it, so the two sit
565
+ side by side and the field's border reads cleanly. The button's inner edge is ~30px from the
566
+ panel's content edge (24px wide, its right edge 6px in once the reserved scrollbar gutter is
567
+ accounted for), so 30px leaves them flush with a hair of breathing room. width:auto lets the
568
+ column's stretch fill the rest, so the margin shortens the field instead of overflowing 100%. */
569
+ .zine-search .zine-search-input { width: auto; align-self: stretch; margin-right: 30px; }
570
+ .zine-panel-wrap-rtl .zine-search .zine-search-input { margin-right: 0; margin-left: 30px; }
571
+
572
+ /* Overlay panels (outline, search) on a wide screen: float over the book's start edge instead of
573
+ flanking it, so the book never resizes. The wrap drops to a block, laying the book out exactly as
574
+ it was before the panel opened; the holder sits absolute over it at full book height, with a
575
+ shadow so it reads as lifted off the page. thumbnails is not overlaid — it stays a flex flank and
576
+ shrinks the book only when the two will not otherwise both fit. */
577
+ @media (min-width: 641px) {
578
+ .zine-panel-wrap-overlay { display: block; }
579
+ .zine-panel-wrap-overlay .zine-panel-holder {
580
+ position: absolute;
581
+ inset: 0 auto 0 0;
582
+ z-index: 4;
583
+ box-shadow: 0 0 24px light-dark(rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.55));
584
+ }
585
+ .zine-panel-wrap-overlay.zine-panel-wrap-rtl .zine-panel-holder { inset: 0 0 0 auto; }
586
+ /* Opaque over the page it floats on, unlike a flanking rail that sits against empty margin. */
587
+ .zine-panel-wrap-overlay .zine-panel {
588
+ background: var(--zine-controls-bg, light-dark(#ffffff, #18181b));
589
+ }
590
+ /* A click-away layer over the book, so pressing the page behind the floating rail closes it the
591
+ way tapping the scrim does on a narrow screen. Transparent here — the wide-screen rail only
592
+ covers an edge, so there is no need to dim the page the reader is still looking at. It sits
593
+ under the holder (z-index) so the rail's own rows still take their clicks. */
594
+ .zine-panel-wrap-overlay .zine-panel-scrim {
595
+ display: block;
596
+ position: absolute;
597
+ inset: 0;
598
+ z-index: 3;
599
+ background: transparent;
600
+ }
601
+ }
602
+ @media (min-width: 641px) and (prefers-reduced-motion: no-preference) {
603
+ .zine-panel-wrap-overlay .zine-panel-holder { animation: zine-drawer-in 180ms ease; }
604
+ .zine-panel-wrap-overlay.zine-panel-wrap-rtl .zine-panel-holder { animation-name: zine-drawer-in-rtl; }
605
+ }
606
+
607
+ /* Narrow screen: no room to flank, so the rail becomes a drawer over the book and the scrim dims
608
+ the page behind it. The wrap is position:relative, so the absolute holder and scrim below are
609
+ measured against it — i.e. against the book's own box. */
610
+ @media (max-width: 640px) {
611
+ /* No flanking here — the rail and scrim both overlay absolutely — so drop the flex row entirely.
612
+ As a plain block wrap the book keeps the exact box it had before a panel opened (its own width,
613
+ margin and aspect-ratio height); a flex row would instead re-resolve the book's width and, with
614
+ it, its aspect-derived height, enlarging the canvas and pushing the page down. */
615
+ .zine-panel-wrap {
616
+ display: block;
617
+ }
618
+ .zine-panel-holder {
619
+ position: absolute;
620
+ inset: 0 auto 0 0;
621
+ z-index: 4;
622
+ /* Cap the drawer so it never eats the whole book; its inline width still applies under this. */
623
+ max-width: 80%;
624
+ box-shadow: 0 0 24px light-dark(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.6));
625
+ }
626
+ /* RTL reads from the right, so the drawer enters from there. */
627
+ .zine-panel-wrap-rtl .zine-panel-holder { inset: 0 0 0 auto; }
628
+ /* Opaque over the page, unlike the wide-screen rail which can sit against empty margin. */
629
+ .zine-panel {
630
+ background: var(--zine-controls-bg, light-dark(#ffffff, #18181b));
631
+ }
632
+ .zine-panel-scrim {
633
+ display: block;
634
+ position: absolute;
635
+ inset: 0;
636
+ z-index: 3;
637
+ background: rgba(0, 0, 0, 0.4);
638
+ }
639
+ }
640
+ @media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
641
+ .zine-panel-holder { animation: zine-drawer-in 180ms ease; }
642
+ .zine-panel-wrap-rtl .zine-panel-holder { animation-name: zine-drawer-in-rtl; }
643
+ .zine-panel-scrim { animation: zine-scrim-in 180ms ease; }
644
+ }
645
+ @keyframes zine-drawer-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
646
+ @keyframes zine-drawer-in-rtl { from { transform: translateX(100%); } to { transform: translateX(0); } }
647
+ @keyframes zine-scrim-in { from { opacity: 0; } to { opacity: 1; } }
414
648
 
415
649
  .zine-thumbs { align-items: center; }
416
650
 
@@ -429,22 +663,25 @@ void main() {
429
663
  cursor: pointer;
430
664
  box-sizing: border-box;
431
665
  }
432
- .zine-thumbs-row:hover { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
666
+ .zine-thumbs-row:hover { background: var(--zine-controls-hover, light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.14))); }
433
667
  .zine-thumbs-row:focus-visible {
434
- outline: 2px solid var(--zine-controls-accent, #7dd3fc);
668
+ outline: 2px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
435
669
  outline-offset: -2px;
436
670
  }
437
671
  .zine-thumbs-row.zine-panel-active .zine-thumbs-cell {
438
- outline: 1px solid var(--zine-controls-accent, #7dd3fc);
672
+ outline: 1px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
439
673
  }
440
674
 
441
675
  /* Outline: a single column of headings, indented by depth. */
442
- .zine-outline { gap: 1px; }
676
+ /* No gap: a hairline between rows is the separator instead, so a title that wraps to two lines
677
+ still reads as one entry rather than blending into its neighbours. */
678
+ .zine-outline { gap: 0; }
443
679
  .zine-outline-row {
444
680
  display: block;
445
681
  width: 100%;
446
682
  padding: 6px 8px;
447
683
  border: 0;
684
+ border-bottom: 1px solid var(--zine-controls-divider, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.1)));
448
685
  border-radius: 5px;
449
686
  background: transparent;
450
687
  color: inherit;
@@ -455,11 +692,12 @@ void main() {
455
692
  box-sizing: border-box;
456
693
  overflow-wrap: anywhere;
457
694
  }
695
+ .zine-outline-row:last-child { border-bottom: 0; }
458
696
  .zine-outline-row:hover:not(:disabled) {
459
- background: var(--zine-controls-hover, rgba(255,255,255,0.14));
697
+ background: var(--zine-controls-hover, light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.14)));
460
698
  }
461
699
  .zine-outline-row:focus-visible {
462
- outline: 2px solid var(--zine-controls-accent, #7dd3fc);
700
+ outline: 2px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
463
701
  outline-offset: -2px;
464
702
  }
465
703
  /* A heading whose destination could not be resolved: shown, but nothing to click through to. */
@@ -470,7 +708,7 @@ void main() {
470
708
  min-width: 0;
471
709
  min-height: 24px;
472
710
  display: flex;
473
- background: rgba(0, 0, 0, 0.3);
711
+ background: light-dark(rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.3));
474
712
  border-radius: 2px;
475
713
  overflow: hidden;
476
714
  }
@@ -492,7 +730,7 @@ void main() {
492
730
  padding: 16px;
493
731
  background: rgba(0, 0, 0, 0.55);
494
732
  font: 500 13px/1.4 system-ui, sans-serif;
495
- color: var(--zine-controls-fg, #f4f4f5);
733
+ color: var(--zine-controls-fg, light-dark(#18181b, #f4f4f5));
496
734
  }
497
735
  .zine-share {
498
736
  width: min(320px, 100%);
@@ -503,7 +741,7 @@ void main() {
503
741
  gap: 12px;
504
742
  padding: 14px;
505
743
  border-radius: 12px;
506
- background: var(--zine-share-bg, #1c1c20);
744
+ background: var(--zine-share-bg, light-dark(#ffffff, #1c1c20));
507
745
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
508
746
  box-sizing: border-box;
509
747
  }
@@ -523,7 +761,7 @@ void main() {
523
761
  cursor: pointer;
524
762
  }
525
763
  .zine-share-close svg { width: 16px; height: 16px; }
526
- .zine-share-close:hover { background: var(--zine-controls-hover, rgba(255,255,255,0.14)); }
764
+ .zine-share-close:hover { background: var(--zine-controls-hover, light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.14))); }
527
765
 
528
766
  .zine-share-qr {
529
767
  align-self: center;
@@ -539,9 +777,9 @@ void main() {
539
777
  flex: 1 1 auto;
540
778
  min-width: 0;
541
779
  padding: 7px 9px;
542
- border: 1px solid var(--zine-controls-hover, rgba(255,255,255,0.2));
780
+ border: 1px solid var(--zine-controls-hover, light-dark(rgba(0,0,0,0.14), rgba(255,255,255,0.2)));
543
781
  border-radius: 7px;
544
- background: rgba(0, 0, 0, 0.3);
782
+ background: light-dark(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.3));
545
783
  color: inherit;
546
784
  font: inherit;
547
785
  }
@@ -551,8 +789,8 @@ void main() {
551
789
  padding: 7px 12px;
552
790
  border: 0;
553
791
  border-radius: 7px;
554
- background: var(--zine-controls-accent, #7dd3fc);
555
- color: #06202c;
792
+ background: var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
793
+ color: light-dark(#ffffff, #06202c);
556
794
  font: inherit;
557
795
  font-weight: 600;
558
796
  cursor: pointer;
@@ -566,22 +804,22 @@ void main() {
566
804
  align-items: center;
567
805
  justify-content: center;
568
806
  border-radius: 8px;
569
- background: rgba(255, 255, 255, 0.08);
807
+ background: light-dark(rgba(0, 0, 0, 0.06), rgba(255, 255, 255, 0.08));
570
808
  color: inherit;
571
809
  text-decoration: none;
572
810
  }
573
811
  .zine-share-social svg { width: 19px; height: 19px; }
574
- .zine-share-social:hover { background: var(--zine-controls-hover, rgba(255,255,255,0.18)); }
812
+ .zine-share-social:hover { background: var(--zine-controls-hover, light-dark(rgba(0,0,0,0.12), rgba(255,255,255,0.18))); }
575
813
  .zine-share-close:focus-visible,
576
814
  .zine-share-copy:focus-visible,
577
815
  .zine-share-social:focus-visible,
578
816
  .zine-share-link input:focus-visible {
579
- outline: 2px solid var(--zine-controls-accent, #7dd3fc);
817
+ outline: 2px solid var(--zine-controls-accent, light-dark(#0284c7, #7dd3fc));
580
818
  outline-offset: 2px;
581
819
  }
582
820
 
583
821
  @media (prefers-reduced-motion: no-preference) {
584
822
  .zine-controls-btn { transition: background 120ms ease; }
585
823
  }
586
- `})),X,Mt=n((()=>{X=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}}})),Nt,Pt,Ft=n((()=>{Mt(),Nt=78,Pt=class{#e;#t;#n;#r=[];#i=null;#a=[];constructor(e,t){this.#e=e;let n=t.ownerDocument;this.#t=n,this.#n=new X(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(Nt*a)),o.height=Math.max(1,Math.round(Nt*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()}}})),It,Lt,Rt,zt=n((()=>{Mt(),It=208,Lt=12,Rt=class{#e;#t;#n;#r=[];#i=[];constructor(e,t){this.#e=e;let n=t.ownerDocument;this.#t=n,this.#n=new X(n,t,{className:`zine-outline`,label:`Outline`,width:It}),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*Lt}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()}}})),Bt,Vt,Ht,Ut,Wt=n((()=>{Mt(),Bt=208,Vt=180,Ht=2,Ut=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 X(n,t,{className:`zine-search`,label:`Search results`,width:Bt}),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(),Vt)}),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<Ht){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()}}})),Gt,Kt=n((()=>{L(),Gt=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?I.next:I.prev,`Previous page`,()=>e.flipPrev()),this.#n=this.#a(n,r?I.prev:I.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(F(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 qt(e){wt(),R({id:`thumbnails`,title:()=>e.openPanel()===`thumbnails`?`Hide thumbnails`:`Show thumbnails`,icon:I.thumbnails,isVisible:e=>e.zine.isDocument(),isActive:()=>e.openPanel()===`thumbnails`,action:t=>{e.togglePanel(`thumbnails`),t.close()}}),R({id:`outline`,title:()=>e.openPanel()===`outline`?`Hide outline`:`Show outline`,icon:I.outline,isVisible:()=>e.hasOutline(),isActive:()=>e.openPanel()===`outline`,action:t=>{e.togglePanel(`outline`),t.close()}}),R({id:`pageInput`,title:`Page`,render:()=>e.makePageInput()}),R({id:`search`,title:()=>e.openPanel()===`search`?`Hide search`:`Search`,icon:I.search,isVisible:e=>e.zine.canSearch(),isActive:()=>e.openPanel()===`search`,action:()=>e.togglePanel(`search`)})}var Jt,Yt,Xt,Zt=n((()=>{L(),V(),Dt(),jt(),Ft(),zt(),Wt(),Kt(),Jt={thumbnails:Pt,outline:Rt,search:Ut},Yt=[`pointerdown`,`pointerup`,`pointermove`,`click`,`dblclick`,`wheel`,`keydown`],Xt=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,Ot(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 Yt)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??B),(e.arrows??!0)&&(this.#p=new Gt(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=ct(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(F(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=ct(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(F(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=ct(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=!1,i=()=>{if(r)return;r=!0;let e=Number(t.value),n=Math.max(0,this.#e.getPageCount()-1),i=Number.isFinite(e)?Math.min(Math.max(Math.round(e)-1,0),n):this.#e.getPage();i===this.#e.getPage()?t.value=String(this.#e.getPage()+1):this.#e.flipTo(i)};return t.addEventListener(`focus`,()=>{r=!1}),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(i(),t.blur())}),t.addEventListener(`blur`,i),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 Jt[e](this.#e,this.#l),this.#d=e),this.#D()}}})),Qt=r({DEFAULT_ITEMS:()=>B,ICONS:()=>I,createIcon:()=>F,defineControl:()=>R,getControl:()=>st,mountControls:()=>$t});function $t(e,t,n={}){let r=new Xt(e,t,n);return qt(r),r.mount(n),()=>r.destroy()}var en=n((()=>{Zt(),V(),L()}));D();var tn=.25,nn=.0015,Z=6,rn=250,an=24,on=2*rn,sn=1.55,cn=32,ln=60,un=2.5,dn=1.5,fn=120,pn=.85,mn=.72;function hn(e,t,n){let r=Math.max(0,t-cn),i=Math.min(e.length,t+n+cn),a=e.slice(r,i).replace(/\s+/g,` `).trim();return`${r>0?`…`:``}${a}${i<e.length?`…`:``}`}var gn=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=-1/0;#se=null;#ce=null;#le=new Set;#ue;#de=null;#fe;#pe=null;#me=null;#he=`download`;#ge=1;#_e=0;#ve=null;#ye;debug={setFlipProgress:(e,t)=>{this.#z?.setFlipProgress(e,t)}};constructor(e,t){xn(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=Qe(t.source,{frontCover:t.frontCover,backCover:t.backCover,pages:t.pages});let n=t.direction??`ltr`;this.#a=n,this.#x=(t.deepLink??!0)&&y(),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.#ue=t.controls??!0,this.#fe=t.loading??!0,this.#b=t.startPage,typeof this.#t.open!=`function`&&this.#jt(),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??rn:0,this.#ye=this.#Qe(t.renderer??`auto`)}get ready(){return this.#ye}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.#ht(),this.#gt())}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.#mt(e)}else{if(!this.#_)return;this.#_=!1,this.#ht()}this.#gt()}}getPageImage(e){return this.#Ot(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.#ce){let e=this.#t.getOutline;this.#ce=typeof e==`function`?Promise.resolve(e.call(this.#t)).catch(()=>[]):Promise.resolve([])}return this.#ce}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:hn(t,i,r.length)})}return a}flipNext(){this.#be(1)}flipPrev(){this.#be(-1)}#be(e){this.#xe(()=>this.#Ee(this.#E+e))}flipTo(e){let t=Q(e,0,Math.max(0,this.#t.pageCount-1));this.#xe(()=>this.#Ee(this.#At(t)))}#xe(e){this.#i.state===`idle`?e():this.#J?(this.#q=null,this.#Se(),e()):this.#q=e}#Se(){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())}#Ce(){let e=this.#q;if(!e){this.#wt();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=r.screenAt?.(this.#I),a=t??(i?{x:i.x+this.#L+i.width/2,y:i.y+this.#R+i.height/2}:null)??{x:r.containerWidth/2,y:r.containerHeight/2},o=this.#I,s=n===1?0:a.x-n/o*(a.x-this.#L),c=n===1?0:a.y-n/o*(a.y-this.#R);[s,c]=this.#Te(s,c,n,r.containerWidth,r.containerHeight),this.#I=n,this.#L=s,this.#R=c,this.#z.setViewTransform(n,s,c),o>1!=n>1&&this.#we(),this.#bt(),this.#n.emit(`zoomChanged`,{scale:n})}resetZoom(){this.setZoom(1)}#we(){this.#e.style.touchAction=this.#I>1?`none`:`pan-y`}#Te(e,t,n,r,i){let a=typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1,o=e=>Math.round(e*a)/a||0,s=this.#z?.measure().screenAt?.(n)??{x:0,y:0,width:r*n,height:i*n},[c,l]=_n(s.x,s.width,r),[u,d]=_n(s.y,s.height,i);return[o(Q(e,c,l)),o(Q(t,u,d))]}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.#Ue(),this.#P?.disconnect(),this.#C?.stop(),this.#C=null,this.#w?.(),this.#x&&b(),this.#de?.(),this.#nt(),this.#se?.(),this.#ne?.(),this.#ie?.(),this.#re?.(),this.#te?.(),this.#ve!==null&&clearTimeout(this.#ve),this.#_e++,this.#z?.destroy(),this.#z=null,this.#t.destroy(),this.#n.clear()}#Ee(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.#je(e);this.#n.emit(`flipStart`,{from:this.#D,to:n}),this.#De(e,t,n,++this.#Y)}async#De(e,t,n,r){let i=this.#T[e],a=i?await this.#Dt(i):{left:null,right:null};r===this.#Y&&(this.#z?.beginFlip(this.#O,a,t,{fill:this.#h,curl:this.#ft(),anchor:{y:this.#l}}),this.#Oe(0,1,t,()=>this.#Ae(e,n,a),()=>this.#ke(n)))}#Oe(e,t,n,r,i){let a=this.#dt()*Math.abs(t-e);if(a<=0){this.#z?.setFlipProgress(t,n),r();return}let o={toT:t,direction:n,onDone:r};this.#J=o;let s=performance.now(),c=!1,l=u=>{if(this.#J!==o)return;let d=Math.min(1,(u-s)/a),f=this.#h?yn(d):vn(d);i&&!c&&f>=(this.#h?mn:pn)&&(c=!0,i()),d<1?(this.#z?.setFlipProgress(e+(t-e)*f,n),this.#H=requestAnimationFrame(l)):(this.#z?.setFlipProgress(t,n),this.#H=null,this.#J=null,r())};this.#H=requestAnimationFrame(l)}#ke(e){this.#D!==e&&(this.#D=e,this.#ut(),this.#n.emit(`pageChanged`,{page:e}))}#Ae(e,t,n){let r=this.#T[e];this.#E=e,this.#O=n,r&&this.#_t(r,n),this.#kt(),this.#i.send(`settle`),this.#oe=performance.now(),this.#ke(t),this.#n.emit(`flipEnd`,{page:t}),this.#Ce()}#je(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}#Me(e,t){if(this.#Z||!this.#z)return;if(this.#Ue(),this.#I>1){if(this.#i.send(`panStart`)===null)return;this.#X={baseTx:this.#L,baseTy:this.#R};return}let n=this.#ze(),r=this.#Be(e,t);this.#G=r;let i=Math.min(n.width,n.height)*tn,a=r.x>=0&&r.x<=n.width&&r.y>=0&&r.y<=n.height,o=r.x<=i||r.x>=n.width-i,s=a&&o;if(this.#i.state!==`idle`){if(!this.#J||!s){this.#W=null;return}this.#Se()}if(!s)return;this.#l=Q(r.y/n.height,0,1);let c=r.x>n.width/2,l=this.#a===`rtl`?!c:c,u=this.#E+(l?1:-1);u<0||u>=this.#T.length||(this.#W={direction:l?`forward`:`backward`,targetIndex:u,toPage:this.#je(u),width:n.width})}#Ne(){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.#Pe(e.targetIndex,e.direction)))}async#Pe(e,t){let n=this.#T[e],r=n?await this.#Dt(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.#ft(),anchor:{y:this.#l}}),this.#z?.setFlipProgress(this.#U.t,t))}#Fe(e,t){if(this.#Z)return;if(this.#X){if(!this.#z)return;let n=this.#z.measure(),[r,i]=this.#Te(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.#bt();return}this.#W&&Math.hypot(e,t)>Z&&this.#Ne();let n=this.#U;n&&(n.t=Q((n.direction===`forward`?-e:e)/n.width,0,1),this.#z?.setFlipProgress(n.t,n.direction))}#Ie(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.#Le(e)||this.#Re(e);return}this.#U=null,this.#i.send(`release`);let n=e.swipe&&Math.abs(e.vx)>Math.abs(e.vy),r=t.direction===`forward`?e.vx<0:e.vx>0,i=n&&r,a=n&&!r;i||t.t>=.5&&!a?this.#Oe(t.t,1,t.direction,()=>this.#Ae(t.targetIndex,t.toPage,t.toContent),()=>this.#ke(t.toPage)):this.#Oe(t.t,0,t.direction,()=>this.#We())}#Le(e){if(this.#I>1||!e.swipe||Math.abs(e.dx)<=Math.abs(e.dy))return!1;let t=this.#a===`rtl`?e.dx>0:e.dx<0,n=t?`forward`:`backward`;if(!this.#He(n))return!1;let r=t?1:-1;return this.#xe(()=>this.#Ee(this.#E+r)),!0}#Re(e){if(this.#u===`off`||this.#I>1||!this.#G||Math.abs(e.dx)>Z||Math.abs(e.dy)>Z)return;let t=this.#Ve(this.#G);if(!t||!this.#He(t))return;this.#l=Q(this.#G.y/this.#ze().height,0,1);let n=t===`forward`?1:-1,r=()=>this.#Ee(this.#E+n);if(this.#Ue(),this.#p<=0){this.#xe(r);return}this.#K=setTimeout(()=>{this.#K=null,this.#xe(r)},this.#p)}#ze(){let e=this.#z.measure();return e.content??e.book??{x:0,y:0,width:e.containerWidth,height:e.containerHeight}}#Be(e,t){let n=this.#e.getBoundingClientRect(),r=this.#ze();return{x:e-n.left-r.x,y:t-n.top-r.y}}#Ve(e){if(!this.#z)return null;let t=this.#ze().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`}#He(e){let t=this.#E+(e===`forward`?1:-1);return t>=0&&t<this.#T.length}#Ue(){this.#K!==null&&(clearTimeout(this.#K),this.#K=null)}#We(){let e=this.#T[this.#E];e&&this.#_t(e,this.#O),this.#i.send(`settle`),this.#n.emit(`flipEnd`,{page:this.#D}),this.#Ce()}#Ge(){if(this.#W=null,this.#Ue(),this.#U){this.#U=null,this.#i.send(`release`),this.#i.send(`settle`);let e=this.#T[this.#E];e&&this.#_t(e,this.#O)}else this.#X&&(this.#X=null,this.#i.send(`panEnd`));this.#Z=!0,this.#Q=this.#I}#Ke(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})}#qe(){this.#Z=!1}#Je(){if(!this.#S)return;let e=e=>e.preventDefault();this.#e.addEventListener(`contextmenu`,e),this.#re=()=>this.#e.removeEventListener(`contextmenu`,e)}#Ye(){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*nn);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)}#Xe(){let e=e=>{let t=this.#M;if(!this.#A||t===null||!this.#z)return;let n=performance.now(),r=this.#ae;if(!(r!==null&&n-r.t<=rn&&Math.hypot(e.clientX-r.x,e.clientY-r.y)<=an)){this.#ae={t:n,x:e.clientX,y:e.clientY};return}this.#ae=null,this.#Ze(e.clientX,e.clientY,t)};this.#e.addEventListener(`click`,e),this.#ie=()=>this.#e.removeEventListener(`click`,e)}#Ze(e,t,n){if(this.#I<=1&&this.#u!==`off`&&!this.#f){let n=this.#Be(e,t),r=this.#Ve(n);if(r!==null&&this.#He(r)||this.#i.state===`animating`||performance.now()-this.#oe<=on)return}this.#Ue();let r=n.find(e=>e>this.#I+1e-6)??n[0]??this.#I,i=this.#e.getBoundingClientRect();this.setZoom(r,{x:e-i.left,y:t-i.top})}async#Qe(e){let t=M(e);if(this.#t.onProgress?.(e=>this.#$e(e)),typeof this.#t.open==`function`){this.#et();try{await this.#t.open(),this.#jt()}catch(e){throw this.#nt(),e}this.#tt(`preparing`)}this.#t.prefetch([this.#D]);let n=await t,r=await this.#rt(n);this.#z=r,this.#t.onPageUpdate?.(e=>this.#yt(e)),this.#mt(r.measure().containerWidth);let i=new p({onStart:e=>this.#Me(e.x,e.y),onMove:e=>this.#Fe(e.dx,e.dy),onEnd:e=>this.#Ie(e)}),a=new g({onPinchStart:()=>this.#Ge(),onPinchMove:e=>this.#Ke(e.centerX,e.centerY,e.scale),onPinchEnd:()=>this.#qe()});this.#te=m(this.#e,{pointer:i,pinch:a}),this.#we(),this.#Ye(),this.#Xe(),this.#Je(),this.#at(),this.#se=this.#ct(),await this.#gt(),this.#nt(),this.#Tt(),this.#kt(),this.#ut(),this.#st(),await this.#ot(),this.#n.emit(`ready`)}#$e(e){this.#me=e,this.#n.emit(`progress`,e),this.#pe?.update(e)}async#et(){if(this.#fe===!1||this.#V)return;let e=this.#e;if(!(!e.ownerDocument||typeof e.appendChild!=`function`))try{let{mountLoading:t}=await Promise.resolve().then(()=>(ot(),tt));if(this.#he===`done`||this.#V)return;this.#pe=t(e),this.#me&&this.#pe.update(this.#me),this.#he===`preparing`&&this.#pe.preparing()}catch{}}#tt(e){this.#he!==`done`&&(this.#he=e,this.#pe?.preparing())}#nt(){this.#he=`done`,this.#pe?.destroy(),this.#pe=null}async#rt(e){try{return await e.mount(this.#e),e.onFatal?.(()=>{this.#it()}),e}catch{e.destroy();let t=await M(`css`);return await t.mount(this.#e),this.#B=!0,this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`}),t}}async#it(){if(this.#B||this.#V)return;this.#B=!0,this.#z?.destroy(),this.#z=null;let e=await M(`css`);if(this.#V){e.destroy();return}await e.mount(this.#e),this.#z=e,this.#mt(e.measure().containerWidth),await this.#gt(),this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`})}#at(){if(typeof matchMedia!=`function`)return;let e=matchMedia(`(prefers-reduced-motion: reduce)`);this.#$=e.matches,e.addEventListener?.(`change`,e=>{this.#$=e.matches})}async#ot(){if(this.#ue===!1||this.#V)return;let e=this.#e;if(!(!e.ownerDocument||typeof e.appendChild!=`function`))try{let{mountControls:t}=await Promise.resolve().then(()=>(en(),Qt));if(this.#V)return;let n=this.#ue===!0?{}:this.#ue;this.#de=t(this,e,n)}catch{}}#st(){if(!this.#x||globalThis.location===void 0)return;let e=globalThis;this.#C=C(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=S(n.hash,Q(e,0,Math.max(0,this.#t.pageCount-1))),n.toString()}#ct(){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.#lt(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}}#lt(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}}#ut(){this.#ee&&(this.#ee.textContent=`Page ${this.#D+1} of ${this.#t.pageCount}`)}#dt(){return this.#$?fn:this.#k*(this.#h?sn:1)}#ft(){return this.#$?`simple`:this.#c}update(){!this.#z||this.#i.state!==`idle`||(this.#mt(this.#z.measure().containerWidth),this.#gt())}#pt(){return this.#_||this.#o===`single`?`single`:this.#o}#mt(e){let t=this.#v&&a(e,this.#m);t!==this.#_&&(this.#_=t,this.#ht())}#ht(){let e=this.#pt(),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.#At(this.#D),t&&this.#n.emit(`spreadChanged`,{mode:e,singlePage:this.#h})}async#gt(){let e=this.#T[this.#E];!e||!this.#z||(this.#O=await this.#Dt(e),this.#_t(e,this.#O))}#_t(e,t){this.#z?.renderSpread(e,t,{fill:this.#h}),this.#vt(),this.#ge=1,this.#bt()}#vt(){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)}#yt(e){if(this.#i.state!==`idle`){this.#le.add(e);return}let t=this.#T[this.#E];t&&(t.left===e||t.right===e)&&this.#gt()}#bt(){this.#ve!==null&&clearTimeout(this.#ve);let e=this.#St();if(e!==this.#ge){if(e===1){this.#_e++,this.#ge=1,this.#gt();return}this.#ve=setTimeout(()=>{this.#ve=null,this.#Ct()},ln)}}#xt(){let e=this.#z?.measure(),t=e?.content??e?.book;if(!t||t.width<=0)return 1;let n=this.#O,r=+!!n.left+ +!!n.right;if(r===0)return 1;let i=t.width/r,a=typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1,o=0;for(let e of[n.left,n.right]){if(!e||e.width<=0)continue;let t=e.width/this.#ge;o=Math.max(o,i*a/t)}return o===0?1:o}#St(){let e=Math.max(1,dn/(typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1)),t=this.#I<=1?1:this.#I,n=this.#xt()*Math.max(t,e);return n<=1.001?1:Math.min(Math.ceil(n*2)/2,un)}async#Ct(){let e=this.#T[this.#E];if(!this.#z||!e)return;let t=this.#St();if(t===1||t===this.#ge||this.#i.state!==`idle`)return;let n=++this.#_e,r={x:0,y:0,width:1,height:1},i=await Promise.all([e.left,e.right].map(async e=>{if(e===null)return null;try{return await this.#t.get(e,{scale:t,region:r})}catch(t){return this.#n.emit(`sourceError`,{index:e,error:t}),null}}));if(n!==this.#_e||this.#St()!==t||this.#i.state!==`idle`)return;let a=i[0]??null,o=i[1]??null;a===this.#O.left&&o===this.#O.right||(this.#ge=t,this.#O={left:a,right:o},this.#z.renderSpread(e,this.#O,{fill:this.#h}))}#wt(){if(this.#le.size===0)return;let e=this.#T[this.#E],t=e!==void 0&&[e.left,e.right].some(e=>e!==null&&this.#le.has(e));this.#le.clear(),t&&this.#gt()}#Tt(){typeof ResizeObserver>`u`||(this.#P=new ResizeObserver(()=>this.#Et()),this.#P.observe(this.#e))}#Et(){this.#F||(this.#F=!0,requestAnimationFrame(()=>{this.#F=!1,this.update()}))}async#Dt(e){let[t,n]=await Promise.all([this.#Ot(e.left),this.#Ot(e.right)]);return{left:t,right:n}}async#Ot(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}}#kt(){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)}#At(e){let t=this.#T.findIndex(t=>t.left===e||t.right===e);return t===-1?0:t}#jt(){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.#pt();this.#h=n===`single`,this.#T=i(e,{direction:this.#a,mode:n});let r=this.#x?x(globalThis.location?.hash??``):null;this.#D=Q(r??t??0,0,e-1),this.#E=this.#At(this.#D)}};function Q(e,t,n){return e<t?t:e>n?n:e}function _n(e,t,n){if(t<=n){let r=(n-t)/2-e;return[r,r]}return[n-(e+t),-e]}function vn(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function yn(e){return 1-(1-vn(e))**1.3}function bn(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function xn(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 ${bn(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){if(typeof s==`object`&&s){if(typeof s.deform!=`function`)throw Error(`Zine: a curl model must have a deform() function.`)}else if(T.includes(s))throw Error(`Zine: the '${String(s)}' curl is not bundled. Import it and pass the model: import { ${String(s)} } from '@zinejs/core/curls' → curl: ${String(s)}`);else if(!w.includes(s))throw Error(`Zine: curl must be ${w.join(` or `)}, or a model imported from '@zinejs/core/curls' (${T.join(`, `)}); got ${JSON.stringify(s)}.`)}for(let e of[`deepLink`,`disableContextMenu`,`responsiveSpread`,`loading`])if(n[e]!==void 0&&typeof n[e]!=`boolean`)throw Error(`Zine: ${e} must be a boolean; got ${bn(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 ${bn(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),Sn(n.zoom),Cn(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 Sn(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 Cn(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 wn=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}};V(),D(),e.CURL_TYPES=w,e.DEFAULT_ITEMS=B,e.IMPORTABLE_CURLS=T,e.ImageSource=wn,e.Zine=gn,e.defineControl=R,e.getControl=st});
824
+ `})),wt=r({ShareDialog:()=>Dt}),Tt,Et,Dt,Ot=n((()=>{I(),dt(),yt(),Ct(),Tt=132,Et=1600,Dt=class{#e;#t;#n;#r;#i=null;#a;constructor(e,t,n=`auto`){let r=t.ownerDocument;this.#e=r,this.#r=r.activeElement;let i=e.pageLink(),a=r.title||`Flipbook`;this.#t=r.createElement(`div`),this.#t.className=`zine-share-backdrop`,Y(this.#t,n),this.#t.addEventListener(`pointerdown`,e=>{e.target===this.#t&&this.close()}),this.#n=r.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 o=r.createElement(`div`);o.className=`zine-share-head`;let s=r.createElement(`strong`);s.textContent=`Share`;let c=r.createElement(`button`);c.type=`button`,c.className=`zine-share-close`,c.setAttribute(`aria-label`,`Close`),c.appendChild(P(r,F.close)),c.addEventListener(`click`,()=>this.close()),o.append(s,c),this.#n.append(o,this.#s(r,i),this.#l(r,i,a));let l=this.#o(r,i);l&&this.#n.insertBefore(l,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),c.focus()}#o(e,t){if(!t)return null;try{let n=e.createElement(`div`);return n.className=`zine-share-qr`,n.innerHTML=gt(t,Tt),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`},Et)}#l(e,t,n){let r=e.createElement(`div`);r.className=`zine-share-socials`;for(let i of ut){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(P(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 kt(){L({id:`prev`,title:`Previous page`,icon:F.prev,isDisabled:e=>!e.zine.canFlipPrev(),action:e=>e.zine.flipPrev()}),L({id:`next`,title:`Next page`,icon:F.next,isDisabled:e=>!e.zine.canFlipNext(),action:e=>e.zine.flipNext()});let e=e=>e.zine.getDirection()===`rtl`;L({id:`first`,title:`First page`,icon:t=>e(t)?F.last:F.first,isDisabled:e=>!e.zine.canFlipPrev(),action:e=>{e.zine.flipTo(0),e.close()}}),L({id:`last`,title:`Last page`,icon:t=>e(t)?F.first:F.last,isDisabled:e=>!e.zine.canFlipNext(),action:e=>{e.zine.flipTo(e.zine.getPageCount()-1),e.close()}}),L({id:`zoomIn`,title:`Zoom in`,icon:F.zoomIn,isDisabled:e=>e.zine.getZoom()>=e.zine.getMaxZoom()-1e-6,action:e=>e.zine.setZoom(e.zine.getZoom()*At)}),L({id:`zoomOut`,title:`Zoom out`,icon:F.zoomOut,isDisabled:e=>e.zine.getZoom()<=1.000001,action:e=>e.zine.setZoom(e.zine.getZoom()/At)}),L({id:`fullscreen`,title:`Fullscreen`,icon:F.fullscreen,isVisible:e=>typeof e.zine.container.requestFullscreen==`function`,isActive:jt,action:e=>{let t=e.zine.container.ownerDocument;jt(e)?t?.exitFullscreen?.():e.zine.container.requestFullscreen?.(),e.close()}}),L({id:`share`,title:`Share`,icon:F.share,action:e=>{e.close(),Promise.resolve().then(()=>(Ot(),wt)).then(({ShareDialog:t})=>new t(e.zine,e.zine.container,e.colorScheme)).catch(()=>{navigator.clipboard?.writeText(e.zine.pageLink()).catch(()=>{})})}}),L({id:`download`,title:`Download PDF`,icon:F.download,isVisible:e=>e.zine.canDownload(),action:async e=>{await e.zine.download(),e.close()}}),L({id:`spread`,title:e=>e.zine.isSinglePage()?`Show two pages`:`Show one page`,icon:e=>e.zine.isSinglePage()?F.twoPages:F.onePage,isVisible:e=>!e.zine.isResponsiveSingle(),action:e=>{e.zine.toggleSpreadMode(),e.close()}}),L({id:`print`,title:`Print`,icon:F.print,isVisible:e=>e.zine.canPrint(),action:async e=>{await e.zine.print(),e.close()}}),L({id:`menu`,title:`More`,icon:F.menu,children:[`first`,`last`,`spread`,`thumbnails`,`outline`,`print`,`download`]})}var At,jt,Mt=n((()=>{I(),B(),At=Math.SQRT2,jt=e=>e.zine.container.ownerDocument?.fullscreenElement===e.zine.container})),X,Z=n((()=>{I(),X=class{root;#e;#t=null;#n=null;#r=null;#i=null;#a;#o=null;#s=null;constructor(e,t,n){this.#a=e,this.#e=e.createElement(`div`),this.#e.className=`zine-panel-holder`,this.#e.style.width=`${n.width}px`,this.#o=n.pageBox??null,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.#u(e,t,n.rtl??!1,n.overlay??!1),n.onDismiss&&this.#d(e,n.onDismiss),this.#c(t)}#c(e){this.#o&&(this.#l(),!(typeof ResizeObserver>`u`)&&(this.#s=new ResizeObserver(()=>this.#l()),this.#s.observe(e)))}#l(){let e=this.#o?.();e&&(this.#e.style.top=`${e.y}px`,this.#e.style.bottom=`auto`,this.#e.style.height=`${e.height}px`)}setWidth(e){this.#e.style.width=`${e}px`}#u(e,t,n,r){if(!t.parentNode){this.#e.classList.add(`zine-panel-overlay`),t.appendChild(this.#e);return}let i=t.closest(`.zine-controls-wrap`)??t,a=e.createElement(`div`);a.className=`zine-panel-wrap`,n&&a.classList.add(`zine-panel-wrap-rtl`),r&&a.classList.add(`zine-panel-wrap-overlay`),i.parentNode.insertBefore(a,i),a.append(this.#e,i),this.#t=a}#d(e,t){let n=e.createElement(`button`);if(n.type=`button`,n.className=`zine-panel-close`,n.setAttribute(`aria-label`,`Close`),n.appendChild(P(e,F.close)),n.addEventListener(`click`,e=>{e.stopPropagation(),t()}),this.#e.appendChild(n),this.#r=n,this.#t){let n=e.createElement(`div`);n.className=`zine-panel-scrim`,this.#t.insertBefore(n,this.#e);for(let e of[`pointerdown`,`click`])n.addEventListener(e,e=>{e.stopPropagation(),t()});this.#n=n}this.#i=e=>{e.key===`Escape`&&t()},e.addEventListener(`keydown`,this.#i)}destroy(){this.#s?.disconnect(),this.#s=null,this.#i&&=(this.#a.removeEventListener(`keydown`,this.#i),null),this.#n?.remove(),this.#n=null,this.#r=null,this.#e.remove();let e=this.#t;if(e?.parentNode){for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);e.remove()}this.#t=null}}})),Nt,Pt,Ft=n((()=>{Z(),Nt=78,Pt=class{root;#e;#t;#n;#r=[];#i=null;#a=[];constructor(e,t,n={}){this.#e=e;let r=t.ownerDocument;this.#t=r,this.#n=new X(r,t,{className:`zine-thumbs`,label:`Pages`,width:90,onDismiss:n.onDismiss,rtl:e.getDirection()===`rtl`,pageBox:()=>e.getPageBox()}),this.root=this.#n.root,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,pages:a})}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(Nt*a)),o.height=Math.max(1,Math.round(Nt*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.getPage();for(let{el:t,pages:n}of this.#r){let r=n.includes(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()}}})),It,Lt,Rt,zt=n((()=>{Z(),It=208,Lt=12,Rt=class{root;#e;#t;#n;#r=[];#i=[];#a;constructor(e,t,n={}){this.#e=e;let r=t.ownerDocument;this.#t=r,this.#a=n.onDismiss,this.#n=new X(r,t,{className:`zine-outline`,label:`Outline`,width:It,onDismiss:n.onDismiss,rtl:e.getDirection()===`rtl`,overlay:!0,pageBox:()=>e.getPageBox()}),this.root=this.#n.root,this.#o(`Loading…`),this.#s(),this.#i.push(e.on(`pageChanged`,()=>this.#l()))}#o(e){let t=this.#t.createElement(`div`);t.className=`zine-panel-note`,t.textContent=e,this.#n.root.replaceChildren(t)}async#s(){let e=await this.#e.getOutline();if(this.#n.root.isConnected){if(e.length===0){this.#o(`This document has no outline.`);return}this.#n.root.replaceChildren(),this.#c(e,0),this.#l()}}#c(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*Lt}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.#a?.()}),this.#r.push({el:e,page:t})}this.#n.root.appendChild(e),n.children.length>0&&this.#c(n.children,t+1)}}#l(){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()}}})),Bt,Vt,Ht,Ut,Wt=n((()=>{Z(),Bt=208,Vt=180,Ht=2,Ut=class{root;#e;#t;#n;#r;#i;#a=0;#o=null;#s;constructor(e,t,n={}){this.#e=e;let r=t.ownerDocument;this.#t=r,this.#s=n.onDismiss,this.#n=new X(r,t,{className:`zine-search`,label:`Search results`,width:Bt,onDismiss:n.onDismiss,rtl:e.getDirection()===`rtl`,overlay:!0,pageBox:()=>e.getPageBox()}),this.root=this.#n.root,this.#r=r.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.#l(),Vt)}),this.#r.addEventListener(`keydown`,e=>{e.key===`Enter`&&(this.#o&&clearTimeout(this.#o),this.#l())}),this.#i=r.createElement(`div`),this.#i.className=`zine-search-hits`,this.#n.root.append(this.#r,this.#i),this.#r.focus()}#c(e){let t=this.#t.createElement(`div`);t.className=`zine-panel-note`,t.textContent=e,this.#i.replaceChildren(t)}async#l(){let e=this.#r.value.trim(),t=++this.#a;if(e.length<Ht){this.#i.replaceChildren();return}this.#c(`Searching…`);let n=await this.#e.search(e);if(!(t!==this.#a||!this.#n.root.isConnected)){if(n.length===0){this.#c(`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),this.#s?.()}),t}))}}destroy(){this.#o&&clearTimeout(this.#o),this.#o=null,this.#a++,this.#n.destroy()}}})),Gt,Kt=n((()=>{I(),Ct(),Gt=class{#e;#t;#n;#r=null;#i;#a=[];constructor(e,t,n=`auto`,r=null){this.#e=e,this.#i=r;let i=t.ownerDocument,a=e.getDirection()===`rtl`;if(this.#t=this.#o(i,a?F.next:F.prev,`Previous page`,()=>e.flipPrev()),this.#n=this.#o(i,a?F.prev:F.next,`Next page`,()=>e.flipNext()),this.#s(i,t),this.#r)Y(this.#r,n);else for(let e of[this.#t,this.#n])Y(e,n);this.#a.push(e.on(`pageChanged`,({page:e})=>this.#c(e))),this.#a.push(e.on(`flipEnd`,()=>this.#c())),this.#c()}#o(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(P(e,t)),i.addEventListener(`click`,r);for(let e of[`pointerdown`,`pointerup`,`click`])i.addEventListener(e,e=>e.stopPropagation());return i}#s(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`,this.#i&&i.classList.add(`zine-arrows-${this.#i}`),r.insertBefore(i,n),i.append(this.#t,n,this.#n),this.#r=i}#c(e){let{prev:t,next:n}=this.#l(e);for(let[e,r]of[[this.#t,t],[this.#n,n]])e.disabled=!r,e.classList.toggle(`zine-arrow-hidden`,!r)}#l(e){if(e!==void 0){let t=this.#e.getSpreads(),n=t.findIndex(t=>t.left===e||t.right===e);if(n>=0)return{prev:n>0,next:n+1<t.length}}return{prev:this.#e.canFlipPrev(),next:this.#e.canFlipNext()}}destroy(){for(let e of this.#a)e();this.#a=[],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 qt(e){kt(),L({id:`thumbnails`,title:()=>e.openPanel()===`thumbnails`?`Hide thumbnails`:`Show thumbnails`,icon:F.thumbnails,isVisible:e=>e.zine.isDocument(),isActive:()=>e.openPanel()===`thumbnails`,action:t=>{e.togglePanel(`thumbnails`),t.close()}}),L({id:`outline`,title:()=>e.openPanel()===`outline`?`Hide outline`:`Show outline`,icon:F.outline,isVisible:()=>e.hasOutline(),isActive:()=>e.openPanel()===`outline`,action:t=>{e.togglePanel(`outline`),t.close()}}),L({id:`pageInput`,title:`Page`,render:()=>e.makePageInput()}),L({id:`search`,title:()=>e.openPanel()===`search`?`Hide search`:`Search`,icon:F.search,isVisible:e=>e.zine.canSearch(),isActive:()=>e.openPanel()===`search`,action:()=>e.togglePanel(`search`)})}var Jt,Yt,Xt,Zt=n((()=>{I(),B(),Mt(),Ct(),Ft(),zt(),Wt(),Kt(),Jt={thumbnails:Pt,outline:Rt,search:Ut},Yt=[`pointerdown`,`pointerup`,`pointermove`,`click`,`dblclick`,`wheel`,`keydown`],Xt=class{#e;#t;#n;#r;#i=[];#a=null;#o=[];#s=null;#c=null;#l;#u=null;#d=null;#f=null;#p=null;#m;#h;constructor(e,t,n){this.#e=e,this.#l=t;let r=t.ownerDocument;this.#t=r,bt(r),this.#m=n.colorScheme??`auto`;let i=n.position??`bottom`;this.#h=i;let 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`),Y(this.#n,this.#m),this.#r=r.createElement(`div`),this.#r.className=`zine-controls-bar`,this.#n.appendChild(this.#r),this.#n.addEventListener(`keydown`,e=>this.#k(e));for(let e of Yt)this.#n.addEventListener(e,e=>this.#_(e));this.#g(t,i,a);let o=()=>this.#A();this.#o.push(e.on(`pageChanged`,o)),this.#o.push(e.on(`zoomChanged`,o)),this.#o.push(e.on(`flipEnd`,o));let s=e=>{if(!this.#a)return;let t=e.target;this.#a.el.contains(t)||this.#a.trigger.contains(t)||this.#O()};r.addEventListener(`pointerdown`,s,!0),this.#o.push(()=>r.removeEventListener(`pointerdown`,s,!0))}#g(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.#y(e.items??z);let t=e.arrows??!0;t!==!1&&(this.#p=new Gt(this.#e,this.#l,this.#m,t===!0?null:t)),this.#A(),this.#N()}destroy(){for(let e of this.#o)e();this.#o=[],this.#O(),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}#_(e){e.stopPropagation()}#v(e=()=>this.#O()){return{zine:this.#e,close:e,colorScheme:this.#m}}#y(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=lt(t),n;e.render?(n=e.render(this.#v()),this.#i.push({el:n,def:e})):n=this.#S(e,`zine-controls-btn`),this.#r.appendChild(n)}}#b(e){return typeof e.title==`function`?e.title(this.#v()):e.title}#x(e){return typeof e.icon==`function`?e.icon(this.#v()):e.icon}#S(e,t,n=!1){let r=this.#t.createElement(`button`),i=this.#b(e),a=this.#x(e);if(r.type=`button`,r.className=t,r.title=i,r.setAttribute(`aria-label`,i),a&&r.appendChild(P(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.#C(e,r)),this.#i.push({el:r,def:e}),r}#C(e,t){if(e.isDisabled?.(this.#v()))return;if(e.children){this.#a?.trigger===t?this.#O():this.#T(e,t);return}if(t.classList.contains(`zine-controls-busy`))return;let n=e.action?.(this.#v());n&&typeof n.then==`function`&&(this.#w(t,!0),n.finally(()=>{this.#w(t,!1),this.#A()})),this.#A()}#w(e,t){e.classList.toggle(`zine-controls-busy`,t),e.setAttribute(`aria-busy`,String(t)),e.disabled=t}#T(e,t){this.#O();let n=this.#t.createElement(`div`);n.className=`zine-controls-menu`,n.setAttribute(`role`,`menu`);let r=this.#v();for(let t of e.children??[]){if(t===`|`)continue;let e=lt(t);if(e.isVisible&&!e.isVisible(r))continue;let i;e.render?(i=e.render(this.#v()),this.#i.push({el:i,def:e})):i=this.#S(e,`zine-controls-btn`,!0),i.setAttribute(`role`,`menuitem`),n.appendChild(i)}this.#E(n,t),this.#A(),n.querySelector(`button`)?.focus()}#E(e,t){this.#n.appendChild(e),this.#a={el:e,trigger:t},t.setAttribute(`aria-expanded`,`true`),this.#D(e,t)}#D(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=`${this.#h===`bottom`||s>=0?s:o}px`}#O(){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()}#k(e){if(e.key===`Escape`&&this.#a){let{trigger:t}=this.#a;this.#O(),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())}#A(){let e=this.#v();for(let{el:t,def:n}of this.#i){let r=n.children?this.#M(n,e):n.isVisible?.(e);r!==void 0&&(t.style.display=r?``:`none`);let i=t.classList.contains(`zine-controls-busy`),a=(n.isDisabled?.(e)??!1)||i;for(let e of this.#j(t))e.disabled=a;if(this.#j(t).length||t.setAttribute(`aria-disabled`,String(a)),t.classList.toggle(`zine-controls-off`,a),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(P(this.#t,n.icon(e)))}this.#s&&this.#t.activeElement!==this.#s&&(this.#s.value=String(this.#e.getPage()+1))}#j(e){return e instanceof HTMLButtonElement||e instanceof HTMLInputElement?[e]:[...e.querySelectorAll(`button, input`)]}#M(e,t){return e.isVisible&&!e.isVisible(t)?!1:(e.children??[]).some(e=>{if(e===`|`)return!1;let n=lt(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=!1,i=()=>{if(r)return;r=!0;let e=Number(t.value),n=Math.max(0,this.#e.getPageCount()-1),i=Number.isFinite(e)?Math.min(Math.max(Math.round(e)-1,0),n):this.#e.getPage();i===this.#e.getPage()?t.value=String(this.#e.getPage()+1):this.#e.flipTo(i)};return t.addEventListener(`focus`,()=>{r=!1}),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(i(),t.blur())}),t.addEventListener(`blur`,i),e.append(t,n),this.#s=t,e}openPanel(){return this.#d}hasOutline(){return this.#f===!0}#N(){this.#f!==null||!this.#e.canOutline()||(this.#f=!1,this.#e.getOutline().then(e=>{if(e.length===0)return;this.#f=!0,this.#A();let t=this.#a;if(t){let e=this.#i.find(e=>e.el===t.trigger)?.def;this.#O(),e&&this.#T(e,t.trigger)}}))}togglePanel(e){let t=this.#d;this.#u?.destroy(),this.#u=null,this.#d=null,t!==e&&(this.#u=new Jt[e](this.#e,this.#l,{onDismiss:()=>this.togglePanel(e)}),Y(this.#u.root,this.#m),this.#d=e),this.#A()}}})),Qt=r({DEFAULT_ITEMS:()=>z,ICONS:()=>F,createIcon:()=>P,defineControl:()=>L,getControl:()=>ct,mountControls:()=>$t});function $t(e,t,n={}){let r=new Xt(e,t,n);return qt(r),r.mount(n),()=>r.destroy()}var en=n((()=>{Zt(),B(),I()}));D();var tn=.25,nn=.0015,rn=6,an=250,on=24,sn=2*an,cn=1.55,ln=32,un=60,dn=2.5,fn=1.5,pn=120,mn=.85,hn=.72;function gn(e,t,n){let r=Math.max(0,t-ln),i=Math.min(e.length,t+n+ln),a=e.slice(r,i).replace(/\s+/g,` `).trim();return`${r>0?`…`:``}${a}${i<e.length?`…`:``}`}var _n=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=-1/0;#se=null;#ce=null;#le=new Set;#ue;#de=null;#fe;#pe=null;#me=null;#he=`download`;#ge=1;#_e=0;#ve=null;#ye;debug={setFlipProgress:(e,t)=>{this.#z?.setFlipProgress(e,t)}};constructor(e,t){Sn(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=$e(t.source,{frontCover:t.frontCover,backCover:t.backCover,pages:t.pages});let n=t.direction??`ltr`;this.#a=n,this.#x=(t.deepLink??!0)&&y(),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.#ue=t.controls??!0,this.#fe=t.loading??!0,this.#b=t.startPage,typeof this.#t.open!=`function`&&this.#Nt(),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??an:0,this.#ye=this.#et(t.renderer??`auto`)}get ready(){return this.#ye}getPageCount(){return this.#t.pageCount}getPage(){return this.#D}get container(){return this.#e}getPageBox(){return this.#z?.measure().book??null}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.#_t(),this.#vt())}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.#gt(e)}else{if(!this.#_)return;this.#_=!1,this.#_t()}this.#vt()}}getPageImage(e){return this.#At(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`&&this.#e.ownerDocument?.defaultView?.navigator?.pdfViewerEnabled!==!1}async print(){let e=await this.getSourceFile(),t=this.#e.ownerDocument;if(!e||!t)return!1;let{url:n,revoke:r}=await this.#be(e,t),i=t.createElement(`iframe`);return i.style.cssText=`position:fixed;right:0;bottom:0;width:1px;height:1px;opacity:0;border:0;`,i.setAttribute(`aria-hidden`,`true`),i.src=n,new Promise(e=>{let a=!1,o=t=>{a||(a=!0,setTimeout(()=>{i.remove(),r&&URL.revokeObjectURL(n)},6e4),e(t))};i.addEventListener(`load`,()=>{try{let e=i.contentWindow;if(!e)return o(!1);e.focus(),e.print(),o(!0)}catch{o(!1)}}),i.addEventListener(`error`,()=>o(!1)),t.body.appendChild(i)})}canOutline(){return typeof this.#t.getOutline==`function`}getOutline(){if(!this.#ce){let e=this.#t.getOutline;this.#ce=typeof e==`function`?Promise.resolve(e.call(this.#t)).catch(()=>[]):Promise.resolve([])}return this.#ce}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{url:n,revoke:r}=await this.#be(e,t),i=t.createElement(`a`);return i.href=n,i.download=e.filename,i.rel=`noopener`,t.body.appendChild(i),i.click(),i.remove(),r&&setTimeout(()=>URL.revokeObjectURL(n),1e4),!0}async#be(e,t){if(e.revoke||!this.#xe(e.url,t))return{url:e.url,revoke:e.revoke??!1};try{let t=await(await fetch(e.url)).blob();return{url:URL.createObjectURL(t),revoke:!0}}catch{return{url:e.url,revoke:!1}}}#xe(e,t){let n=t.defaultView?.location?.href;if(!n)return!1;try{return new URL(e,n).origin!==new URL(n).origin}catch{return!1}}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:gn(t,i,r.length)})}return a}flipNext(){this.#Se(1)}flipPrev(){this.#Se(-1)}#Se(e){this.#Ce(()=>this.#Oe(this.#E+e))}flipTo(e){let t=Q(e,0,Math.max(0,this.#t.pageCount-1));this.#Ce(()=>this.#Oe(this.#Mt(t)))}#Ce(e){this.#i.state===`idle`?e():this.#J?(this.#q=null,this.#we(),e()):this.#q=e}#we(){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())}#Te(){let e=this.#q;if(!e){this.#Et();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=r.screenAt?.(this.#I),a=t??(i?{x:i.x+this.#L+i.width/2,y:i.y+this.#R+i.height/2}:null)??{x:r.containerWidth/2,y:r.containerHeight/2},o=this.#I,s=n===1?0:a.x-n/o*(a.x-this.#L),c=n===1?0:a.y-n/o*(a.y-this.#R);[s,c]=this.#De(s,c,n,r.containerWidth,r.containerHeight),this.#I=n,this.#L=s,this.#R=c,this.#z.setViewTransform(n,s,c),o>1!=n>1&&this.#Ee(),this.#St(),this.#n.emit(`zoomChanged`,{scale:n})}resetZoom(){this.setZoom(1)}#Ee(){this.#e.style.touchAction=this.#I>1?`none`:`pan-y`}#De(e,t,n,r,i){let a=typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1,o=e=>Math.round(e*a)/a||0,s=this.#z?.measure().screenAt?.(n)??{x:0,y:0,width:r*n,height:i*n},[c,l]=vn(s.x,s.width,r),[u,d]=vn(s.y,s.height,i);return[o(Q(e,c,l)),o(Q(t,u,d))]}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.#Ge(),this.#P?.disconnect(),this.#C?.stop(),this.#C=null,this.#w?.(),this.#x&&b(),this.#de?.(),this.#it(),this.#se?.(),this.#ne?.(),this.#ie?.(),this.#re?.(),this.#te?.(),this.#ve!==null&&clearTimeout(this.#ve),this.#_e++,this.#z?.destroy(),this.#z=null,this.#t.destroy(),this.#n.clear()}#Oe(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.#Ne(e);this.#n.emit(`flipStart`,{from:this.#D,to:n}),this.#ke(e,t,n,++this.#Y)}async#ke(e,t,n,r){let i=this.#T[e],a=i?await this.#kt(i):{left:null,right:null};r===this.#Y&&(this.#z?.beginFlip(this.#O,a,t,{fill:this.#h,curl:this.#mt(),anchor:{y:this.#l}}),this.#Ae(0,1,t,()=>this.#Me(e,n,a),()=>this.#je(n)))}#Ae(e,t,n,r,i){let a=this.#pt()*Math.abs(t-e);if(a<=0){this.#z?.setFlipProgress(t,n),r();return}let o={toT:t,direction:n,onDone:r};this.#J=o;let s=performance.now(),c=!1,l=u=>{if(this.#J!==o)return;let d=Math.min(1,(u-s)/a),f=this.#h?bn(d):yn(d);i&&!c&&f>=(this.#h?hn:mn)&&(c=!0,i()),d<1?(this.#z?.setFlipProgress(e+(t-e)*f,n),this.#H=requestAnimationFrame(l)):(this.#z?.setFlipProgress(t,n),this.#H=null,this.#J=null,r())};this.#H=requestAnimationFrame(l)}#je(e){this.#D!==e&&(this.#D=e,this.#ft(),this.#n.emit(`pageChanged`,{page:e}))}#Me(e,t,n){let r=this.#T[e];this.#E=e,this.#O=n,r&&this.#yt(r,n),this.#jt(),this.#i.send(`settle`),this.#oe=performance.now(),this.#je(t),this.#n.emit(`flipEnd`,{page:t}),this.#Te()}#Ne(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}#Pe(e,t){if(this.#Z||!this.#z)return;if(this.#Ge(),this.#I>1){if(this.#i.send(`panStart`)===null)return;this.#X={baseTx:this.#L,baseTy:this.#R};return}let n=this.#Ve(),r=this.#He(e,t);this.#G=r;let i=Math.min(n.width,n.height)*tn,a=r.x>=0&&r.x<=n.width&&r.y>=0&&r.y<=n.height,o=r.x<=i||r.x>=n.width-i,s=a&&o;if(this.#i.state!==`idle`){if(!this.#J||!s){this.#W=null;return}this.#we()}if(!s)return;this.#l=Q(r.y/n.height,0,1);let c=r.x>n.width/2,l=this.#a===`rtl`?!c:c,u=this.#E+(l?1:-1);u<0||u>=this.#T.length||(this.#W={direction:l?`forward`:`backward`,targetIndex:u,toPage:this.#Ne(u),width:n.width})}#Fe(){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.#Ie(e.targetIndex,e.direction)))}async#Ie(e,t){let n=this.#T[e],r=n?await this.#kt(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.#mt(),anchor:{y:this.#l}}),this.#z?.setFlipProgress(this.#U.t,t))}#Le(e,t){if(this.#Z)return;if(this.#X){if(!this.#z)return;let n=this.#z.measure(),[r,i]=this.#De(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.#St();return}this.#W&&Math.hypot(e,t)>rn&&this.#Fe();let n=this.#U;n&&(n.t=Q((n.direction===`forward`?-e:e)/n.width,0,1),this.#z?.setFlipProgress(n.t,n.direction))}#Re(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.#ze(e)||this.#Be(e);return}this.#U=null,this.#i.send(`release`);let n=e.swipe&&Math.abs(e.vx)>Math.abs(e.vy),r=t.direction===`forward`?e.vx<0:e.vx>0,i=n&&r,a=n&&!r;i||t.t>=.5&&!a?this.#Ae(t.t,1,t.direction,()=>this.#Me(t.targetIndex,t.toPage,t.toContent),()=>this.#je(t.toPage)):this.#Ae(t.t,0,t.direction,()=>this.#Ke())}#ze(e){if(this.#I>1||!e.swipe||Math.abs(e.dx)<=Math.abs(e.dy))return!1;let t=this.#a===`rtl`?e.dx>0:e.dx<0,n=t?`forward`:`backward`;if(!this.#We(n))return!1;let r=t?1:-1;return this.#Ce(()=>this.#Oe(this.#E+r)),!0}#Be(e){if(this.#u===`off`||this.#I>1||!this.#G||Math.abs(e.dx)>rn||Math.abs(e.dy)>rn)return;let t=this.#Ue(this.#G);if(!t||!this.#We(t))return;this.#l=Q(this.#G.y/this.#Ve().height,0,1);let n=t===`forward`?1:-1,r=()=>this.#Oe(this.#E+n);if(this.#Ge(),this.#p<=0){this.#Ce(r);return}this.#K=setTimeout(()=>{this.#K=null,this.#Ce(r)},this.#p)}#Ve(){let e=this.#z.measure();return e.content??e.book??{x:0,y:0,width:e.containerWidth,height:e.containerHeight}}#He(e,t){let n=this.#e.getBoundingClientRect(),r=this.#Ve();return{x:e-n.left-r.x,y:t-n.top-r.y}}#Ue(e){if(!this.#z)return null;let t=this.#Ve().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`}#We(e){let t=this.#E+(e===`forward`?1:-1);return t>=0&&t<this.#T.length}#Ge(){this.#K!==null&&(clearTimeout(this.#K),this.#K=null)}#Ke(){let e=this.#T[this.#E];e&&this.#yt(e,this.#O),this.#i.send(`settle`),this.#n.emit(`flipEnd`,{page:this.#D}),this.#Te()}#qe(){if(this.#W=null,this.#Ge(),this.#U){this.#U=null,this.#i.send(`release`),this.#i.send(`settle`);let e=this.#T[this.#E];e&&this.#yt(e,this.#O)}else this.#X&&(this.#X=null,this.#i.send(`panEnd`));this.#Z=!0,this.#Q=this.#I}#Je(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})}#Ye(){this.#Z=!1}#Xe(){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*nn);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)}#Qe(){let e=e=>{let t=this.#M;if(!this.#A||t===null||!this.#z)return;let n=performance.now(),r=this.#ae;if(!(r!==null&&n-r.t<=an&&Math.hypot(e.clientX-r.x,e.clientY-r.y)<=on)){this.#ae={t:n,x:e.clientX,y:e.clientY};return}this.#ae=null,this.#$e(e.clientX,e.clientY,t)};this.#e.addEventListener(`click`,e),this.#ie=()=>this.#e.removeEventListener(`click`,e)}#$e(e,t,n){if(this.#I<=1&&this.#u!==`off`&&!this.#f){let n=this.#He(e,t),r=this.#Ue(n);if(r!==null&&this.#We(r)||this.#i.state===`animating`||performance.now()-this.#oe<=sn)return}this.#Ge();let r=n.find(e=>e>this.#I+1e-6)??n[0]??this.#I,i=this.#e.getBoundingClientRect();this.setZoom(r,{x:e-i.left,y:t-i.top})}async#et(e){let t=Qe(e);if(this.#t.onProgress?.(e=>this.#tt(e)),typeof this.#t.open==`function`){this.#nt();try{await this.#t.open(),this.#Nt()}catch(e){throw this.#it(),e}this.#rt(`preparing`)}this.#t.prefetch([this.#D]);let n=await t,r=await this.#at(n);this.#z=r,this.#t.onPageUpdate?.(e=>this.#xt(e)),this.#gt(r.measure().containerWidth);let i=new p({onStart:e=>this.#Pe(e.x,e.y),onMove:e=>this.#Le(e.dx,e.dy),onEnd:e=>this.#Re(e)}),a=new g({onPinchStart:()=>this.#qe(),onPinchMove:e=>this.#Je(e.centerX,e.centerY,e.scale),onPinchEnd:()=>this.#Ye()});this.#te=m(this.#e,{pointer:i,pinch:a}),this.#Ee(),this.#Ze(),this.#Qe(),this.#Xe(),this.#st(),this.#se=this.#ut(),await this.#vt(),this.#it(),this.#Dt(),this.#jt(),this.#ft(),this.#lt(),await this.#ct(),this.#n.emit(`ready`)}#tt(e){this.#me=e,this.#n.emit(`progress`,e),this.#pe?.update(e)}async#nt(){if(this.#fe===!1||this.#V)return;let e=this.#e;if(!(!e.ownerDocument||typeof e.appendChild!=`function`))try{let{mountLoading:t}=await Promise.resolve().then(()=>(st(),nt));if(this.#he===`done`||this.#V)return;this.#pe=t(e),this.#me&&this.#pe.update(this.#me),this.#he===`preparing`&&this.#pe.preparing()}catch{}}#rt(e){this.#he!==`done`&&(this.#he=e,this.#pe?.preparing())}#it(){this.#he=`done`,this.#pe?.destroy(),this.#pe=null}async#at(e){try{return await e.mount(this.#e),e.onFatal?.(()=>{this.#ot()}),e}catch{e.destroy();let t=await Qe(`css`);return await t.mount(this.#e),this.#B=!0,this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`}),t}}async#ot(){if(this.#B||this.#V)return;this.#B=!0,this.#z?.destroy(),this.#z=null;let e=await Qe(`css`);if(this.#V){e.destroy();return}await e.mount(this.#e),this.#z=e,this.#gt(e.measure().containerWidth),await this.#vt(),this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`})}#st(){if(typeof matchMedia!=`function`)return;let e=matchMedia(`(prefers-reduced-motion: reduce)`);this.#$=e.matches,e.addEventListener?.(`change`,e=>{this.#$=e.matches})}async#ct(){if(this.#ue===!1||this.#V)return;let e=this.#e;if(!(!e.ownerDocument||typeof e.appendChild!=`function`))try{let{mountControls:t}=await Promise.resolve().then(()=>(en(),Qt));if(this.#V)return;let n=this.#ue===!0?{}:this.#ue;this.#de=t(this,e,n)}catch{}}#lt(){if(!this.#x||globalThis.location===void 0)return;let e=globalThis;this.#C=C(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=S(n.hash,Q(e,0,Math.max(0,this.#t.pageCount-1))),n.toString()}#ut(){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.#dt(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}}#dt(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}}#ft(){this.#ee&&(this.#ee.textContent=`Page ${this.#D+1} of ${this.#t.pageCount}`)}#pt(){return this.#$?pn:this.#k*(this.#h?cn:1)}#mt(){return this.#$?`simple`:this.#c}update(){!this.#z||this.#i.state!==`idle`||(this.#gt(this.#z.measure().containerWidth),this.#vt())}#ht(){return this.#_||this.#o===`single`?`single`:this.#o}#gt(e){let t=this.#v&&a(e,this.#m);t!==this.#_&&(this.#_=t,this.#_t())}#_t(){let e=this.#ht(),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.#Mt(this.#D),t&&this.#n.emit(`spreadChanged`,{mode:e,singlePage:this.#h})}async#vt(){let e=this.#T[this.#E];!e||!this.#z||(this.#O=await this.#kt(e),this.#yt(e,this.#O))}#yt(e,t){this.#z?.renderSpread(e,t,{fill:this.#h}),this.#bt(),this.#ge=1,this.#St()}#bt(){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)}#xt(e){if(this.#i.state!==`idle`){this.#le.add(e);return}let t=this.#T[this.#E];t&&(t.left===e||t.right===e)&&this.#vt()}#St(){this.#ve!==null&&clearTimeout(this.#ve);let e=this.#wt();if(e!==this.#ge){if(e===1){this.#_e++,this.#ge=1,this.#vt();return}this.#ve=setTimeout(()=>{this.#ve=null,this.#Tt()},un)}}#Ct(){let e=this.#z?.measure(),t=e?.content??e?.book;if(!t||t.width<=0)return 1;let n=this.#O,r=+!!n.left+ +!!n.right;if(r===0)return 1;let i=t.width/r,a=typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1,o=0;for(let e of[n.left,n.right]){if(!e||e.width<=0)continue;let t=e.width/this.#ge;o=Math.max(o,i*a/t)}return o===0?1:o}#wt(){let e=Math.max(1,fn/(typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1)),t=this.#I<=1?1:this.#I,n=this.#Ct()*Math.max(t,e);return n<=1.001?1:Math.min(Math.ceil(n*2)/2,dn)}async#Tt(){let e=this.#T[this.#E];if(!this.#z||!e)return;let t=this.#wt();if(t===1||t===this.#ge||this.#i.state!==`idle`)return;let n=++this.#_e,r={x:0,y:0,width:1,height:1},i=await Promise.all([e.left,e.right].map(async e=>{if(e===null)return null;try{return await this.#t.get(e,{scale:t,region:r})}catch(t){return this.#n.emit(`sourceError`,{index:e,error:t}),null}}));if(n!==this.#_e||this.#wt()!==t||this.#i.state!==`idle`)return;let a=i[0]??null,o=i[1]??null;a===this.#O.left&&o===this.#O.right||(this.#ge=t,this.#O={left:a,right:o},this.#z.renderSpread(e,this.#O,{fill:this.#h}))}#Et(){if(this.#le.size===0)return;let e=this.#T[this.#E],t=e!==void 0&&[e.left,e.right].some(e=>e!==null&&this.#le.has(e));this.#le.clear(),t&&this.#vt()}#Dt(){typeof ResizeObserver>`u`||(this.#P=new ResizeObserver(()=>this.#Ot()),this.#P.observe(this.#e))}#Ot(){this.#F||(this.#F=!0,requestAnimationFrame(()=>{this.#F=!1,this.update()}))}async#kt(e){let[t,n]=await Promise.all([this.#At(e.left),this.#At(e.right)]);return{left:t,right:n}}async#At(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}}#jt(){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)}#Mt(e){let t=this.#T.findIndex(t=>t.left===e||t.right===e);return t===-1?0:t}#Nt(){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.#ht();this.#h=n===`single`,this.#T=i(e,{direction:this.#a,mode:n});let r=this.#x?x(globalThis.location?.hash??``):null;this.#D=Q(r??t??0,0,e-1),this.#E=this.#Mt(this.#D)}};function Q(e,t,n){return e<t?t:e>n?n:e}function vn(e,t,n){if(t<=n){let r=(n-t)/2-e;return[r,r]}return[n-(e+t),-e]}function yn(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function bn(e){return 1-(1-yn(e))**1.3}function xn(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function Sn(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 ${xn(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){if(typeof s==`object`&&s){if(typeof s.deform!=`function`)throw Error(`Zine: a curl model must have a deform() function.`)}else if(T.includes(s))throw Error(`Zine: the '${String(s)}' curl is not bundled. Import it and pass the model: import { ${String(s)} } from '@zinejs/core/curls' → curl: ${String(s)}`);else if(!w.includes(s))throw Error(`Zine: curl must be ${w.join(` or `)}, or a model imported from '@zinejs/core/curls' (${T.join(`, `)}); got ${JSON.stringify(s)}.`)}for(let e of[`deepLink`,`disableContextMenu`,`responsiveSpread`,`loading`])if(n[e]!==void 0&&typeof n[e]!=`boolean`)throw Error(`Zine: ${e} must be a boolean; got ${xn(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 ${xn(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=c?.colorScheme;if(u!==void 0&&![`light`,`dark`,`auto`].includes(u))throw Error(`Zine: controls.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(u)}.`);let d=c?.arrows;if(d!==void 0&&typeof d!=`boolean`&&![`desktop`,`mobile`].includes(d))throw Error(`Zine: controls.arrows must be a boolean, 'desktop', or 'mobile'; got ${JSON.stringify(d)}.`);let f=n.spreadMode;if(f!==void 0&&![`double`,`single`,`cover`,`book`].includes(f))throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(f)}.`);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 p=n.pages;if(p!==void 0&&(typeof p!=`object`||!p||Array.isArray(p)))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),Cn(n.zoom),wn(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 Cn(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 wn(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 Tn=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(),D(),e.CURL_TYPES=w,e.DEFAULT_ITEMS=z,e.IMPORTABLE_CURLS=T,e.ImageSource=Tn,e.Zine=_n,e.defineControl=L,e.getControl=ct});
587
825
  //# sourceMappingURL=index.umd.js.map