@zinejs/core 0.8.0 → 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/controls/styles.d.ts +1 -1
- package/dist/controls/types.d.ts +7 -2
- package/dist/{controls-Djjk8Yac.js → controls-DgEXR2zi.js} +69 -57
- package/dist/controls-DgEXR2zi.js.map +1 -0
- package/dist/index.js +188 -175
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +36 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/loading/loading.d.ts +1 -1
- package/dist/{loading-C0qbANt2.js → loading-BBK6YbSW.js} +2 -2
- package/dist/loading-BBK6YbSW.js.map +1 -0
- package/dist/{share-DXAfK9rJ.js → share-WXdscwp3.js} +2 -2
- package/dist/{share-DXAfK9rJ.js.map → share-WXdscwp3.js.map} +1 -1
- package/dist/styles-B8fFoYm_.js +40 -0
- package/dist/styles-B8fFoYm_.js.map +1 -0
- package/package.json +1 -1
- package/dist/controls-Djjk8Yac.js.map +0 -1
- package/dist/loading-C0qbANt2.js.map +0 -1
- package/dist/styles-CgCzjFUk.js +0 -40
- package/dist/styles-CgCzjFUk.js.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -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
|
}
|
|
@@ -223,6 +223,35 @@ void main() {
|
|
|
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; }
|
|
@@ -792,5 +821,5 @@ void main() {
|
|
|
792
821
|
@media (prefers-reduced-motion: no-preference) {
|
|
793
822
|
.zine-controls-btn { transition: background 120ms ease; }
|
|
794
823
|
}
|
|
795
|
-
`})),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:e=>{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:e=>{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=[];constructor(e,t,n={}){this.#e=e;let r=t.ownerDocument;this.#t=r,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.#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((()=>{Z(),Bt=208,Vt=180,Ht=2,Ut=class{root;#e;#t;#n;#r;#i;#a=0;#o=null;constructor(e,t,n={}){this.#e=e;let r=t.ownerDocument;this.#t=r,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.#c(),Vt)}),this.#r.addEventListener(`keydown`,e=>{e.key===`Enter`&&(this.#o&&clearTimeout(this.#o),this.#c())}),this.#i=r.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((()=>{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.#O(e));for(let e of Yt)this.#n.addEventListener(e,e=>this.#_(e));this.#g(t,i,a);let o=()=>this.#k();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.#D()};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.#k(),this.#M()}destroy(){for(let e of this.#o)e();this.#o=[],this.#D(),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.#D()){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())){if(e.children){this.#a?.trigger===t?this.#D():this.#w(e,t);return}e.action?.(this.#v()),this.#k()}}#w(e,t){this.#D();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.#T(n,t),this.#k(),n.querySelector(`button`)?.focus()}#T(e,t){this.#n.appendChild(e),this.#a={el:e,trigger:t},t.setAttribute(`aria-expanded`,`true`),this.#E(e,t)}#E(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`}#D(){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()}#O(e){if(e.key===`Escape`&&this.#a){let{trigger:t}=this.#a;this.#D(),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())}#k(){let e=this.#v();for(let{el:t,def:n}of this.#i){let r=n.children?this.#j(n,e):n.isVisible?.(e);r!==void 0&&(t.style.display=r?``:`none`);let i=n.isDisabled?.(e)??!1;for(let e of this.#A(t))e.disabled=i;if(this.#A(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(P(this.#t,n.icon(e)))}this.#s&&this.#t.activeElement!==this.#s&&(this.#s.value=String(this.#e.getPage()+1))}#A(e){return e instanceof HTMLButtonElement||e instanceof HTMLInputElement?[e]:[...e.querySelectorAll(`button, input`)]}#j(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}#M(){this.#f!==null||!this.#e.canOutline()||(this.#f=!1,this.#e.getOutline().then(e=>{if(e.length===0)return;this.#f=!0,this.#k();let t=this.#a;if(t){let e=this.#i.find(e=>e.el===t.trigger)?.def;this.#D(),e&&this.#w(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.#k()}}})),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.#Mt(),this.#k=t.flipDuration??800,this.#A=t.zoom?.enabled??!0,this.#j=t.zoom?.wheel??!0;let r=t.zoom?.doubleClick,i=r===!1?[]:[...r??[1,2,4]].sort((e,t)=>e-t);this.#M=i.length>0?i:null,this.#N=t.zoom?.max??4;let a=this.#A&&this.#M!==null,o=t.zoom?.doubleClickInFlipZone??this.#u===`half`;this.#f=this.#u!==`off`&&a&&o&&t.clickFlipDelay!==0,this.#p=this.#f?t.clickFlipDelay??an:0,this.#ye=this.#$e(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.#gt(),this.#_t())}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.#ht(e)}else{if(!this.#_)return;this.#_=!1,this.#gt()}this.#_t()}}getPageImage(e){return this.#kt(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 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=e.url,r=e.revoke??!1;if(!r&&this.#be(n,t))try{let e=await(await fetch(n)).blob();n=URL.createObjectURL(e),r=!0}catch{}let 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}#be(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.#xe(1)}flipPrev(){this.#xe(-1)}#xe(e){this.#Se(()=>this.#De(this.#E+e))}flipTo(e){let t=Q(e,0,Math.max(0,this.#t.pageCount-1));this.#Se(()=>this.#De(this.#jt(t)))}#Se(e){this.#i.state===`idle`?e():this.#J?(this.#q=null,this.#Ce(),e()):this.#q=e}#Ce(){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())}#we(){let e=this.#q;if(!e){this.#Tt();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.#Ee(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.#Te(),this.#xt(),this.#n.emit(`zoomChanged`,{scale:n})}resetZoom(){this.setZoom(1)}#Te(){this.#e.style.touchAction=this.#I>1?`none`:`pan-y`}#Ee(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.#We(),this.#P?.disconnect(),this.#C?.stop(),this.#C=null,this.#w?.(),this.#x&&b(),this.#de?.(),this.#rt(),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()}#De(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.#Me(e);this.#n.emit(`flipStart`,{from:this.#D,to:n}),this.#Oe(e,t,n,++this.#Y)}async#Oe(e,t,n,r){let i=this.#T[e],a=i?await this.#Ot(i):{left:null,right:null};r===this.#Y&&(this.#z?.beginFlip(this.#O,a,t,{fill:this.#h,curl:this.#pt(),anchor:{y:this.#l}}),this.#ke(0,1,t,()=>this.#je(e,n,a),()=>this.#Ae(n)))}#ke(e,t,n,r,i){let a=this.#ft()*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)}#Ae(e){this.#D!==e&&(this.#D=e,this.#dt(),this.#n.emit(`pageChanged`,{page:e}))}#je(e,t,n){let r=this.#T[e];this.#E=e,this.#O=n,r&&this.#vt(r,n),this.#At(),this.#i.send(`settle`),this.#oe=performance.now(),this.#Ae(t),this.#n.emit(`flipEnd`,{page:t}),this.#we()}#Me(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}#Ne(e,t){if(this.#Z||!this.#z)return;if(this.#We(),this.#I>1){if(this.#i.send(`panStart`)===null)return;this.#X={baseTx:this.#L,baseTy:this.#R};return}let n=this.#Be(),r=this.#Ve(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.#Ce()}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.#Me(u),width:n.width})}#Pe(){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.#Fe(e.targetIndex,e.direction)))}async#Fe(e,t){let n=this.#T[e],r=n?await this.#Ot(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.#pt(),anchor:{y:this.#l}}),this.#z?.setFlipProgress(this.#U.t,t))}#Ie(e,t){if(this.#Z)return;if(this.#X){if(!this.#z)return;let n=this.#z.measure(),[r,i]=this.#Ee(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.#xt();return}this.#W&&Math.hypot(e,t)>rn&&this.#Pe();let n=this.#U;n&&(n.t=Q((n.direction===`forward`?-e:e)/n.width,0,1),this.#z?.setFlipProgress(n.t,n.direction))}#Le(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.#Re(e)||this.#ze(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.#ke(t.t,1,t.direction,()=>this.#je(t.targetIndex,t.toPage,t.toContent),()=>this.#Ae(t.toPage)):this.#ke(t.t,0,t.direction,()=>this.#Ge())}#Re(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.#Ue(n))return!1;let r=t?1:-1;return this.#Se(()=>this.#De(this.#E+r)),!0}#ze(e){if(this.#u===`off`||this.#I>1||!this.#G||Math.abs(e.dx)>rn||Math.abs(e.dy)>rn)return;let t=this.#He(this.#G);if(!t||!this.#Ue(t))return;this.#l=Q(this.#G.y/this.#Be().height,0,1);let n=t===`forward`?1:-1,r=()=>this.#De(this.#E+n);if(this.#We(),this.#p<=0){this.#Se(r);return}this.#K=setTimeout(()=>{this.#K=null,this.#Se(r)},this.#p)}#Be(){let e=this.#z.measure();return e.content??e.book??{x:0,y:0,width:e.containerWidth,height:e.containerHeight}}#Ve(e,t){let n=this.#e.getBoundingClientRect(),r=this.#Be();return{x:e-n.left-r.x,y:t-n.top-r.y}}#He(e){if(!this.#z)return null;let t=this.#Be().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`}#Ue(e){let t=this.#E+(e===`forward`?1:-1);return t>=0&&t<this.#T.length}#We(){this.#K!==null&&(clearTimeout(this.#K),this.#K=null)}#Ge(){let e=this.#T[this.#E];e&&this.#vt(e,this.#O),this.#i.send(`settle`),this.#n.emit(`flipEnd`,{page:this.#D}),this.#we()}#Ke(){if(this.#W=null,this.#We(),this.#U){this.#U=null,this.#i.send(`release`),this.#i.send(`settle`);let e=this.#T[this.#E];e&&this.#vt(e,this.#O)}else this.#X&&(this.#X=null,this.#i.send(`panEnd`));this.#Z=!0,this.#Q=this.#I}#qe(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})}#Je(){this.#Z=!1}#Ye(){if(!this.#S)return;let e=e=>e.preventDefault();this.#e.addEventListener(`contextmenu`,e),this.#re=()=>this.#e.removeEventListener(`contextmenu`,e)}#Xe(){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)}#Ze(){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.#Qe(e.clientX,e.clientY,t)};this.#e.addEventListener(`click`,e),this.#ie=()=>this.#e.removeEventListener(`click`,e)}#Qe(e,t,n){if(this.#I<=1&&this.#u!==`off`&&!this.#f){let n=this.#Ve(e,t),r=this.#He(n);if(r!==null&&this.#Ue(r)||this.#i.state===`animating`||performance.now()-this.#oe<=sn)return}this.#We();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#$e(e){let t=Qe(e);if(this.#t.onProgress?.(e=>this.#et(e)),typeof this.#t.open==`function`){this.#tt();try{await this.#t.open(),this.#Mt()}catch(e){throw this.#rt(),e}this.#nt(`preparing`)}this.#t.prefetch([this.#D]);let n=await t,r=await this.#it(n);this.#z=r,this.#t.onPageUpdate?.(e=>this.#bt(e)),this.#ht(r.measure().containerWidth);let i=new p({onStart:e=>this.#Ne(e.x,e.y),onMove:e=>this.#Ie(e.dx,e.dy),onEnd:e=>this.#Le(e)}),a=new g({onPinchStart:()=>this.#Ke(),onPinchMove:e=>this.#qe(e.centerX,e.centerY,e.scale),onPinchEnd:()=>this.#Je()});this.#te=m(this.#e,{pointer:i,pinch:a}),this.#Te(),this.#Xe(),this.#Ze(),this.#Ye(),this.#ot(),this.#se=this.#lt(),await this.#_t(),this.#rt(),this.#Et(),this.#At(),this.#dt(),this.#ct(),await this.#st(),this.#n.emit(`ready`)}#et(e){this.#me=e,this.#n.emit(`progress`,e),this.#pe?.update(e)}async#tt(){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{}}#nt(e){this.#he!==`done`&&(this.#he=e,this.#pe?.preparing())}#rt(){this.#he=`done`,this.#pe?.destroy(),this.#pe=null}async#it(e){try{return await e.mount(this.#e),e.onFatal?.(()=>{this.#at()}),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#at(){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.#ht(e.measure().containerWidth),await this.#_t(),this.#n.emit(`rendererFallback`,{from:`webgl2`,to:`css`})}#ot(){if(typeof matchMedia!=`function`)return;let e=matchMedia(`(prefers-reduced-motion: reduce)`);this.#$=e.matches,e.addEventListener?.(`change`,e=>{this.#$=e.matches})}async#st(){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{}}#ct(){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()}#lt(){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.#ut(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}}#ut(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}}#dt(){this.#ee&&(this.#ee.textContent=`Page ${this.#D+1} of ${this.#t.pageCount}`)}#ft(){return this.#$?pn:this.#k*(this.#h?cn:1)}#pt(){return this.#$?`simple`:this.#c}update(){!this.#z||this.#i.state!==`idle`||(this.#ht(this.#z.measure().containerWidth),this.#_t())}#mt(){return this.#_||this.#o===`single`?`single`:this.#o}#ht(e){let t=this.#v&&a(e,this.#m);t!==this.#_&&(this.#_=t,this.#gt())}#gt(){let e=this.#mt(),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.#jt(this.#D),t&&this.#n.emit(`spreadChanged`,{mode:e,singlePage:this.#h})}async#_t(){let e=this.#T[this.#E];!e||!this.#z||(this.#O=await this.#Ot(e),this.#vt(e,this.#O))}#vt(e,t){this.#z?.renderSpread(e,t,{fill:this.#h}),this.#yt(),this.#ge=1,this.#xt()}#yt(){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)}#bt(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.#_t()}#xt(){this.#ve!==null&&clearTimeout(this.#ve);let e=this.#Ct();if(e!==this.#ge){if(e===1){this.#_e++,this.#ge=1,this.#_t();return}this.#ve=setTimeout(()=>{this.#ve=null,this.#wt()},un)}}#St(){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}#Ct(){let e=Math.max(1,fn/(typeof devicePixelRatio==`number`&&devicePixelRatio>0?devicePixelRatio:1)),t=this.#I<=1?1:this.#I,n=this.#St()*Math.max(t,e);return n<=1.001?1:Math.min(Math.ceil(n*2)/2,dn)}async#wt(){let e=this.#T[this.#E];if(!this.#z||!e)return;let t=this.#Ct();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.#Ct()!==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}))}#Tt(){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.#_t()}#Et(){typeof ResizeObserver>`u`||(this.#P=new ResizeObserver(()=>this.#Dt()),this.#P.observe(this.#e))}#Dt(){this.#F||(this.#F=!0,requestAnimationFrame(()=>{this.#F=!1,this.update()}))}async#Ot(e){let[t,n]=await Promise.all([this.#kt(e.left),this.#kt(e.right)]);return{left:t,right:n}}async#kt(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}}#At(){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)}#jt(e){let t=this.#T.findIndex(t=>t.left===e||t.right===e);return t===-1?0:t}#Mt(){let e=this.#t.pageCount;if(!Number.isInteger(e)||e<1)throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);let t=this.#b;if(t!==void 0&&(!Number.isInteger(t)||t<0||t>=e))throw Error(`Zine: startPage ${JSON.stringify(t)} is out of range for a ${e}-page book (valid 0..${e-1}).`);let n=this.#mt();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.#jt(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});
|
|
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});
|
|
796
825
|
//# sourceMappingURL=index.umd.js.map
|