flipbookengine 0.6.5 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +24 -3
  2. package/README.md +136 -8
  3. package/dist/components/App.d.ts +19 -0
  4. package/dist/components/HotspotLayer.d.ts +14 -0
  5. package/dist/components/NotesPanel.d.ts +14 -0
  6. package/dist/components/PluginPanels.d.ts +5 -0
  7. package/dist/components/SearchPanel.d.ts +11 -0
  8. package/dist/components/Toolbar.d.ts +6 -0
  9. package/dist/components/Viewer.d.ts +6 -0
  10. package/dist/core/LayoutManager.d.ts +1 -1
  11. package/dist/core/PdfRenderer.d.ts +11 -0
  12. package/dist/core-entry.d.ts +13 -0
  13. package/dist/core.d.ts +1 -0
  14. package/dist/embed.d.ts +80 -0
  15. package/dist/engine-Dt2Fn6O-.js +4060 -0
  16. package/dist/engine-Dt2Fn6O-.js.map +1 -0
  17. package/dist/engine.d.ts +101 -0
  18. package/dist/feature-Cicli9ie.js +17 -0
  19. package/dist/feature-Cicli9ie.js.map +1 -0
  20. package/dist/flipbook-engine.core.js +8 -0
  21. package/dist/flipbook-engine.core.js.map +1 -0
  22. package/dist/flipbook-engine.css +1 -1
  23. package/dist/flipbook-engine.iife.js +56 -47
  24. package/dist/flipbook-engine.iife.js.map +1 -1
  25. package/dist/flipbook-engine.js +10 -6
  26. package/dist/flipbook-engine.js.map +1 -1
  27. package/dist/flipbook-engine.plugins-annotations.js +14 -0
  28. package/dist/flipbook-engine.plugins-annotations.js.map +1 -0
  29. package/dist/flipbook-engine.plugins-bookmarks.js +16 -0
  30. package/dist/flipbook-engine.plugins-bookmarks.js.map +1 -0
  31. package/dist/flipbook-engine.plugins-deep-link.js +14 -0
  32. package/dist/flipbook-engine.plugins-deep-link.js.map +1 -0
  33. package/dist/flipbook-engine.plugins-hotspots.js +15 -0
  34. package/dist/flipbook-engine.plugins-hotspots.js.map +1 -0
  35. package/dist/flipbook-engine.plugins-notes.js +16 -0
  36. package/dist/flipbook-engine.plugins-notes.js.map +1 -0
  37. package/dist/flipbook-engine.plugins-search.js +15 -0
  38. package/dist/flipbook-engine.plugins-search.js.map +1 -0
  39. package/dist/flipbook-engine.plugins-share.js +13 -0
  40. package/dist/flipbook-engine.plugins-share.js.map +1 -0
  41. package/dist/flipbook-engine.plugins-toc.js +14 -0
  42. package/dist/flipbook-engine.plugins-toc.js.map +1 -0
  43. package/dist/flipbook-engine.plugins.js +5 -0
  44. package/dist/flipbook-engine.plugins.js.map +1 -0
  45. package/dist/flipbook-engine.react.js +1 -1
  46. package/dist/flipbook-engine.vue.js +1 -1
  47. package/dist/i18n/locales/en.d.ts +17 -0
  48. package/dist/i18n/locales/tr.d.ts +17 -0
  49. package/dist/i18n/service.d.ts +51 -0
  50. package/dist/index-BhTR2SK6.js +366 -0
  51. package/dist/index-BhTR2SK6.js.map +1 -0
  52. package/dist/index.d.ts +7 -0
  53. package/dist/model/annotations.d.ts +14 -0
  54. package/dist/model/hotspots.d.ts +40 -0
  55. package/dist/model/search.d.ts +25 -0
  56. package/dist/plugins/annotations.d.ts +4 -0
  57. package/dist/plugins/bookmarks.d.ts +4 -0
  58. package/dist/plugins/deep-link.d.ts +4 -0
  59. package/dist/plugins/feature.d.ts +5 -0
  60. package/dist/plugins/hotspots.d.ts +4 -0
  61. package/dist/plugins/index.d.ts +65 -0
  62. package/dist/plugins/notes.d.ts +4 -0
  63. package/dist/plugins/search.d.ts +4 -0
  64. package/dist/plugins/share.d.ts +4 -0
  65. package/dist/plugins/toc.d.ts +4 -0
  66. package/dist/plugins-annotations.d.ts +1 -0
  67. package/dist/plugins-bookmarks.d.ts +1 -0
  68. package/dist/plugins-deep-link.d.ts +1 -0
  69. package/dist/plugins-hotspots.d.ts +1 -0
  70. package/dist/plugins-notes.d.ts +1 -0
  71. package/dist/plugins-search.d.ts +1 -0
  72. package/dist/plugins-share.d.ts +1 -0
  73. package/dist/plugins-toc.d.ts +1 -0
  74. package/dist/plugins.d.ts +1 -0
  75. package/dist/state/store.d.ts +19 -5
  76. package/dist/vue/index.d.ts +1 -1
  77. package/docs/api-reference.md +206 -0
  78. package/docs/frameworks.md +73 -0
  79. package/docs/getting-started.md +128 -0
  80. package/docs/i18n.md +47 -0
  81. package/docs/migration-0.4.0.md +24 -0
  82. package/docs/migration-0.5.0.md +25 -0
  83. package/docs/migration-1.0.0.md +59 -0
  84. package/docs/plugin-architecture.md +103 -0
  85. package/docs/release-checklist.md +37 -0
  86. package/docs/theming.md +61 -0
  87. package/package.json +165 -114
  88. package/dist/engine-DhQ2zxpm.js +0 -3535
  89. package/dist/engine-DhQ2zxpm.js.map +0 -1
@@ -1,70 +1,70 @@
1
- var FlipbookEngine=function(x,E){"use strict";var Ei=Object.defineProperty;var De=x=>{throw TypeError(x)};var Mi=(x,E,L)=>E in x?Ei(x,E,{enumerable:!0,configurable:!0,writable:!0,value:L}):x[E]=L;var v=(x,E,L)=>Mi(x,typeof E!="symbol"?E+"":E,L),Ut=(x,E,L)=>E.has(x)||De("Cannot "+L);var V=(x,E,L)=>(Ut(x,E,"read from private field"),L?L.call(x):E.get(x)),xt=(x,E,L)=>E.has(x)?De("Cannot add the same private member more than once"):E instanceof WeakSet?E.add(x):E.set(x,L),St=(x,E,L,et)=>(Ut(x,E,"write to private field"),et?et.call(x,L):E.set(x,L),L),lt=(x,E,L)=>(Ut(x,E,"access private method"),L);var at,B,j,jt,Vt,Me;function L(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const et=L(E);var Re=Symbol.for("preact-signals");function kt(){if(Z>1)Z--;else{var e,t=!1;for(function(){var r=ut;for(ut=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();it!==void 0;){var s=it;for(it=void 0,dt++;s!==void 0;){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&Xt(s))try{s.c()}catch(r){t||(e=r,t=!0)}s=o}}if(dt=0,Z--,t)throw e}}var M=void 0;function ct(e){var t=M;M=void 0;try{return e()}finally{M=t}}var it=void 0,Z=0,dt=0,Zt=0,ut=void 0,gt=0;function qt(e){if(M!==void 0){var t=e.n;if(t===void 0||t.t!==M)return t={i:0,S:e,p:M.s,n:void 0,t:M,e:void 0,x:void 0,r:t},M.s!==void 0&&(M.s.n=t),M.s=t,e.n=t,32&M.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=M.s,t.n=void 0,M.s.n=t,M.s=t),t}}function O(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}O.prototype.brand=Re,O.prototype.h=function(){return!0},O.prototype.S=function(e){var t=this,s=this.t;s!==e&&e.e===void 0&&(e.x=s,this.t=e,s!==void 0?s.e=e:ct(function(){var o;(o=t.W)==null||o.call(t)}))},O.prototype.U=function(e){var t=this;if(this.t!==void 0){var s=e.e,o=e.x;s!==void 0&&(s.x=o,e.e=void 0),o!==void 0&&(o.e=s,e.x=void 0),e===this.t&&(this.t=o,o===void 0&&ct(function(){var r;(r=t.Z)==null||r.call(t)}))}},O.prototype.subscribe=function(e){var t=this;return U(function(){var s=t.value;ct(function(){return e(s)})},{name:"sub"})},O.prototype.valueOf=function(){return this.value},O.prototype.toString=function(){return this.value+""},O.prototype.toJSON=function(){return this.value},O.prototype.peek=function(){var e=this;return ct(function(){return e.value})},Object.defineProperty(O.prototype,"value",{get:function(){var e=qt(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(dt>100)throw new Error("Cycle detected");(function(s){Z!==0&&dt===0&&s.l!==Zt&&(s.l=Zt,ut={S:s,v:s.v,i:s.i,o:ut})})(this),this.v=e,this.i++,gt++,Z++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{kt()}}}});function I(e,t){return new O(e,t)}function Xt(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Yt(e){for(var t=e.s;t!==void 0;t=t.n){var s=t.S.n;if(s!==void 0&&(t.r=s),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Qt(e){for(var t=e.s,s=void 0;t!==void 0;){var o=t.p;t.i===-1?(t.S.U(t),o!==void 0&&(o.n=t.n),t.n!==void 0&&(t.n.p=o)):s=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=o}e.s=s}function q(e,t){O.call(this,void 0,t),this.x=e,this.s=void 0,this.g=gt-1,this.f=4}q.prototype=new O,q.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===gt))return!0;if(this.g=gt,this.f|=1,this.i>0&&!Xt(this))return this.f&=-2,!0;var e=M;try{Yt(this),M=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return M=e,Qt(this),this.f&=-2,!0},q.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}O.prototype.S.call(this,e)},q.prototype.U=function(e){if(this.t!==void 0&&(O.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},q.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(q.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=qt(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function w(e,t){return new q(e,t)}function Kt(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Z++;var s=M;M=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Tt(e),o}finally{M=s,kt()}}}function Tt(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Kt(e)}function Ie(e){if(M!==this)throw new Error("Out-of-order effect");Qt(this),M=e,this.f&=-2,8&this.f&&Tt(this),kt()}function K(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}K.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}},K.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Kt(this),Yt(this),Z++;var e=M;return M=this,Ie.bind(this,e)},K.prototype.N=function(){2&this.f||(this.f|=2,this.u=it,it=this)},K.prototype.d=function(){this.f|=8,1&this.f||Tt(this)},K.prototype.dispose=function(){this.d()};function U(e,t){var s=new K(e,t);try{s.c()}catch(r){throw s.d(),r}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}var Jt=Symbol.for("Serenity.initPropHook");function Le(e){return!!(e&&typeof e.nodeType=="number")}function pt(e){return typeof e=="string"}function te(e){return typeof e=="number"}function $(e){return typeof e=="object"&&e!==null}function ze(e){return!!(e&&e.isComponent)}function Ct(e){return $(e)&&typeof e.length=="number"&&typeof e.nodeType!="number"}function Fe(e){return typeof e=="function"&&typeof e[Jt]=="function"}function st(e){return e!=null&&typeof e!="boolean"}function nt(e){return Array.isArray(e)?e.map(nt).filter(Boolean).join(" "):$(e)?Symbol.iterator in e?nt(Array.from(e)):Object.keys(e).filter(t=>e[t]).join(" "):st(e)?""+e:""}function Oe(e){return e!=null&&typeof e=="object"&&"current"in e}function At(e,t){Oe(e)?e.current=t:typeof e=="function"&&e(t)}function We(e,t,s){t={...t,children:s};const o=new e(t),r=o.render();return"ref"in t&&At(t.ref,o),r}var Ne="http://www.w3.org/1998/Math/MathML",$e=new Set(["math","annotation","annotation-xml","maction","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics","menclose","mfenced"]),He=new Set(["animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view"]),ee=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/,Be="http://www.w3.org/2000/svg",ie=Symbol.for("Serenity.jsxNamespaceURI");function _e(e){const t=globalThis[ie];return arguments.length&&(globalThis[ie]=e),t}var Ge=Symbol.for("Serenity.jsxTypeKey"),Ue="ShadowRoot";function je(e){return e!=null&&e[Ge]===Ue}var Et=Symbol.for("Serenity.disposingListeners"),Mt=Symbol.for("Serenity.lifecycleRoot");function Dt(){return globalThis[Et]||(globalThis[Et]=new WeakMap)}function Rt(e){e&&e.target&&(!e.currentTarget||e.currentTarget===e.target)&&Ve(e==null?void 0:e.target)}function Ve(e,t){if(!e)return;const s=Dt();function o(r){const h=s.get(r);if(h){s.delete(r),r.removeEventListener("disposing",Rt);for(const u of h)try{u.callback(r)}catch{}}}o(e)}function It(e,t,s){if(!e||!t)return e;const o=Dt();let r=o.get(e);if(!r)return typeof e.addEventListener!="function"||(o.set(e,r=[{callback:t,regKey:s}]),e.addEventListener("disposing",Rt,{once:!0})),e;const h=r.find(u=>u.callback===t);return h?(h.regKey,e):(r.push({callback:t,regKey:s}),e)}function se(e,t,s){if(!e||!t)return e;const o=Dt(),r=o.get(e);if(r){for(let h=r.length-1;h>=0;h--){const u=r[h];t&&t===u.callback&&r.splice(h,1)}r.length===0&&(o.delete(e),typeof e.removeEventListener=="function"&&e.removeEventListener("disposing",Rt))}return e}function Ze(...e){if(e.length>0){const t=globalThis[Mt]||null;return globalThis[Mt]=e[0]||null,t}return globalThis[Mt]||null}function X(e){return e!=null&&typeof e=="object"&&typeof e.subscribe=="function"&&typeof e.peek=="function"&&"value"in e}var qe=(Me=class{constructor(e,t,s){xt(this,j);xt(this,at);xt(this,B);this.signal=e,this.isInitial=!0,this.hasChanged=!1,this.lifecycleRoot=t,St(this,B,s)}get lifecycleNode(){return V(this,B)}get effectDisposer(){return V(this,at)}set effectDisposer(e){lt(this,j,jt).call(this),St(this,at,e),lt(this,j,Vt).call(this)}set lifecycleNode(e){e!==V(this,B)&&(lt(this,j,jt).call(this),St(this,B,e),lt(this,j,Vt).call(this))}},at=new WeakMap,B=new WeakMap,j=new WeakSet,jt=function(){var e;se(V(this,B),this.effectDisposer),se(V(this,B),(e=this.signal)==null?void 0:e.derivedDisposer)},Vt=function(){var e;It(V(this,B),this.effectDisposer),It(V(this,B),(e=this.signal)==null?void 0:e.derivedDisposer)},Me);function ot(e,t,s){const o=s!=null&&s.useLifecycleRoot?Ze():void 0,r=new qe(e,o,s==null?void 0:s.lifecycleNode),h=r.signal.subscribe(function(u){r.newValue=u,r.isInitial&&(this!=null&&this.dispose)&&(r.effectDisposer=this.dispose.bind(this)),r.hasChanged=!r.isInitial&&r.prevValue!==r.newValue;try{t(r)}finally{r.prevValue=r.newValue,r.isInitial=!1}});return h&&!r.effectDisposer&&(r.effectDisposer=h),r.effectDisposer}function ne(e,t){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}var Lt=0,zt="__domwisefrag_";function oe(e){return e instanceof Comment&&e.data.startsWith(zt)}function re(e){return e instanceof DocumentFragment&&oe(e.firstChild)}function Xe(e,t){var s;typeof e.replaceWith=="function"?e.replaceWith(t):(s=e.parentNode)==null||s.replaceChild(t,e)}function ae(e){return e instanceof DocumentFragment?(++Lt,e.prepend(document.createComment(zt+Lt)),e.append(document.createComment(zt+Lt)),e):e instanceof Node?e:st(e)?document.createTextNode(e):document.createComment("")}function Ye(e,t){let s;ot(t,o=>{var u;if(o.isInitial){s=ae(o.newValue);let c=re(s)?s.firstChild:s;ft(e,s),o.lifecycleNode=(s=c)??e;return}if(!o.hasChanged)return;const r=ae(o.newValue);if(oe(s)){let c;for(;(c=s.nextSibling)&&((u=c.parentNode)==null||u.removeChild(c),!(c instanceof Comment&&c.data===s.data)););}let h=re(r)?r.firstChild:r;Xe(s,r),o.lifecycleNode=(s=h)??e})}function ft(e,t){if(st(t))if(Ct(t))for(const s of[...t])ft(e,s);else if(pt(t)||te(t))ne(e,document.createTextNode(t));else if(Le(t))ne(e,t);else if(je(t)){const s=e.attachShadow(t.attr);ft(s,t.children),At(t.ref,s)}else X(t)&&Ye(e,t)}function he(e){return e==null||(Ct(e)?e=Array.from(e).map(t=>X(t)?t.peek():t):$(e)&&(e={...e},Object.entries(e).forEach(([t,s])=>{X(s)&&(e[t]=s.peek())}))),e}function Qe(e,t){if(t==null||t===!1||t===!0)return;t=he(t);const s=(nt(t)??"").split(" ");for(let o of s)o&&e.classList.remove(o)}function Ke(e,t,s){if(t==null||t===!1){Qe(e,s);return}s=he(s),Ct(t)?t=Array.from(t).map(o=>{let r=o;return X(o)&&ot(o,h=>{if(h.isInitial){r=h.newValue;return}Ft(e,h.newValue,h.prevValue)},{lifecycleNode:e}),r}):$(t)&&(t={...t},Object.entries(t).forEach(([o,r])=>{X(r)&&ot(r,h=>{if(h.isInitial){t[o]=h.newValue;return}Ft(e,!!h.newValue&&o,!!h.prevValue&&o)},{lifecycleNode:e})})),Ft(e,t,s)}function Ft(e,t,s){const o=(nt(t)??"").split(" ");if(s){const r=(nt(s)??"").split(" ");for(let h of r)h&&!o.includes(h)&&e.classList.remove(h)}for(let r of o)r&&e.classList.add(r)}function Je(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)}var ti=(()=>{let e={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};const t=["Webkit","ms","Moz","O"];return Object.keys(e).forEach(s=>{t.forEach(o=>{e[Je(o,s)]=0})}),e})();function Ot(e,t,s){t.indexOf("-")===0?e.style.setProperty(t,s):te(s)&&ti[t]!==0?e.style[t]=s+"px":e.style[t]=s}function le(e,t){if(!(t==null||t===!1||t===!0)){if(pt(t)){e.removeAttribute("style");return}$(t)&&Object.keys(t).forEach(s=>{Ot(e,s,"")})}}function ei(e,t,s){if(t==null||t===!1||t===!0){le(e,s);return}if(pt(t)){e.setAttribute("style",t);return}if($(t)){$(s)?(t={...t},Object.keys(s).forEach(o=>{o in t||(t[o]="")})):le(e,s),Object.entries(t).forEach(([o,r])=>{X(r)?ot(r,h=>Ot(e,o,h.newValue),{lifecycleNode:e}):Ot(e,o,r)});return}}var ii="http://www.w3.org/1999/xlink",si="http://www.w3.org/XML/1998/namespace";function mt(e,t){return e.replace(/[A-Z]/g,s=>t+s.toLowerCase())}var ni=new Map([["autoComplete","autocomplete"],["autoFocus","autofocus"],["className","class"],["colSpan","colspan"],["contentEditable","contenteditable"],["formNoValidate","formnovalidate"],["htmlFor","for"],["innerText","textContent"],["minLength","minlength"],["maxLength","maxlength"],["readOnly","readonly"],["reffererPolicy","referrerpolicy"],["rowSpan","rowspan"],["spellCheck","spellcheck"],["tabIndex","tabindex"],["onDoubleClick","onDblClick"],["onDoubleClickCapture","onDblClickCapture"]]);function ce(e,t,s,o){switch(t){case"dataset":o!=null&&Object.entries(o).forEach(([h,u])=>{u!=null&&delete e.dataset[h]}),Object.entries(s).forEach(([h,u])=>{u!=null&&(e.dataset[h]=u)});return;case"textContent":st(s)?e[t]=s:st(o)&&(e[t]="");return;case"dangerouslySetInnerHTML":$(s)?e.innerHTML=s.__html:$(o)&&(e.innerHTML="");return;case"value":if(s==null){o!=null&&(e[t]=null);return}else{if(e instanceof window.HTMLSelectElement)return;if(e instanceof window.HTMLTextAreaElement){e.value=s;return}}break;case"class":Ke(e,s,o);return;case"spellcheck":e.spellcheck=s===""||s===!0||s==="true"?!0:s===!1||s==="false"?!1:s;return;case"draggable":s===!1||s==="false"?s="false":s===""?s=null:(s===!0||s==="true")&&(s="true");break;case"contenteditable":s===!1?s="false":(s===""||s===!0)&&(s="true");break;case"ref":case"namespaceURI":return;case"style":ei(e,s,o);return;case"on":case"onCapture":const r=t==="onCapture";o!=null&&Object.entries(o).forEach(([h,u])=>{(s==null||s[h]!==u)&&e.removeEventListener(h,u,r)}),Object.entries(s).forEach(([h,u])=>{(o==null||o[h]!==u)&&e.addEventListener(h,u,r)});return;case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":e.setAttributeNS(ii,mt(t,":"),s);return;case"xmlnsXlink":e.setAttribute("xmlns:xlink",s);return;case"xmlBase":case"xmlLang":case"xmlSpace":e.setAttributeNS(si,mt(t,":"),s);return}if(typeof s=="function"){if(t[0]==="o"&&t[1]==="n"){if(o!=null&&o===s)return;let r=t.toLowerCase();const h=r.endsWith("capture");let u;!h&&(e[r]===null||o!=null&&e[r]===o)?(e[r]=s,It(e,ri.bind(e,r))):h?(u=r.substring(2,r.length-7),o!=null&&e.removeEventListener(u,o,!0),e.addEventListener(u,s,!0)):(r in window?u=r.substring(2):u=r[2]+t.slice(3),o!=null&&e.removeEventListener(u,o),e.addEventListener(u,s))}else console.warn(`A function was provided for JSX ${e.tagName} element ${t} which does not start with "on":`,s,e.tagName);return}if($(o)){if(o===s)return;delete e[t]}if(o===!0){if(o===s)return;e.removeAttribute(t)}if(o!==!1&&o!=null){if(o===s)return;e instanceof SVGElement&&!ee.test(t)?e.removeAttributeNS(mt(t,"-"),s):e.removeAttribute(t)}if($(s)){e[t]=s;return}if(s===!0){e.setAttribute(t,"");return}s!==!1&&s!=null&&(e instanceof SVGElement&&!ee.test(t)?e.setAttribute(mt(t,"-"),s):e.setAttribute(t,s))}function oi(e,t){for(let[s,o]of Object.entries(t))s=ni.get(s)??s,X(o)?ot(o,r=>ce(e,s,r.newValue,r.prevValue),{lifecycleNode:e}):Fe(o)?o[Jt](e,s):ce(e,s,o);return e}function ri(e){this[e]=null}function g(e,t){let{children:s,...o}=t||{},r=o.namespaceURI;r||(He.has(e)?r=Be:$e.has(e)?r=Ne:r=_e());let h;if(pt(e)){if(h=r?document.createElementNS(r,e):document.createElement(e),oi(h,o),ft(h,s),h instanceof window.HTMLSelectElement&&o.value!=null)if(o.multiple===!0&&Array.isArray(o.value)){const u=o.value.map(c=>String(c));h.querySelectorAll("option").forEach(c=>c.selected=u.includes(c.value))}else h.value=o.value;At(o.ref,h)}else if(typeof e=="function")$(e.defaultProps)&&(o={...e.defaultProps,...o}),h=ze(e)?We(e,o,s):e({...o,children:s});else throw new TypeError(`Invalid JSX element type: ${e}`);return h}var ai=Symbol.for("preact-signals");function Wt(){if(Y>1)Y--;else{var e,t=!1;for(function(){var r=vt;for(vt=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();rt!==void 0;){var s=rt;for(rt=void 0,wt++;s!==void 0;){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&pe(s))try{s.c()}catch(r){t||(e=r,t=!0)}s=o}}if(wt=0,Y--,t)throw e}}var S=void 0;function de(e){var t=S;S=void 0;try{return e()}finally{S=t}}var rt=void 0,Y=0,wt=0,ue=0,vt=void 0,yt=0;function ge(e){if(S!==void 0){var t=e.n;if(t===void 0||t.t!==S)return t={i:0,S:e,p:S.s,n:void 0,t:S,e:void 0,x:void 0,r:t},S.s!==void 0&&(S.s.n=t),S.s=t,e.n=t,32&S.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=S.s,t.n=void 0,S.s.n=t,S.s=t),t}}function N(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}N.prototype.brand=ai,N.prototype.h=function(){return!0},N.prototype.S=function(e){var t=this,s=this.t;s!==e&&e.e===void 0&&(e.x=s,this.t=e,s!==void 0?s.e=e:de(function(){var o;(o=t.W)==null||o.call(t)}))},N.prototype.U=function(e){var t=this;if(this.t!==void 0){var s=e.e,o=e.x;s!==void 0&&(s.x=o,e.e=void 0),o!==void 0&&(o.e=s,e.x=void 0),e===this.t&&(this.t=o,o===void 0&&de(function(){var r;(r=t.Z)==null||r.call(t)}))}},N.prototype.subscribe=function(e){var t=this;return li(function(){var s=t.value,o=S;S=void 0;try{e(s)}finally{S=o}},{name:"sub"})},N.prototype.valueOf=function(){return this.value},N.prototype.toString=function(){return this.value+""},N.prototype.toJSON=function(){return this.value},N.prototype.peek=function(){var e=S;S=void 0;try{return this.value}finally{S=e}},Object.defineProperty(N.prototype,"value",{get:function(){var e=ge(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(wt>100)throw new Error("Cycle detected");(function(s){Y!==0&&wt===0&&s.l!==ue&&(s.l=ue,vt={S:s,v:s.v,i:s.i,o:vt})})(this),this.v=e,this.i++,yt++,Y++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Wt()}}}});function pe(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function fe(e){for(var t=e.s;t!==void 0;t=t.n){var s=t.S.n;if(s!==void 0&&(t.r=s),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function me(e){for(var t=e.s,s=void 0;t!==void 0;){var o=t.p;t.i===-1?(t.S.U(t),o!==void 0&&(o.n=t.n),t.n!==void 0&&(t.n.p=o)):s=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=o}e.s=s}function J(e,t){N.call(this,void 0),this.x=e,this.s=void 0,this.g=yt-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}J.prototype=new N,J.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===yt))return!0;if(this.g=yt,this.f|=1,this.i>0&&!pe(this))return this.f&=-2,!0;var e=S;try{fe(this),S=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return S=e,me(this),this.f&=-2,!0},J.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}N.prototype.S.call(this,e)},J.prototype.U=function(e){if(this.t!==void 0&&(N.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},J.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(J.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=ge(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function we(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Y++;var s=S;S=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Nt(e),o}finally{S=s,Wt()}}}function Nt(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,we(e)}function hi(e){if(S!==this)throw new Error("Out-of-order effect");me(this),S=e,this.f&=-2,8&this.f&&Nt(this),Wt()}function tt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}tt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}},tt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,we(this),fe(this),Y++;var e=S;return S=this,hi.bind(this,e)},tt.prototype.N=function(){2&this.f||(this.f|=2,this.u=rt,rt=this)},tt.prototype.d=function(){this.f|=8,1&this.f||Nt(this)},tt.prototype.dispose=function(){this.d()};function li(e,t){var s=new tt(e,t);try{s.c()}catch(r){throw s.d(),r}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}const $t={en:{emptyStateTitle:"No data available.",thumbnails:"Thumbnails",singlePageMode:"Single Page Mode",pages:"Pages",previous:"Previous",next:"Next",zoomOut:"Zoom Out",zoomIn:"Zoom In",fullscreen:"Fullscreen",settings:"Settings",downloadCatalog:"Download Catalog",play:"Play",pause:"Pause",tableOfContents:"Table of Contents"},tr:{emptyStateTitle:"Veri bulunamadi.",thumbnails:"Küçük Resimler",singlePageMode:"Tek Sayfa Modu",pages:"Sayfalar",previous:"Önceki",next:"Sonraki",zoomOut:"Uzaklaş",zoomIn:"Yaklaş",fullscreen:"Tam Ekran",settings:"Ayarlar",downloadCatalog:"Kataloğu İndir",play:"Otomatik Oynat",pause:"Duraklat",tableOfContents:"İçindekiler"}};function ve(e={}){var r;const t=e.locale??"en",s=$t[t]??$t.en,o=((r=e.messages)==null?void 0:r[t])??{};return{...$t.en,...s,...o}}function ci(e){const t=w(()=>ve({locale:e.store.locale.value,messages:e.store.messages.value}));return g("div",{class:"bk-toolbar",role:"toolbar","aria-label":"Flipbook controls",children:[g("div",{class:"bk-btn-group",children:[g("button",{type:"button",class:w(()=>`bk-btn ${e.store.showThumbs.value?"active":""}`),onClick:e.onToggleThumbs,"aria-label":w(()=>t.value.thumbnails||"Thumbnails"),"aria-pressed":w(()=>e.store.showThumbs.value?"true":"false"),title:w(()=>t.value.thumbnails||"Thumbnails"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("rect",{x:"3",y:"3",width:"7",height:"7"}),g("rect",{x:"14",y:"3",width:"7",height:"7"}),g("rect",{x:"14",y:"14",width:"7",height:"7"}),g("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),w(()=>e.store.toc.value.length?g("button",{type:"button",class:w(()=>e.store.showToc.value?"bk-btn active":"bk-btn"),onClick:e.onToggleToc,"aria-label":w(()=>t.value.tableOfContents||"Table of Contents"),"aria-pressed":w(()=>e.store.showToc.value?"true":"false"),title:w(()=>t.value.tableOfContents||"Table of Contents"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),g("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),g("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),g("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),g("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),g("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]})}):null),g("button",{type:"button",class:w(()=>`bk-btn bz-hide-mobile ${e.store.isSingleMode.value?"active":""}`),onClick:e.onToggleSingleMode,"aria-label":w(()=>t.value.singlePageMode||"Single Page"),"aria-pressed":w(()=>e.store.isSingleMode.value?"true":"false"),title:w(()=>t.value.singlePageMode||"Single Page"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),g("polyline",{points:"14 2 14 8 20 8"}),g("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),g("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),g("polyline",{points:"10 9 9 9 8 9"})]})}),g("button",{type:"button",class:w(()=>`bk-btn ${e.store.isAutoPlaying.value?"active":""}`),onClick:e.onToggleAutoPlay,"aria-label":w(()=>e.store.isAutoPlaying.value?t.value.pause||"Pause":t.value.play||"Play"),"aria-pressed":w(()=>e.store.isAutoPlaying.value?"true":"false"),title:w(()=>e.store.isAutoPlaying.value?t.value.pause||"Pause":t.value.play||"Play"),children:[g("svg",{style:{display:w(()=>e.store.isAutoPlaying.value?"block":"none")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("rect",{x:"6",y:"4",width:"4",height:"16"}),g("rect",{x:"14",y:"4",width:"4",height:"16"})]}),g("svg",{style:{display:w(()=>e.store.isAutoPlaying.value?"none":"block")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:g("polygon",{points:"5 3 19 12 5 21 5 3"})})]})]}),g("div",{class:"bk-btn-group bk-btn-group--center",children:[g("button",{type:"button",class:"bk-btn",onClick:e.onPrevPage,"aria-label":w(()=>t.value.previous||"Previous"),title:w(()=>t.value.previous||"Previous"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:g("polyline",{points:"15 18 9 12 15 6"})})}),g("span",{class:"bz-page-info","aria-live":"polite","aria-atomic":"true",children:w(()=>{const s=e.store.currentPage.value,o=e.store.totalPages.value;if(e.store.isSingleMode.value||s===0||s>=o-1)return`${s+1} / ${o}`;const r=s%2===1?s:s-1;return`${r+1}-${r+2} / ${o}`})}),g("button",{type:"button",class:"bk-btn",onClick:e.onNextPage,"aria-label":w(()=>t.value.next||"Next"),title:w(()=>t.value.next||"Next"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:g("polyline",{points:"9 18 15 12 9 6"})})})]}),g("div",{class:"bk-btn-group",children:[g("button",{type:"button",class:"bk-btn",onClick:e.onZoomIn,"aria-label":w(()=>t.value.zoomIn||"Zoom In"),title:w(()=>t.value.zoomIn||"Zoom In"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("circle",{cx:"11",cy:"11",r:"8"}),g("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),g("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),g("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),g("button",{type:"button",class:w(()=>`bk-btn ${e.store.isZoomed.value?"active":""}`),onClick:e.onZoomOut,"aria-label":w(()=>t.value.zoomOut||"Zoom Out"),title:w(()=>t.value.zoomOut||"Zoom Out"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("circle",{cx:"11",cy:"11",r:"8"}),g("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),g("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),g("button",{type:"button",class:"bk-btn bk-btn--fullscreen",onClick:e.onToggleFullscreen,"aria-label":w(()=>t.value.fullscreen||"Fullscreen"),title:w(()=>t.value.fullscreen||"Fullscreen"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:g("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),w(()=>e.store.allowDownload.value&&e.store.hasDownloadUrl.value&&e.onDownload?g("button",{type:"button",class:"bk-btn bk-btn--download",onClick:e.onDownload,"aria-label":w(()=>t.value.downloadCatalog||"Download"),title:w(()=>t.value.downloadCatalog||"Download"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),g("polyline",{points:"7 10 12 15 17 10"}),g("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}):null),g("button",{type:"button",class:w(()=>`bk-btn ${e.store.soundEnabled.value?"":"muted"}`),onClick:e.onSoundToggle,"aria-label":"Sound","aria-pressed":w(()=>e.store.soundEnabled.value?"true":"false"),title:"Sound",children:[g("svg",{style:{display:w(()=>e.store.soundEnabled.value?"block":"none")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),g("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),g("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}),g("svg",{style:{display:w(()=>e.store.soundEnabled.value?"none":"block")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),g("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),g("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]})]})]})}function di(e){return g("div",{class:"bk-thumbs",style:w(()=>e.store.showThumbs.value?"display:flex;":"display:none;"),children:e.store.pages.value.map((t,s)=>{const o=()=>{const r=e.store.currentPage.value;if(e.store.isSingleMode.value||r===0||r>=e.store.pages.value.length-1)return r===s;const h=r%2===1?r:r-1;return s===h||s===h+1};return g("div",{class:w(()=>`thumb-item ${o()?"active":""}`),role:"button",tabindex:"0","aria-label":`Go to page ${s+1}`,"aria-current":w(()=>o()?"page":void 0),onClick:()=>e.onThumbClick(s),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),e.onThumbClick(s))},children:g("div",{class:"thumb-img-wrapper",children:[g("img",{"data-pdf-page":t.assetId.startsWith("pdf-page-")?t.sourcePageNumber??t.pageNumber:void 0,class:`thumb-img ${t.cropMode!=="full"?"thumb-img--split thumb-img--"+t.cropMode:""}`,src:t.thumb||t.low||t.normal,alt:`Page ${s+1}`,loading:"lazy",onError:r=>{r.currentTarget.style.display="none"}}),g("span",{class:"thumb-page-number",children:s+1})]})})})})}function ye(e,t,s){return g("ol",{class:"bk-toc-list",children:e.map(o=>{var r;return g("li",{class:"bk-toc-item",children:[g("button",{type:"button",class:w(()=>t.currentPage.value===o.pageIndex?"bk-toc-entry active":"bk-toc-entry"),"aria-current":w(()=>t.currentPage.value===o.pageIndex?"page":void 0),onClick:()=>s(o.pageIndex),children:[g("span",{class:"bk-toc-title",children:o.title}),g("span",{class:"bk-toc-page",children:o.pageIndex+1})]}),(r=o.children)!=null&&r.length?ye(o.children,t,s):null]})})})}function ui(e){const t=w(()=>ve({locale:e.store.locale.value,messages:e.store.messages.value}));return g("nav",{class:"bk-toc","aria-label":w(()=>t.value.tableOfContents||"Table of Contents"),style:w(()=>e.store.showToc.value&&e.store.toc.value.length?"display:flex;":"display:none;"),children:[g("div",{class:"bk-toc-heading",children:w(()=>t.value.tableOfContents||"Table of Contents")}),ye(e.store.toc.value,e.store,e.onEntryClick)]})}function gi(e){return g("div",{role:"region","aria-label":"Flipbook viewer",class:w(()=>{let t="bk-book-wrapper ";return e.store.isDoublePageLayout.value&&(t+="double-mode "),e.store.isFrontCover.value&&(t+="bk-is-cover "),e.store.isBackCover.value&&(t+="bk-is-back-cover "),e.store.zoomState.value.isActive&&(t+="zoomed "),t.trim()}),ref:e.bookWrapperRef,children:g("div",{class:"bk-book-sizer",ref:e.bookSizerRef,children:[g("div",{ref:e.bookContainerRef,class:w(()=>"bk-book "+(e.store.flipState.value!=="read"?"is-flipping":"")),style:w(()=>`display: ${e.store.isSingleMode.value?"none":"block"};`),children:e.store.pages.value.map((t,s)=>{const o=s===0||s===e.store.pages.value.length-1;return g("div",{class:`bz-page ${s===0?"bz-page--cover":""} ${s===e.store.pages.value.length-1?"bz-page--back":""}`,"data-density":o?"hard":"soft","data-idx":s,children:g("div",{class:"bz-page-content",style:"position:relative; width:100%; height:100%; overflow:hidden;",children:[g("img",{"data-pdf-page":t.assetId.startsWith("pdf-page-")?t.sourcePageNumber??t.pageNumber:void 0,src:t.low||t.normal,"data-src":t.normal,class:`page-content ${t.cropMode!=="full"?"page-content--split page-content--"+t.cropMode:""}`,alt:`Page ${s+1}`,loading:"lazy"}),g("div",{class:"page-shadow"})]})})})}),g("div",{class:"bk-single-view",style:w(()=>`display: ${e.store.isSingleMode.value?"flex":"none"}; width: 100%; height: 100%; justify-content: center; align-items: center; position: absolute; top: 0; left: 0; z-index: 10;`),children:w(()=>{const t=e.store.pages.value[e.store.currentPage.value];return t?g("img",{"data-pdf-page":t.assetId.startsWith("pdf-page-")?t.sourcePageNumber??t.pageNumber:void 0,class:`bk-single-img page-content ${t.cropMode!=="full"?"page-content--split page-content--"+t.cropMode:""}`,src:e.store.zoomState.value.isActive?t.normal:t.low||t.normal,alt:`Page ${e.store.currentPage.value+1}`,style:"opacity: 1; transition: opacity 0.3s; box-shadow: var(--flipbook-shadow);"}):null})})]})})}function pi(e){const t=w(()=>e.store.showArrows.value&&e.store.currentPage.value>0),s=w(()=>!e.store.showArrows.value||e.store.totalPages.value<=1?!1:e.store.currentPage.value<e.store.totalPages.value-1);return g("div",{class:"bk-nav-arrows",style:w(()=>e.store.showArrows.value?"display: flex;":"display: none;"),children:[g("button",{type:"button",class:"bk-nav-arrow bk-nav-prev",style:w(()=>t.value?"visibility: visible;":"visibility: hidden;"),onClick:o=>{o.preventDefault(),e.onPrevPage()},"aria-label":"Previous Page",children:g("div",{class:"bk-arrow-icon bk-arrow-left"})}),g("button",{type:"button",class:"bk-nav-arrow bk-nav-next",style:w(()=>s.value?"visibility: visible;":"visibility: hidden;"),onClick:o=>{o.preventDefault(),e.onNextPage()},"aria-label":"Next Page",children:g("div",{class:"bk-arrow-icon bk-arrow-right"})})]})}function fi(e){const t=()=>{e.store.showThumbs.value=!e.store.showThumbs.value},s=()=>{e.store.showToc.value=!e.store.showToc.value},o=()=>{e.store.isSingleMode.value=!e.store.isSingleMode.value},r=()=>{e.store.isAutoPlaying.value=!e.store.isAutoPlaying.value},h=()=>{var k;(k=e.interactionManagerRef.current)==null||k.zoomIn()},u=()=>{var k;(k=e.interactionManagerRef.current)==null||k.zoomOut()},c=()=>e.onToggleFullscreen(),b=k=>{e.store.currentPage.value=k,e.store.showToc.value=!1},P=k=>{var T;e.store.currentPage.value!==k&&(e.store.currentPage.value=k,(T=e.pageFlipAdapterRef.current)==null||T.playSound())},A=()=>{var k;(k=e.pageFlipAdapterRef.current)==null||k.turnToNextPage()},F=()=>{var k;(k=e.pageFlipAdapterRef.current)==null||k.turnToPrevPage()};return g("div",{class:w(()=>`bk-wrapper bk-theme-${e.store.themeMode.value} ${e.className||""}`),children:[g("div",{class:"bk-main-area",children:[g(gi,{store:e.store,bookWrapperRef:e.bookWrapperRef,bookSizerRef:e.bookSizerRef,bookContainerRef:e.bookContainerRef}),g(pi,{store:e.store,onPrevPage:F,onNextPage:A}),e.store.whiteLabel.value?null:g("div",{class:"bk-watermark",children:["Powered by ",g("a",{href:"https://flipbookengine.com",target:"_blank",rel:"noopener",style:"text-decoration: underline;",children:"FlipbookEngine"})]}),g(ui,{store:e.store,onEntryClick:b})]}),g(ci,{store:e.store,onToggleThumbs:t,onToggleToc:s,onToggleSingleMode:o,onZoomIn:h,onZoomOut:u,onDownload:e.onDownload,onNextPage:A,onPrevPage:F,onSoundToggle:()=>e.store.soundEnabled.value=!e.store.soundEnabled.value,onToggleAutoPlay:r,onToggleFullscreen:c}),g(di,{store:e.store,onThumbClick:P})]})}var mi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ht={exports:{}};(function(e,t){(function(s,o){o(t)})(mi,function(s){class o{constructor(i,n){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=n,this.nowDrawingDensity=this.createdDensity,this.render=i}setDensity(i){this.createdDensity=i,this.nowDrawingDensity=i}setDrawingDensity(i){this.nowDrawingDensity=i}setPosition(i){this.state.position=i}setAngle(i){this.state.angle=i}setArea(i){this.state.area=i}setHardDrawingAngle(i){this.state.hardDrawingAngle=i}setHardAngle(i){this.state.hardAngle=i,this.state.hardDrawingAngle=i}setOrientation(i){this.orientation=i}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class r extends o{constructor(i,n,a){super(i,a),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=n}draw(i){const n=this.render.getContext(),a=this.render.convertToGlobal(this.state.position),l=this.render.getRect().pageWidth,d=this.render.getRect().height;n.save(),n.translate(a.x,a.y),n.beginPath();for(let p of this.state.area)p!==null&&(p=this.render.convertToGlobal(p),n.lineTo(p.x-a.x,p.y-a.y));n.rotate(this.state.angle),n.clip(),this.isLoad?n.drawImage(this.image,0,0,l,d):this.drawLoader(n,{x:0,y:0},l,d),n.restore()}simpleDraw(i){const n=this.render.getRect(),a=this.render.getContext(),l=n.pageWidth,d=n.height,p=i===1?n.left+n.pageWidth:n.left,y=n.top;this.isLoad?a.drawImage(this.image,p,y,l,d):this.drawLoader(a,{x:p,y},l,d)}drawLoader(i,n,a,l){i.beginPath(),i.strokeStyle="rgb(200, 200, 200)",i.fillStyle="rgb(255, 255, 255)",i.lineWidth=1,i.rect(n.x+1,n.y+1,a-1,l-1),i.stroke(),i.fill();const d={x:n.x+a/2,y:n.y+l/2};i.beginPath(),i.lineWidth=10,i.arc(d.x,d.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),i.stroke(),i.closePath(),this.loadingAngle+=.07,this.loadingAngle>=2*Math.PI&&(this.loadingAngle=0)}load(){this.isLoad||(this.image.onload=()=>{this.isLoad=!0})}newTemporaryCopy(){return this}getTemporaryCopy(){return this}hideTemporaryCopy(){}}class h{constructor(i,n){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=n,this.app=i,this.currentPageIndex=0,this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[],this.portraitSpread=[];for(let n=0;n<this.pages.length;n++)this.portraitSpread.push([n]);let i=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([i]),i++);for(let n=i;n<this.pages.length;n+=2)n<this.pages.length-1?this.landscapeSpread.push([n,n+1]):(this.landscapeSpread.push([n]),this.pages[n].setDensity("hard"))}getSpread(){return this.render.getOrientation()==="landscape"?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(i){const n=this.getSpread();for(let a=0;a<n.length;a++)if(i===n[a][0]||i===n[a][1])return a;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(i){if(i>=0&&i<this.pages.length)return this.pages[i];throw new Error("Invalid page number")}nextBy(i){const n=this.pages.indexOf(i);return n<this.pages.length-1?this.pages[n+1]:null}prevBy(i){const n=this.pages.indexOf(i);return n>0?this.pages[n-1]:null}getFlippingPage(i){const n=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return i===0?this.pages[n].newTemporaryCopy():this.pages[n-1];{const a=i===0?this.getSpread()[n+1]:this.getSpread()[n-1];return a.length===1||i===0?this.pages[a[0]]:this.pages[a[1]]}}getBottomPage(i){const n=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return i===0?this.pages[n+1]:this.pages[n-1];{const a=i===0?this.getSpread()[n+1]:this.getSpread()[n-1];return a.length===1?this.pages[a[0]]:i===0?this.pages[a[1]]:this.pages[a[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(i=null){if(i===null&&(i=this.currentPageIndex),i<0||i>=this.pages.length)return;const n=this.getSpreadIndexByPage(i);n!==null&&(this.currentSpreadIndex=n,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(i){if(!(i>=0&&i<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=i}showSpread(){const i=this.getSpread()[this.currentSpreadIndex];i.length===2?(this.render.setLeftPage(this.pages[i[0]]),this.render.setRightPage(this.pages[i[1]])):this.render.getOrientation()==="landscape"&&i[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[i[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[i[0]])),this.currentPageIndex=i[0],this.app.updatePageIndex(this.currentPageIndex)}}class u extends h{constructor(i,n,a){super(i,n),this.imagesHref=a}load(){for(const i of this.imagesHref){const n=new r(this.render,i,"soft");n.load(),this.pages.push(n)}this.createSpread()}}class c{static GetDistanceBetweenTwoPoint(i,n){return i===null||n===null?1/0:Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2))}static GetSegmentLength(i){return c.GetDistanceBetweenTwoPoint(i[0],i[1])}static GetAngleBetweenTwoLine(i,n){const a=i[0].y-i[1].y,l=n[0].y-n[1].y,d=i[1].x-i[0].x,p=n[1].x-n[0].x;return Math.acos((a*l+d*p)/(Math.sqrt(a*a+d*d)*Math.sqrt(l*l+p*p)))}static PointInRect(i,n){return n===null?null:n.x>=i.left&&n.x<=i.width+i.left&&n.y>=i.top&&n.y<=i.top+i.height?n:null}static GetRotatedPoint(i,n,a){return{x:i.x*Math.cos(a)+i.y*Math.sin(a)+n.x,y:i.y*Math.cos(a)-i.x*Math.sin(a)+n.y}}static LimitPointToCircle(i,n,a){if(c.GetDistanceBetweenTwoPoint(i,a)<=n)return a;const l=i.x,d=i.y,p=a.x,y=a.y;let f=Math.sqrt(Math.pow(n,2)*Math.pow(l-p,2)/(Math.pow(l-p,2)+Math.pow(d-y,2)))+l;a.x<0&&(f*=-1);let R=(f-l)*(d-y)/(l-p)+d;return l-p+d===0&&(R=n),{x:f,y:R}}static GetIntersectBetweenTwoSegment(i,n,a){return c.PointInRect(i,c.GetIntersectBeetwenTwoLine(n,a))}static GetIntersectBeetwenTwoLine(i,n){const a=i[0].y-i[1].y,l=n[0].y-n[1].y,d=i[1].x-i[0].x,p=n[1].x-n[0].x,y=i[0].x*i[1].y-i[1].x*i[0].y,f=n[0].x*n[1].y-n[1].x*n[0].y,R=a*f-l*y,z=d*f-p*y,H=-(y*p-f*d)/(a*p-l*d),ht=-(a*f-l*y)/(a*p-l*d);if(isFinite(H)&&isFinite(ht))return{x:H,y:ht};if(Math.abs(R-z)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(i,n){const a=Math.abs(i.x-n.x),l=Math.abs(i.y-n.y),d=Math.max(a,l),p=[i];function y(f,R,z,H,ht){return R>f?f+ht*(z/H):R<f?f-ht*(z/H):f}for(let f=1;f<=d;f+=1)p.push({x:y(i.x,n.x,a,d,f),y:y(i.y,n.y,l,d,f)});return p}}class b extends o{constructor(i,n,a){super(i,a),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=n,this.element.classList.add("stf__item"),this.element.classList.add("--"+a)}newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new b(this.render,this.copiedElement,this.nowDrawingDensity)),this.getTemporaryCopy())}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){this.temporaryCopy!==null&&(this.copiedElement.remove(),this.copiedElement=null,this.temporaryCopy=null)}draw(i){const n=i||this.nowDrawingDensity,a=this.render.convertToGlobal(this.state.position),l=this.render.getRect().pageWidth,d=this.render.getRect().height;this.element.classList.remove("--simple");const p=`
1
+ var FlipbookEngine=function(E,L){"use strict";var os=Object.defineProperty;var Qt=E=>{throw TypeError(E)};var rs=(E,L,O)=>L in E?os(E,L,{enumerable:!0,configurable:!0,writable:!0,value:O}):E[L]=O;var b=(E,L,O)=>rs(E,typeof L!="symbol"?L+"":L,O),tt=(E,L,O)=>L.has(E)||Qt("Cannot "+O);var K=(E,L,O)=>(tt(E,L,"read from private field"),O?O.call(E):L.get(E)),Re=(E,L,O)=>L.has(E)?Qt("Cannot add the same private member more than once"):L instanceof WeakSet?L.add(E):L.set(E,O),De=(E,L,O,le)=>(tt(E,L,"write to private field"),le?le.call(E,O):L.set(E,O),O),me=(E,L,O)=>(tt(E,L,"access private method"),O);var fe,V,Q,it,st,Zt;function O(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:()=>t[i]})}}return e.default=t,Object.freeze(e)}const le=O(L);var Yt=Symbol.for("preact-signals");function Le(){if(J>1)J--;else{var t,e=!1;for(function(){var r=be;for(be=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();he!==void 0;){var i=he;for(he=void 0,we++;i!==void 0;){var n=i.u;if(i.u=void 0,i.f&=-3,!(8&i.f)&&rt(i))try{i.c()}catch(r){e||(t=r,e=!0)}i=n}}if(we=0,J--,e)throw t}}var N=void 0;function ve(t){var e=N;N=void 0;try{return t()}finally{N=e}}var he=void 0,J=0,we=0,nt=0,be=void 0,ye=0;function ot(t){if(N!==void 0){var e=t.n;if(e===void 0||e.t!==N)return e={i:0,S:t,p:N.s,n:void 0,t:N,e:void 0,x:void 0,r:e},N.s!==void 0&&(N.s.n=e),N.s=e,t.n=e,32&N.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=N.s,e.n=void 0,N.s.n=e,N.s=e),e}}function $(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}$.prototype.brand=Yt,$.prototype.h=function(){return!0},$.prototype.S=function(t){var e=this,i=this.t;i!==t&&t.e===void 0&&(t.x=i,this.t=t,i!==void 0?i.e=t:ve(function(){var n;(n=e.W)==null||n.call(e)}))},$.prototype.U=function(t){var e=this;if(this.t!==void 0){var i=t.e,n=t.x;i!==void 0&&(i.x=n,t.e=void 0),n!==void 0&&(n.e=i,t.x=void 0),t===this.t&&(this.t=n,n===void 0&&ve(function(){var r;(r=e.Z)==null||r.call(e)}))}},$.prototype.subscribe=function(t){var e=this;return X(function(){var i=e.value;ve(function(){return t(i)})},{name:"sub"})},$.prototype.valueOf=function(){return this.value},$.prototype.toString=function(){return this.value+""},$.prototype.toJSON=function(){return this.value},$.prototype.peek=function(){var t=this;return ve(function(){return t.value})},Object.defineProperty($.prototype,"value",{get:function(){var t=ot(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(we>100)throw new Error("Cycle detected");(function(i){J!==0&&we===0&&i.l!==nt&&(i.l=nt,be={S:i,v:i.v,i:i.i,o:be})})(this),this.v=t,this.i++,ye++,J++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Le()}}}});function T(t,e){return new $(t,e)}function rt(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function at(t){for(var e=t.s;e!==void 0;e=e.n){var i=e.S.n;if(i!==void 0&&(e.r=i),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function lt(t){for(var e=t.s,i=void 0;e!==void 0;){var n=e.p;e.i===-1?(e.S.U(e),n!==void 0&&(n.n=e.n),e.n!==void 0&&(e.n.p=n)):i=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=n}t.s=i}function ee(t,e){$.call(this,void 0,e),this.x=t,this.s=void 0,this.g=ye-1,this.f=4}ee.prototype=new $,ee.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ye))return!0;if(this.g=ye,this.f|=1,this.i>0&&!rt(this))return this.f&=-2,!0;var t=N;try{at(this),N=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(i){this.v=i,this.f|=16,this.i++}return N=t,lt(this),this.f&=-2,!0},ee.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}$.prototype.S.call(this,t)},ee.prototype.U=function(t){if(this.t!==void 0&&($.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},ee.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}},Object.defineProperty(ee.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=ot(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function p(t,e){return new ee(t,e)}function ht(t){var e=t.m;if(t.m=void 0,typeof e=="function"){J++;var i=N;N=void 0;try{e()}catch(n){throw t.f&=-2,t.f|=8,Ne(t),n}finally{N=i,Le()}}}function Ne(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ht(t)}function Kt(t){if(N!==this)throw new Error("Out-of-order effect");lt(this),N=t,this.f&=-2,8&this.f&&Ne(this),Le()}function se(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e==null?void 0:e.name}se.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}},se.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ht(this),at(this),J++;var t=N;return N=this,Kt.bind(this,t)},se.prototype.N=function(){2&this.f||(this.f|=2,this.u=he,he=this)},se.prototype.d=function(){this.f|=8,1&this.f||Ne(this)},se.prototype.dispose=function(){this.d()};function X(t,e){var i=new se(t,e);try{i.c()}catch(r){throw i.d(),r}var n=i.d.bind(i);return n[Symbol.dispose]=n,n}var ct=Symbol.for("Serenity.initPropHook");function Jt(t){return!!(t&&typeof t.nodeType=="number")}function Pe(t){return typeof t=="string"}function ut(t){return typeof t=="number"}function j(t){return typeof t=="object"&&t!==null}function ei(t){return!!(t&&t.isComponent)}function ze(t){return j(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function ti(t){return typeof t=="function"&&typeof t[ct]=="function"}function ce(t){return t!=null&&typeof t!="boolean"}function ue(t){return Array.isArray(t)?t.map(ue).filter(Boolean).join(" "):j(t)?Symbol.iterator in t?ue(Array.from(t)):Object.keys(t).filter(e=>t[e]).join(" "):ce(t)?""+t:""}function ii(t){return t!=null&&typeof t=="object"&&"current"in t}function Fe(t,e){ii(t)?t.current=e:typeof t=="function"&&t(e)}function si(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&Fe(e.ref,n),r}var ni="http://www.w3.org/1998/Math/MathML",oi=new Set(["math","annotation","annotation-xml","maction","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics","menclose","mfenced"]),ri=new Set(["animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view"]),dt=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/,ai="http://www.w3.org/2000/svg",gt=Symbol.for("Serenity.jsxNamespaceURI");function li(t){const e=globalThis[gt];return arguments.length&&(globalThis[gt]=t),e}var hi=Symbol.for("Serenity.jsxTypeKey"),ci="ShadowRoot";function ui(t){return t!=null&&t[hi]===ci}var Oe=Symbol.for("Serenity.disposingListeners"),Be=Symbol.for("Serenity.lifecycleRoot");function He(){return globalThis[Oe]||(globalThis[Oe]=new WeakMap)}function $e(t){t&&t.target&&(!t.currentTarget||t.currentTarget===t.target)&&di(t==null?void 0:t.target)}function di(t,e){if(!t)return;const i=He();function n(r){const a=i.get(r);if(a){i.delete(r),r.removeEventListener("disposing",$e);for(const h of a)try{h.callback(r)}catch{}}}n(t)}function We(t,e,i){if(!t||!e)return t;const n=He();let r=n.get(t);if(!r)return typeof t.addEventListener!="function"||(n.set(t,r=[{callback:e,regKey:i}]),t.addEventListener("disposing",$e,{once:!0})),t;const a=r.find(h=>h.callback===e);return a?(a.regKey,t):(r.push({callback:e,regKey:i}),t)}function pt(t,e,i){if(!t||!e)return t;const n=He(),r=n.get(t);if(r){for(let a=r.length-1;a>=0;a--){const h=r[a];e&&e===h.callback&&r.splice(a,1)}r.length===0&&(n.delete(t),typeof t.removeEventListener=="function"&&t.removeEventListener("disposing",$e))}return t}function gi(...t){if(t.length>0){const e=globalThis[Be]||null;return globalThis[Be]=t[0]||null,e}return globalThis[Be]||null}function te(t){return t!=null&&typeof t=="object"&&typeof t.subscribe=="function"&&typeof t.peek=="function"&&"value"in t}var pi=(Zt=class{constructor(t,e,i){Re(this,Q);Re(this,fe);Re(this,V);this.signal=t,this.isInitial=!0,this.hasChanged=!1,this.lifecycleRoot=e,De(this,V,i)}get lifecycleNode(){return K(this,V)}get effectDisposer(){return K(this,fe)}set effectDisposer(t){me(this,Q,it).call(this),De(this,fe,t),me(this,Q,st).call(this)}set lifecycleNode(t){t!==K(this,V)&&(me(this,Q,it).call(this),De(this,V,t),me(this,Q,st).call(this))}},fe=new WeakMap,V=new WeakMap,Q=new WeakSet,it=function(){var t;pt(K(this,V),this.effectDisposer),pt(K(this,V),(t=this.signal)==null?void 0:t.derivedDisposer)},st=function(){var t;We(K(this,V),this.effectDisposer),We(K(this,V),(t=this.signal)==null?void 0:t.derivedDisposer)},Zt);function de(t,e,i){const n=i!=null&&i.useLifecycleRoot?gi():void 0,r=new pi(t,n,i==null?void 0:i.lifecycleNode),a=r.signal.subscribe(function(h){r.newValue=h,r.isInitial&&(this!=null&&this.dispose)&&(r.effectDisposer=this.dispose.bind(this)),r.hasChanged=!r.isInitial&&r.prevValue!==r.newValue;try{e(r)}finally{r.prevValue=r.newValue,r.isInitial=!1}});return a&&!r.effectDisposer&&(r.effectDisposer=a),r.effectDisposer}function ft(t,e){t instanceof window.HTMLTemplateElement?t.content.appendChild(e):t.appendChild(e)}var _e=0,Ue="__domwisefrag_";function mt(t){return t instanceof Comment&&t.data.startsWith(Ue)}function vt(t){return t instanceof DocumentFragment&&mt(t.firstChild)}function fi(t,e){var i;typeof t.replaceWith=="function"?t.replaceWith(e):(i=t.parentNode)==null||i.replaceChild(e,t)}function wt(t){return t instanceof DocumentFragment?(++_e,t.prepend(document.createComment(Ue+_e)),t.append(document.createComment(Ue+_e)),t):t instanceof Node?t:ce(t)?document.createTextNode(t):document.createComment("")}function mi(t,e){let i;de(e,n=>{var h;if(n.isInitial){i=wt(n.newValue);let u=vt(i)?i.firstChild:i;xe(t,i),n.lifecycleNode=(i=u)??t;return}if(!n.hasChanged)return;const r=wt(n.newValue);if(mt(i)){let u;for(;(u=i.nextSibling)&&((h=u.parentNode)==null||h.removeChild(u),!(u instanceof Comment&&u.data===i.data)););}let a=vt(r)?r.firstChild:r;fi(i,r),n.lifecycleNode=(i=a)??t})}function xe(t,e){if(ce(e))if(ze(e))for(const i of[...e])xe(t,i);else if(Pe(e)||ut(e))ft(t,document.createTextNode(e));else if(Jt(e))ft(t,e);else if(ui(e)){const i=t.attachShadow(e.attr);xe(i,e.children),Fe(e.ref,i)}else te(e)&&mi(t,e)}function bt(t){return t==null||(ze(t)?t=Array.from(t).map(e=>te(e)?e.peek():e):j(t)&&(t={...t},Object.entries(t).forEach(([e,i])=>{te(i)&&(t[e]=i.peek())}))),t}function vi(t,e){if(e==null||e===!1||e===!0)return;e=bt(e);const i=(ue(e)??"").split(" ");for(let n of i)n&&t.classList.remove(n)}function wi(t,e,i){if(e==null||e===!1){vi(t,i);return}i=bt(i),ze(e)?e=Array.from(e).map(n=>{let r=n;return te(n)&&de(n,a=>{if(a.isInitial){r=a.newValue;return}Ge(t,a.newValue,a.prevValue)},{lifecycleNode:t}),r}):j(e)&&(e={...e},Object.entries(e).forEach(([n,r])=>{te(r)&&de(r,a=>{if(a.isInitial){e[n]=a.newValue;return}Ge(t,!!a.newValue&&n,!!a.prevValue&&n)},{lifecycleNode:t})})),Ge(t,e,i)}function Ge(t,e,i){const n=(ue(e)??"").split(" ");if(i){const r=(ue(i)??"").split(" ");for(let a of r)a&&!n.includes(a)&&t.classList.remove(a)}for(let r of n)r&&t.classList.add(r)}function bi(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var yi=(()=>{let t={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};const e=["Webkit","ms","Moz","O"];return Object.keys(t).forEach(i=>{e.forEach(n=>{t[bi(n,i)]=0})}),t})();function je(t,e,i){e.indexOf("-")===0?t.style.setProperty(e,i):ut(i)&&yi[e]!==0?t.style[e]=i+"px":t.style[e]=i}function yt(t,e){if(!(e==null||e===!1||e===!0)){if(Pe(e)){t.removeAttribute("style");return}j(e)&&Object.keys(e).forEach(i=>{je(t,i,"")})}}function Pi(t,e,i){if(e==null||e===!1||e===!0){yt(t,i);return}if(Pe(e)){t.setAttribute("style",e);return}if(j(e)){j(i)?(e={...e},Object.keys(i).forEach(n=>{n in e||(e[n]="")})):yt(t,i),Object.entries(e).forEach(([n,r])=>{te(r)?de(r,a=>je(t,n,a.newValue),{lifecycleNode:t}):je(t,n,r)});return}}var xi="http://www.w3.org/1999/xlink",Si="http://www.w3.org/XML/1998/namespace";function Se(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}var ki=new Map([["autoComplete","autocomplete"],["autoFocus","autofocus"],["className","class"],["colSpan","colspan"],["contentEditable","contenteditable"],["formNoValidate","formnovalidate"],["htmlFor","for"],["innerText","textContent"],["minLength","minlength"],["maxLength","maxlength"],["readOnly","readonly"],["reffererPolicy","referrerpolicy"],["rowSpan","rowspan"],["spellCheck","spellcheck"],["tabIndex","tabindex"],["onDoubleClick","onDblClick"],["onDoubleClickCapture","onDblClickCapture"]]);function Pt(t,e,i,n){switch(e){case"dataset":n!=null&&Object.entries(n).forEach(([a,h])=>{h!=null&&delete t.dataset[a]}),Object.entries(i).forEach(([a,h])=>{h!=null&&(t.dataset[a]=h)});return;case"textContent":ce(i)?t[e]=i:ce(n)&&(t[e]="");return;case"dangerouslySetInnerHTML":j(i)?t.innerHTML=i.__html:j(n)&&(t.innerHTML="");return;case"value":if(i==null){n!=null&&(t[e]=null);return}else{if(t instanceof window.HTMLSelectElement)return;if(t instanceof window.HTMLTextAreaElement){t.value=i;return}}break;case"class":wi(t,i,n);return;case"spellcheck":t.spellcheck=i===""||i===!0||i==="true"?!0:i===!1||i==="false"?!1:i;return;case"draggable":i===!1||i==="false"?i="false":i===""?i=null:(i===!0||i==="true")&&(i="true");break;case"contenteditable":i===!1?i="false":(i===""||i===!0)&&(i="true");break;case"ref":case"namespaceURI":return;case"style":Pi(t,i,n);return;case"on":case"onCapture":const r=e==="onCapture";n!=null&&Object.entries(n).forEach(([a,h])=>{(i==null||i[a]!==h)&&t.removeEventListener(a,h,r)}),Object.entries(i).forEach(([a,h])=>{(n==null||n[a]!==h)&&t.addEventListener(a,h,r)});return;case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":t.setAttributeNS(xi,Se(e,":"),i);return;case"xmlnsXlink":t.setAttribute("xmlns:xlink",i);return;case"xmlBase":case"xmlLang":case"xmlSpace":t.setAttributeNS(Si,Se(e,":"),i);return}if(typeof i=="function"){if(e[0]==="o"&&e[1]==="n"){if(n!=null&&n===i)return;let r=e.toLowerCase();const a=r.endsWith("capture");let h;!a&&(t[r]===null||n!=null&&t[r]===n)?(t[r]=i,We(t,Ti.bind(t,r))):a?(h=r.substring(2,r.length-7),n!=null&&t.removeEventListener(h,n,!0),t.addEventListener(h,i,!0)):(r in window?h=r.substring(2):h=r[2]+e.slice(3),n!=null&&t.removeEventListener(h,n),t.addEventListener(h,i))}else console.warn(`A function was provided for JSX ${t.tagName} element ${e} which does not start with "on":`,i,t.tagName);return}if(j(n)){if(n===i)return;delete t[e]}if(n===!0){if(n===i)return;t.removeAttribute(e)}if(n!==!1&&n!=null){if(n===i)return;t instanceof SVGElement&&!dt.test(e)?t.removeAttributeNS(Se(e,"-"),i):t.removeAttribute(e)}if(j(i)){t[e]=i;return}if(i===!0){t.setAttribute(e,"");return}i!==!1&&i!=null&&(t instanceof SVGElement&&!dt.test(e)?t.setAttribute(Se(e,"-"),i):t.setAttribute(e,i))}function Ci(t,e){for(let[i,n]of Object.entries(e))i=ki.get(i)??i,te(n)?de(n,r=>Pt(t,i,r.newValue,r.prevValue),{lifecycleNode:t}):ti(n)?n[ct](t,i):Pt(t,i,n);return t}function Ti(t){this[t]=null}function c(t,e){let{children:i,...n}=e||{},r=n.namespaceURI;r||(ri.has(t)?r=ai:oi.has(t)?r=ni:r=li());let a;if(Pe(t)){if(a=r?document.createElementNS(r,t):document.createElement(t),Ci(a,n),xe(a,i),a instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const h=n.value.map(u=>String(u));a.querySelectorAll("option").forEach(u=>u.selected=h.includes(u.value))}else a.value=n.value;Fe(n.ref,a)}else if(typeof t=="function")j(t.defaultProps)&&(n={...t.defaultProps,...n}),a=ei(t)?si(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return a}var Ai=Symbol.for("preact-signals");function qe(){if(ie>1)ie--;else{var t,e=!1;for(function(){var r=Ce;for(Ce=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();ge!==void 0;){var i=ge;for(ge=void 0,ke++;i!==void 0;){var n=i.u;if(i.u=void 0,i.f&=-3,!(8&i.f)&&Ct(i))try{i.c()}catch(r){e||(t=r,e=!0)}i=n}}if(ke=0,ie--,e)throw t}}var R=void 0;function xt(t){var e=R;R=void 0;try{return t()}finally{R=e}}var ge=void 0,ie=0,ke=0,St=0,Ce=void 0,Te=0;function kt(t){if(R!==void 0){var e=t.n;if(e===void 0||e.t!==R)return e={i:0,S:t,p:R.s,n:void 0,t:R,e:void 0,x:void 0,r:e},R.s!==void 0&&(R.s.n=e),R.s=e,t.n=e,32&R.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=R.s,e.n=void 0,R.s.n=e,R.s=e),e}}function _(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}_.prototype.brand=Ai,_.prototype.h=function(){return!0},_.prototype.S=function(t){var e=this,i=this.t;i!==t&&t.e===void 0&&(t.x=i,this.t=t,i!==void 0?i.e=t:xt(function(){var n;(n=e.W)==null||n.call(e)}))},_.prototype.U=function(t){var e=this;if(this.t!==void 0){var i=t.e,n=t.x;i!==void 0&&(i.x=n,t.e=void 0),n!==void 0&&(n.e=i,t.x=void 0),t===this.t&&(this.t=n,n===void 0&&xt(function(){var r;(r=e.Z)==null||r.call(e)}))}},_.prototype.subscribe=function(t){var e=this;return Ei(function(){var i=e.value,n=R;R=void 0;try{t(i)}finally{R=n}},{name:"sub"})},_.prototype.valueOf=function(){return this.value},_.prototype.toString=function(){return this.value+""},_.prototype.toJSON=function(){return this.value},_.prototype.peek=function(){var t=R;R=void 0;try{return this.value}finally{R=t}},Object.defineProperty(_.prototype,"value",{get:function(){var t=kt(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(ke>100)throw new Error("Cycle detected");(function(i){ie!==0&&ke===0&&i.l!==St&&(i.l=St,Ce={S:i,v:i.v,i:i.i,o:Ce})})(this),this.v=t,this.i++,Te++,ie++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{qe()}}}});function Ct(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Tt(t){for(var e=t.s;e!==void 0;e=e.n){var i=e.S.n;if(i!==void 0&&(e.r=i),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function At(t){for(var e=t.s,i=void 0;e!==void 0;){var n=e.p;e.i===-1?(e.S.U(e),n!==void 0&&(n.n=e.n),e.n!==void 0&&(e.n.p=n)):i=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=n}t.s=i}function ne(t,e){_.call(this,void 0),this.x=t,this.s=void 0,this.g=Te-1,this.f=4,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}ne.prototype=new _,ne.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Te))return!0;if(this.g=Te,this.f|=1,this.i>0&&!Ct(this))return this.f&=-2,!0;var t=R;try{Tt(this),R=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(i){this.v=i,this.f|=16,this.i++}return R=t,At(this),this.f&=-2,!0},ne.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}_.prototype.S.call(this,t)},ne.prototype.U=function(t){if(this.t!==void 0&&(_.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},ne.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}},Object.defineProperty(ne.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=kt(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Mt(t){var e=t.m;if(t.m=void 0,typeof e=="function"){ie++;var i=R;R=void 0;try{e()}catch(n){throw t.f&=-2,t.f|=8,Ve(t),n}finally{R=i,qe()}}}function Ve(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Mt(t)}function Mi(t){if(R!==this)throw new Error("Out-of-order effect");At(this),R=t,this.f&=-2,8&this.f&&Ve(this),qe()}function oe(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e==null?void 0:e.name}oe.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}},oe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Mt(this),Tt(this),ie++;var t=R;return R=this,Mi.bind(this,t)},oe.prototype.N=function(){2&this.f||(this.f|=2,this.u=ge,ge=this)},oe.prototype.d=function(){this.f|=8,1&this.f||Ve(this)},oe.prototype.dispose=function(){this.d()};function Ei(t,e){var i=new oe(t,e);try{i.c()}catch(r){throw i.d(),r}var n=i.d.bind(i);return n[Symbol.dispose]=n,n}const Ze={en:{emptyStateTitle:"No data available.",thumbnails:"Thumbnails",singlePageMode:"Single Page Mode",pages:"Pages",previous:"Previous",next:"Next",zoomOut:"Zoom Out",zoomIn:"Zoom In",fullscreen:"Fullscreen",settings:"Settings",downloadCatalog:"Download Catalog",share:"Share",bookmark:"Bookmark page",removeBookmark:"Remove bookmark",notes:"Page note",saveNote:"Save note",clearNote:"Clear note",closeNote:"Close note editor",editNote:"Edit",deleteNote:"Delete",play:"Play",pause:"Pause",tableOfContents:"Table of Contents",search:"Search",searchPlaceholder:"Search PDF text",clearSearch:"Clear",closeSearch:"Close search",noSearchResults:"No results",searchUnavailable:"Text search is available only in Direct PDF mode.",closeHotspot:"Close popup",annotation:"Page annotation"},tr:{emptyStateTitle:"Veri bulunamadi.",thumbnails:"Küçük Resimler",singlePageMode:"Tek Sayfa Modu",pages:"Sayfalar",previous:"Önceki",next:"Sonraki",zoomOut:"Uzaklaş",zoomIn:"Yaklaş",fullscreen:"Tam Ekran",settings:"Ayarlar",downloadCatalog:"Kataloğu İndir",share:"Paylaş",bookmark:"Sayfayı yer imlerine ekle",removeBookmark:"Yer imini kaldır",notes:"Sayfa notu",saveNote:"Notu kaydet",clearNote:"Notu temizle",closeNote:"Not editörünü kapat",editNote:"Düzenle",deleteNote:"Sil",play:"Otomatik Oynat",pause:"Duraklat",tableOfContents:"İçindekiler",search:"Ara",searchPlaceholder:"PDF metninde ara",clearSearch:"Temizle",closeSearch:"Aramayı kapat",noSearchResults:"Sonuç bulunamadı",searchUnavailable:"Metin arama yalnızca Doğrudan PDF modunda desteklenir.",closeHotspot:"Açılır pencereyi kapat",annotation:"Sayfa açıklaması"}};function pe(t={}){var r;const e=t.locale??"en",i=Ze[e]??Ze.en,n=((r=t.messages)==null?void 0:r[e])??{};return{...Ze.en,...i,...n}}function Et(t){return t.registry?(t.registry.version.value,t.registry.getToolbarButtons().filter(i=>(i.placement||"end")===t.placement).map(i=>{const n=typeof i.disabled=="function"?i.disabled():i.disabled;return c("button",{type:"button",class:"bk-btn bk-btn--plugin",onClick:i.onClick,disabled:n,"aria-label":i.title||i.label,title:i.title||i.label,children:[i.icon?c("span",{class:"bk-plugin-button-icon","aria-hidden":"true",children:i.icon}):null,c("span",{class:"bk-plugin-button-label",children:i.label})]})})):[]}function Ii(t){const e=p(()=>pe({locale:t.store.locale.value,messages:t.store.messages.value}));return c("div",{class:"bk-toolbar",role:"toolbar","aria-label":"Flipbook controls",children:[c("div",{class:"bk-btn-group",children:[Et({registry:t.pluginRegistry,placement:"start"}),c("button",{type:"button",class:p(()=>`bk-btn ${t.store.showThumbs.value?"active":""}`),onClick:t.onToggleThumbs,"aria-label":p(()=>e.value.thumbnails||"Thumbnails"),"aria-pressed":p(()=>t.store.showThumbs.value?"true":"false"),title:p(()=>e.value.thumbnails||"Thumbnails"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("rect",{x:"3",y:"3",width:"7",height:"7"}),c("rect",{x:"14",y:"3",width:"7",height:"7"}),c("rect",{x:"14",y:"14",width:"7",height:"7"}),c("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),p(()=>t.store.toc.value.length?c("button",{type:"button",class:p(()=>t.store.showToc.value?"bk-btn active":"bk-btn"),onClick:t.onToggleToc,"aria-label":p(()=>e.value.tableOfContents||"Table of Contents"),"aria-pressed":p(()=>t.store.showToc.value?"true":"false"),title:p(()=>e.value.tableOfContents||"Table of Contents"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),c("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),c("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),c("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),c("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),c("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]})}):null),c("button",{type:"button",class:p(()=>t.store.showSearch.value?"bk-btn active":"bk-btn"),onClick:t.onToggleSearch,disabled:p(()=>!t.store.isPdfMode.value),"aria-label":p(()=>t.store.isPdfMode.value?e.value.search||"Search":e.value.searchUnavailable||"Text search is available only in Direct PDF mode."),"aria-pressed":p(()=>t.store.showSearch.value?"true":"false"),title:p(()=>t.store.isPdfMode.value?e.value.search||"Search":e.value.searchUnavailable||"Text search is available only in Direct PDF mode."),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("circle",{cx:"11",cy:"11",r:"7"}),c("line",{x1:"16",y1:"16",x2:"21",y2:"21"})]})}),c("button",{type:"button",class:p(()=>`bk-btn bz-hide-mobile ${t.store.isSingleMode.value?"active":""}`),onClick:t.onToggleSingleMode,"aria-label":p(()=>e.value.singlePageMode||"Single Page"),"aria-pressed":p(()=>t.store.isSingleMode.value?"true":"false"),title:p(()=>e.value.singlePageMode||"Single Page"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c("polyline",{points:"14 2 14 8 20 8"}),c("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),c("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),c("polyline",{points:"10 9 9 9 8 9"})]})}),c("button",{type:"button",class:p(()=>`bk-btn ${t.store.isAutoPlaying.value?"active":""}`),onClick:t.onToggleAutoPlay,"aria-label":p(()=>t.store.isAutoPlaying.value?e.value.pause||"Pause":e.value.play||"Play"),"aria-pressed":p(()=>t.store.isAutoPlaying.value?"true":"false"),title:p(()=>t.store.isAutoPlaying.value?e.value.pause||"Pause":e.value.play||"Play"),children:[c("svg",{style:{display:p(()=>t.store.isAutoPlaying.value?"block":"none")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("rect",{x:"6",y:"4",width:"4",height:"16"}),c("rect",{x:"14",y:"4",width:"4",height:"16"})]}),c("svg",{style:{display:p(()=>t.store.isAutoPlaying.value?"none":"block")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:c("polygon",{points:"5 3 19 12 5 21 5 3"})})]})]}),c("div",{class:"bk-btn-group bk-btn-group--center",children:[c("button",{type:"button",class:"bk-btn",onClick:t.onPrevPage,"aria-label":p(()=>e.value.previous||"Previous"),title:p(()=>e.value.previous||"Previous"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:c("polyline",{points:"15 18 9 12 15 6"})})}),c("span",{class:"bz-page-info","aria-live":"polite","aria-atomic":"true",children:p(()=>{const i=t.store.currentPage.value,n=t.store.totalPages.value;if(t.store.isSingleMode.value||i===0||i>=n-1)return`${i+1} / ${n}`;const r=i%2===1?i:i-1;return`${r+1}-${r+2} / ${n}`})}),c("button",{type:"button",class:"bk-btn",onClick:t.onNextPage,"aria-label":p(()=>e.value.next||"Next"),title:p(()=>e.value.next||"Next"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:c("polyline",{points:"9 18 15 12 9 6"})})})]}),c("div",{class:"bk-btn-group",children:[c("button",{type:"button",class:"bk-btn",onClick:t.onZoomIn,"aria-label":p(()=>e.value.zoomIn||"Zoom In"),title:p(()=>e.value.zoomIn||"Zoom In"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("circle",{cx:"11",cy:"11",r:"8"}),c("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),c("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),c("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),c("button",{type:"button",class:p(()=>`bk-btn ${t.store.isZoomed.value?"active":""}`),onClick:t.onZoomOut,"aria-label":p(()=>e.value.zoomOut||"Zoom Out"),title:p(()=>e.value.zoomOut||"Zoom Out"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("circle",{cx:"11",cy:"11",r:"8"}),c("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),c("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),c("button",{type:"button",class:"bk-btn bk-btn--fullscreen",onClick:t.onToggleFullscreen,"aria-label":p(()=>e.value.fullscreen||"Fullscreen"),title:p(()=>e.value.fullscreen||"Fullscreen"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:c("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),c("button",{type:"button",class:"bk-btn bk-btn--share",onClick:t.onShare,"aria-label":p(()=>e.value.share||"Share"),title:p(()=>e.value.share||"Share"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("circle",{cx:"18",cy:"5",r:"3"}),c("circle",{cx:"6",cy:"12",r:"3"}),c("circle",{cx:"18",cy:"19",r:"3"}),c("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),c("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}),c("button",{type:"button",class:p(()=>`bk-btn bk-btn--bookmark ${t.store.bookmarkedPages.value.has(t.store.currentPage.value)?"active":""}`),onClick:t.onToggleBookmark,"aria-label":p(()=>t.store.bookmarkedPages.value.has(t.store.currentPage.value)?e.value.removeBookmark||"Remove bookmark":e.value.bookmark||"Bookmark page"),title:p(()=>t.store.bookmarkedPages.value.has(t.store.currentPage.value)?e.value.removeBookmark||"Remove bookmark":e.value.bookmark||"Bookmark page"),"aria-pressed":p(()=>t.store.bookmarkedPages.value.has(t.store.currentPage.value)?"true":"false"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:c("path",{d:"M5 4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v18l-7-4-7 4V4z"})})}),c("button",{type:"button",class:p(()=>`bk-btn bk-btn--notes ${t.store.showNotes.value?"active":""}`),onClick:t.onToggleNotes,"aria-label":p(()=>e.value.notes||"Page note"),title:p(()=>e.value.notes||"Page note"),"aria-pressed":p(()=>t.store.showNotes.value?"true":"false"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c("polyline",{points:"14 2 14 8 20 8"}),c("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),c("line",{x1:"8",y1:"17",x2:"14",y2:"17"})]})}),p(()=>t.store.allowDownload.value&&t.store.hasDownloadUrl.value&&t.onDownload?c("button",{type:"button",class:"bk-btn bk-btn--download",onClick:t.onDownload,"aria-label":p(()=>e.value.downloadCatalog||"Download"),title:p(()=>e.value.downloadCatalog||"Download"),children:c("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),c("polyline",{points:"7 10 12 15 17 10"}),c("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}):null),c("button",{type:"button",class:p(()=>`bk-btn ${t.store.soundEnabled.value?"":"muted"}`),onClick:t.onSoundToggle,"aria-label":"Sound","aria-pressed":p(()=>t.store.soundEnabled.value?"true":"false"),title:"Sound",children:[c("svg",{style:{display:p(()=>t.store.soundEnabled.value?"block":"none")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),c("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),c("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}),c("svg",{style:{display:p(()=>t.store.soundEnabled.value?"none":"block")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[c("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),c("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),c("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),Et({registry:t.pluginRegistry,placement:"end"})]})]})}function Ri(t){return c("div",{class:"bk-thumbs",style:p(()=>t.store.showThumbs.value?"display:flex;":"display:none;"),children:t.store.pages.value.map((e,i)=>{const n=()=>{const r=t.store.currentPage.value;if(t.store.isSingleMode.value||r===0||r>=t.store.pages.value.length-1)return r===i;const a=r%2===1?r:r-1;return i===a||i===a+1};return c("div",{class:p(()=>`thumb-item ${n()?"active":""}`),role:"button",tabindex:"0","aria-label":`Go to page ${i+1}`,"aria-current":p(()=>n()?"page":void 0),onClick:()=>t.onThumbClick(i),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.onThumbClick(i))},children:c("div",{class:"thumb-img-wrapper",children:[c("img",{"data-pdf-page":e.assetId.startsWith("pdf-page-")?e.sourcePageNumber??e.pageNumber:void 0,class:`thumb-img ${e.cropMode!=="full"?"thumb-img--split thumb-img--"+e.cropMode:""}`,src:e.thumb||e.low||e.normal,alt:`Page ${i+1}`,loading:"lazy",onError:r=>{r.currentTarget.style.display="none"}}),c("span",{class:"thumb-page-number",children:i+1})]})})})})}function It(t,e,i){return c("ol",{class:"bk-toc-list",children:t.map(n=>{var r;return c("li",{class:"bk-toc-item",children:[c("button",{type:"button",class:p(()=>e.currentPage.value===n.pageIndex?"bk-toc-entry active":"bk-toc-entry"),"aria-current":p(()=>e.currentPage.value===n.pageIndex?"page":void 0),onClick:()=>i(n.pageIndex),children:[c("span",{class:"bk-toc-title",children:n.title}),c("span",{class:"bk-toc-page",children:n.pageIndex+1})]}),(r=n.children)!=null&&r.length?It(n.children,e,i):null]})})})}function Di(t){const e=p(()=>pe({locale:t.store.locale.value,messages:t.store.messages.value}));return c("nav",{class:"bk-toc","aria-label":p(()=>e.value.tableOfContents||"Table of Contents"),style:p(()=>t.store.showToc.value&&t.store.toc.value.length?"display:flex;":"display:none;"),children:[c("div",{class:"bk-toc-heading",children:p(()=>e.value.tableOfContents||"Table of Contents")}),It(t.store.toc.value,t.store,t.onEntryClick)]})}function Li(t){const e=p(()=>pe({locale:t.store.locale.value,messages:t.store.messages.value})),i=T(""),n=T(!1),r={current:null};let a=-1;const h=p(()=>{const y=t.store.currentPage.value,A=t.store.pageNotes.value.get(y)??"";return a!==y&&(a=y,i.value=A,n.value=!A),i.value}),u=p(()=>t.store.pageNotes.value.get(t.store.currentPage.value)??""),w=y=>{i.value=y.currentTarget.value},x=()=>{i.value=u.value,n.value=!0},P=y=>{var A;y==null||y.preventDefault(),t.onSave(((A=r.current)==null?void 0:A.value)??i.value),n.value=!1},z=y=>{y==null||y.preventDefault(),i.value="",r.current&&(r.current.value=""),t.onClear(),n.value=!0},k=()=>c("div",{class:"bk-notes-editor",children:[c("textarea",{ref:r,class:"bk-notes-input","aria-label":p(()=>e.value.notes||"Page note"),placeholder:p(()=>e.value.notes||"Page note"),value:h,onInput:w,rows:4}),c("div",{class:"bk-notes-actions",children:[c("button",{type:"button",class:"bk-notes-clear",onClick:z,children:p(()=>e.value.clearNote||"Clear note")}),c("button",{type:"button",class:"bk-notes-save",onClick:P,children:p(()=>e.value.saveNote||"Save note")})]})]}),m=()=>c("div",{class:"bk-note-saved",children:[c("p",{class:"bk-note-content",children:u}),c("div",{class:"bk-note-actions",children:[c("button",{type:"button",class:"bk-note-badge bk-note-badge--edit",onClick:x,children:p(()=>e.value.editNote||"Edit")}),c("button",{type:"button",class:"bk-note-badge bk-note-badge--delete",onClick:z,children:p(()=>e.value.deleteNote||"Delete")})]})]});return c("aside",{class:"bk-notes-panel",style:p(()=>t.store.showNotes.value?"display:flex;":"display:none;"),"aria-label":p(()=>e.value.notes||"Page note"),children:[c("div",{class:"bk-notes-heading-row",children:[c("div",{class:"bk-notes-heading",children:p(()=>e.value.notes||"Page note")}),c("button",{type:"button",class:"bk-notes-close",onClick:t.onClose,"aria-label":p(()=>e.value.closeNote||"Close note editor"),title:p(()=>e.value.closeNote||"Close note editor"),children:c("span",{"aria-hidden":"true",children:"×"})})]}),p(()=>u.value&&!n.value?m():k())]})}function Ni(t,e){return t.type==="image"?c("img",{class:"bk-hotspot-media-image",src:t.src,alt:t.alt||"",loading:"lazy"}):t.type==="video"?c("video",{class:"bk-hotspot-media-video",controls:!0,preload:"metadata",poster:t.poster,"aria-label":t.alt||e,children:c("source",{src:t.src})}):c("audio",{class:"bk-hotspot-media-audio",controls:!0,preload:"metadata","aria-label":t.alt||e,children:c("source",{src:t.src})})}function H(t){t.stopPropagation()}function zi(t){const e=i=>Math.max(0,Math.min(1,i))*100;return"left:"+e(t.x)+"%;top:"+e(t.y)+"%;width:"+e(t.width)+"%;height:"+e(t.height)+"%;"}function Fi(t){const e=p(()=>pe({locale:t.store.locale.value,messages:t.store.messages.value})),i=p(()=>t.store.hotspots.value.filter(a=>a.pageIndex===t.pageIndex)),n=p(()=>t.store.annotations.value.filter(a=>a.pageIndex===t.pageIndex)),r=T(0);return c("div",{class:"bk-hotspot-layer",children:[i.value.map(a=>c("button",{type:"button",class:"bk-hotspot",style:zi(a),"aria-label":a.label,onClick:()=>{r.value=0,t.onActivate(a)},children:c("span",{class:"bk-hotspot-label",children:a.label})})),n.value.map(a=>c("button",{type:"button",class:"bk-annotation-marker",style:"left:"+Math.max(0,Math.min(1,a.x))*100+"%;top:"+Math.max(0,Math.min(1,a.y))*100+"%;"+(a.color?"color:"+a.color+";":""),"aria-label":a.text,onClick:()=>t.onAnnotationActivate(a),children:"●"})),p(()=>{const a=t.store.hotspots.value.find(x=>x.id===t.store.activeHotspotId.value&&x.pageIndex===t.pageIndex);if(!a)return null;const h=a.gallery||[],u=h.length?Math.min(r.value,h.length-1):0,w=h[u];return c("div",{class:"bk-hotspot-popup",onPointerDown:H,onPointerMove:H,onPointerUp:H,onPointerCancel:H,onTouchStart:H,onTouchMove:H,onTouchEnd:H,onMouseDown:H,role:"dialog","aria-label":a.label,children:[c("div",{class:"bk-hotspot-popup-heading",children:[c("strong",{children:a.label}),c("button",{type:"button",class:"bk-hotspot-popup-close",onClick:t.onClose,"aria-label":p(()=>e.value.closeHotspot||"Close popup"),children:"×"})]}),a.content?c("p",{children:a.content}):null,a.media?c("div",{class:"bk-hotspot-popup-media",children:Ni(a.media,a.label)}):null,w?c("div",{class:"bk-hotspot-gallery","aria-label":a.label+" gallery",children:[c("div",{class:"bk-hotspot-gallery-thumbs",children:h.map((x,P)=>c("button",{type:"button",class:p(()=>"bk-hotspot-gallery-thumb"+(P===u?" is-selected":"")),onClick:()=>{r.value=P},"aria-label":x.alt||"Gallery image "+(P+1),"aria-pressed":p(()=>P===u?"true":"false"),children:c("img",{src:x.src,alt:x.alt||"",loading:"lazy"})}))}),w.href?c("a",{href:w.href,target:w.target||"_blank",rel:"noopener noreferrer",children:c("img",{class:"bk-hotspot-gallery-selected",src:w.src,alt:w.alt||""})}):c("img",{class:"bk-hotspot-gallery-selected",src:w.src,alt:w.alt||""})]}):null,a.href?c("a",{class:"bk-hotspot-link",href:a.href,target:a.target||"_blank",rel:"noopener noreferrer",children:a.kind==="commerce"?a.label:a.href}):null]})}),p(()=>{const a=t.store.annotations.value.find(h=>h.id===t.store.activeAnnotationId.value&&h.pageIndex===t.pageIndex);return a?c("div",{class:"bk-annotation-popup",onPointerDown:H,onPointerMove:H,onPointerUp:H,onPointerCancel:H,onTouchStart:H,onTouchMove:H,onTouchEnd:H,onMouseDown:H,role:"dialog","aria-label":p(()=>e.value.annotation||"Page annotation"),children:[c("div",{class:"bk-hotspot-popup-heading",children:[c("strong",{children:p(()=>e.value.annotation||"Page annotation")}),c("button",{type:"button",class:"bk-hotspot-popup-close",onClick:t.onAnnotationClose,"aria-label":"Close",children:"×"})]}),c("p",{children:a.text})]}):null})]})}function Rt(t){const e=p(()=>t.store.searchResults.value.filter(i=>i.pageIndex===t.pageIndex).flatMap(i=>i.highlights??[]));return c("div",{class:"bk-search-highlight-layer","aria-hidden":"true",children:p(()=>c("div",{class:"bk-search-highlight-items",children:e.value.map(i=>c("span",{class:"bk-search-text-highlight",style:"left:"+i.x*100+"%;top:"+i.y*100+"%;width:"+i.width*100+"%;height:"+i.height*100+"%;"}))}))})}function Oi(t){return c("div",{role:"region","aria-label":"Flipbook viewer",class:p(()=>{let e="bk-book-wrapper ";return t.store.isDoublePageLayout.value&&(e+="double-mode "),t.store.isFrontCover.value&&(e+="bk-is-cover "),t.store.isBackCover.value&&(e+="bk-is-back-cover "),t.store.zoomState.value.isActive&&(e+="zoomed "),e.trim()}),ref:t.bookWrapperRef,children:c("div",{class:"bk-book-sizer",ref:t.bookSizerRef,children:[c("div",{ref:t.bookContainerRef,class:p(()=>"bk-book "+(t.store.flipState.value!=="read"?"is-flipping":"")),style:p(()=>`display: ${t.store.isSingleMode.value?"none":"block"};`),children:t.store.pages.value.map((e,i)=>{const n=i===0||i===t.store.pages.value.length-1;return c("div",{class:p(()=>`bz-page ${i===0?"bz-page--cover":""} ${i===t.store.pages.value.length-1?"bz-page--back":""}`),"data-density":n?"hard":"soft","data-idx":i,children:c("div",{class:"bz-page-content",style:"position:relative; width:100%; height:100%; overflow:hidden;",children:[c("img",{"data-pdf-page":e.assetId.startsWith("pdf-page-")?e.sourcePageNumber??e.pageNumber:void 0,src:e.low||e.normal,"data-src":e.normal,class:`page-content ${e.cropMode!=="full"?"page-content--split page-content--"+e.cropMode:""}`,alt:`Page ${i+1}`,loading:"lazy"}),c(Rt,{store:t.store,pageIndex:i}),c(Fi,{store:t.store,pageIndex:i,onActivate:t.onHotspotActivate,onClose:t.onHotspotClose,onAnnotationActivate:t.onAnnotationActivate,onAnnotationClose:t.onAnnotationClose}),c("div",{class:"page-shadow"})]})})})}),c("div",{class:"bk-single-view",style:p(()=>`display: ${t.store.isSingleMode.value?"flex":"none"}; width: 100%; height: 100%; justify-content: center; align-items: center; position: absolute; top: 0; left: 0; z-index: 10;`),children:p(()=>{const e=t.store.pages.value[t.store.currentPage.value];return e?c("div",{class:"bk-single-page",children:[c("img",{"data-pdf-page":e.assetId.startsWith("pdf-page-")?e.sourcePageNumber??e.pageNumber:void 0,class:p(()=>`bk-single-img page-content ${e.cropMode!=="full"?"page-content--split page-content--"+e.cropMode:""}`),src:t.store.zoomState.value.isActive?e.normal:e.low||e.normal,alt:`Page ${t.store.currentPage.value+1}`,style:"opacity: 1; transition: opacity 0.3s; box-shadow: var(--flipbook-shadow);"}),c(Rt,{store:t.store,pageIndex:t.store.currentPage.value})]}):null})})]})})}function Bi(t){const e=p(()=>t.store.showArrows.value&&t.store.currentPage.value>0),i=p(()=>!t.store.showArrows.value||t.store.totalPages.value<=1?!1:t.store.currentPage.value<t.store.totalPages.value-1);return c("div",{class:"bk-nav-arrows",style:p(()=>t.store.showArrows.value?"display: flex;":"display: none;"),children:[c("button",{type:"button",class:"bk-nav-arrow bk-nav-prev",style:p(()=>e.value?"visibility: visible;":"visibility: hidden;"),onClick:n=>{n.preventDefault(),t.onPrevPage()},"aria-label":"Previous Page",children:c("div",{class:"bk-arrow-icon bk-arrow-left"})}),c("button",{type:"button",class:"bk-nav-arrow bk-nav-next",style:p(()=>i.value?"visibility: visible;":"visibility: hidden;"),onClick:n=>{n.preventDefault(),t.onNextPage()},"aria-label":"Next Page",children:c("div",{class:"bk-arrow-icon bk-arrow-right"})})]})}function Hi(t){const e=p(()=>pe({locale:t.store.locale.value,messages:t.store.messages.value})),i={current:null},n=T(""),r=()=>{var u;const h=((u=i.current)==null?void 0:u.value)??n.value;n.value=h,t.onSearch(h)},a=()=>{i.current&&(i.current.value=""),n.value="",t.onClear()};return c("section",{class:"bk-search-panel",style:p(()=>t.store.showSearch.value?"display:flex;":"display:none;"),"aria-label":p(()=>e.value.search||"Search"),children:[c("div",{class:"bk-search-heading-row",children:[c("strong",{class:"bk-search-heading",children:p(()=>e.value.search||"Search")}),c("button",{type:"button",class:"bk-search-close",onClick:t.onClose,"aria-label":p(()=>e.value.closeSearch||"Close search"),children:"×"})]}),c("div",{class:"bk-search-form",children:[c("input",{ref:h=>{i.current=h},class:"bk-search-input",type:"search",placeholder:p(()=>e.value.searchPlaceholder||"Search PDF text"),value:p(()=>t.store.searchQuery.value),onInput:h=>{n.value=h.currentTarget.value},onKeyDown:h=>{h.key==="Enter"&&r()}}),c("button",{type:"button",class:"bk-search-submit",onClick:r,children:p(()=>e.value.search||"Search")}),c("button",{type:"button",class:"bk-search-clear",onClick:a,children:p(()=>e.value.clearSearch||"Clear")})]}),c("div",{class:"bk-search-results","aria-live":"polite",children:p(()=>{const h=t.store.searchResults.value;return t.store.searchQuery.value?h.length?c("div",{class:"bk-search-result-list",children:h.map(u=>c("button",{type:"button",class:"bk-search-result",onClick:()=>t.onSelect(u.pageIndex),children:[c("span",{class:"bk-search-result-page",children:u.pageNumber}),c("span",{class:"bk-search-result-text",children:u.snippet}),c("span",{class:"bk-search-result-count",children:u.matches})]}))}):c("div",{class:"bk-search-empty",children:e.value.noSearchResults||"No results"}):null})})]})}function $i(t){let e;const i=n=>{e==null||e(),e=void 0,n&&(e=t.panel.render(n)||void 0)};return c("section",{class:p(()=>`bk-plugin-panel ${t.registry.activePanelId.value===t.panelKey?"is-open":""}`),"aria-hidden":p(()=>t.registry.activePanelId.value===t.panelKey?"false":"true"),"aria-label":t.panel.title||t.panel.id,children:c("div",{class:"bk-plugin-panel-content",ref:i})})}function Wi(t){const e=t.registry.getPanels();return c("div",{class:"bk-plugin-panels",children:e.map(i=>c($i,{panel:i,panelKey:i.key,registry:t.registry}))})}function _i(t){const e=()=>{t.store.showThumbs.value=!t.store.showThumbs.value},i=()=>{t.store.showToc.value=!t.store.showToc.value},n=()=>{t.onToggleNotes()},r=()=>{t.store.isSingleMode.value=!t.store.isSingleMode.value},a=()=>{t.store.isAutoPlaying.value=!t.store.isAutoPlaying.value},h=()=>{var m;(m=t.interactionManagerRef.current)==null||m.zoomIn()},u=()=>{var m;(m=t.interactionManagerRef.current)==null||m.zoomOut()},w=()=>t.onToggleFullscreen(),x=m=>{t.store.currentPage.value=m,t.store.showToc.value=!1},P=m=>{var y;t.store.currentPage.value!==m&&(t.store.currentPage.value=m,(y=t.pageFlipAdapterRef.current)==null||y.playSound())},z=()=>{var m;(m=t.pageFlipAdapterRef.current)==null||m.turnToNextPage()},k=()=>{var m;(m=t.pageFlipAdapterRef.current)==null||m.turnToPrevPage()};return c("div",{class:p(()=>`bk-wrapper bk-theme-${t.store.themeMode.value} ${t.className||""}`),children:[c("div",{class:"bk-main-area",children:[c(Oi,{store:t.store,bookWrapperRef:t.bookWrapperRef,bookSizerRef:t.bookSizerRef,bookContainerRef:t.bookContainerRef,onHotspotActivate:t.onHotspotActivate,onHotspotClose:t.onHotspotClose,onAnnotationActivate:t.onAnnotationActivate,onAnnotationClose:t.onAnnotationClose}),c(Bi,{store:t.store,onPrevPage:k,onNextPage:z}),t.store.whiteLabel.value?null:c("div",{class:"bk-watermark",children:["Powered by ",c("a",{href:"https://flipbookengine.com",target:"_blank",rel:"noopener",style:"text-decoration: underline;",children:"FlipbookEngine"})]}),c(Di,{store:t.store,onEntryClick:x}),c(Hi,{store:t.store,onSearch:t.onSearch,onClear:t.onClearSearch,onClose:t.onCloseSearch,onSelect:t.onSelectSearchResult}),c(Li,{store:t.store,onSave:t.onSaveNote,onClear:t.onClearNote,onClose:t.onCloseNotes}),t.pluginRegistry?c(Wi,{registry:t.pluginRegistry}):null]}),c(Ii,{store:t.store,onToggleThumbs:e,onToggleToc:i,onToggleSearch:()=>t.store.showSearch.value=!t.store.showSearch.value,onToggleSingleMode:r,onZoomIn:h,onZoomOut:u,onDownload:t.onDownload,onShare:t.onShare,onToggleBookmark:t.onToggleBookmark,onToggleNotes:n,onNextPage:z,onPrevPage:k,onSoundToggle:()=>t.store.soundEnabled.value=!t.store.soundEnabled.value,onToggleAutoPlay:a,onToggleFullscreen:w,pluginRegistry:t.pluginRegistry}),c(Ri,{store:t.store,onThumbClick:P})]})}var Ui=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Xe={exports:{}};(function(t,e){(function(i,n){n(e)})(Ui,function(i){class n{constructor(s,o){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=o,this.nowDrawingDensity=this.createdDensity,this.render=s}setDensity(s){this.createdDensity=s,this.nowDrawingDensity=s}setDrawingDensity(s){this.nowDrawingDensity=s}setPosition(s){this.state.position=s}setAngle(s){this.state.angle=s}setArea(s){this.state.area=s}setHardDrawingAngle(s){this.state.hardDrawingAngle=s}setHardAngle(s){this.state.hardAngle=s,this.state.hardDrawingAngle=s}setOrientation(s){this.orientation=s}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class r extends n{constructor(s,o,l){super(s,l),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=o}draw(s){const o=this.render.getContext(),l=this.render.convertToGlobal(this.state.position),d=this.render.getRect().pageWidth,g=this.render.getRect().height;o.save(),o.translate(l.x,l.y),o.beginPath();for(let f of this.state.area)f!==null&&(f=this.render.convertToGlobal(f),o.lineTo(f.x-l.x,f.y-l.y));o.rotate(this.state.angle),o.clip(),this.isLoad?o.drawImage(this.image,0,0,d,g):this.drawLoader(o,{x:0,y:0},d,g),o.restore()}simpleDraw(s){const o=this.render.getRect(),l=this.render.getContext(),d=o.pageWidth,g=o.height,f=s===1?o.left+o.pageWidth:o.left,S=o.top;this.isLoad?l.drawImage(this.image,f,S,d,g):this.drawLoader(l,{x:f,y:S},d,g)}drawLoader(s,o,l,d){s.beginPath(),s.strokeStyle="rgb(200, 200, 200)",s.fillStyle="rgb(255, 255, 255)",s.lineWidth=1,s.rect(o.x+1,o.y+1,l-1,d-1),s.stroke(),s.fill();const g={x:o.x+l/2,y:o.y+d/2};s.beginPath(),s.lineWidth=10,s.arc(g.x,g.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),s.stroke(),s.closePath(),this.loadingAngle+=.07,this.loadingAngle>=2*Math.PI&&(this.loadingAngle=0)}load(){this.isLoad||(this.image.onload=()=>{this.isLoad=!0})}newTemporaryCopy(){return this}getTemporaryCopy(){return this}hideTemporaryCopy(){}}class a{constructor(s,o){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=o,this.app=s,this.currentPageIndex=0,this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[],this.portraitSpread=[];for(let o=0;o<this.pages.length;o++)this.portraitSpread.push([o]);let s=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([s]),s++);for(let o=s;o<this.pages.length;o+=2)o<this.pages.length-1?this.landscapeSpread.push([o,o+1]):(this.landscapeSpread.push([o]),this.pages[o].setDensity("hard"))}getSpread(){return this.render.getOrientation()==="landscape"?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(s){const o=this.getSpread();for(let l=0;l<o.length;l++)if(s===o[l][0]||s===o[l][1])return l;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(s){if(s>=0&&s<this.pages.length)return this.pages[s];throw new Error("Invalid page number")}nextBy(s){const o=this.pages.indexOf(s);return o<this.pages.length-1?this.pages[o+1]:null}prevBy(s){const o=this.pages.indexOf(s);return o>0?this.pages[o-1]:null}getFlippingPage(s){const o=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return s===0?this.pages[o].newTemporaryCopy():this.pages[o-1];{const l=s===0?this.getSpread()[o+1]:this.getSpread()[o-1];return l.length===1||s===0?this.pages[l[0]]:this.pages[l[1]]}}getBottomPage(s){const o=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return s===0?this.pages[o+1]:this.pages[o-1];{const l=s===0?this.getSpread()[o+1]:this.getSpread()[o-1];return l.length===1?this.pages[l[0]]:s===0?this.pages[l[1]]:this.pages[l[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(s=null){if(s===null&&(s=this.currentPageIndex),s<0||s>=this.pages.length)return;const o=this.getSpreadIndexByPage(s);o!==null&&(this.currentSpreadIndex=o,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(s){if(!(s>=0&&s<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=s}showSpread(){const s=this.getSpread()[this.currentSpreadIndex];s.length===2?(this.render.setLeftPage(this.pages[s[0]]),this.render.setRightPage(this.pages[s[1]])):this.render.getOrientation()==="landscape"&&s[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[s[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[s[0]])),this.currentPageIndex=s[0],this.app.updatePageIndex(this.currentPageIndex)}}class h extends a{constructor(s,o,l){super(s,o),this.imagesHref=l}load(){for(const s of this.imagesHref){const o=new r(this.render,s,"soft");o.load(),this.pages.push(o)}this.createSpread()}}class u{static GetDistanceBetweenTwoPoint(s,o){return s===null||o===null?1/0:Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2))}static GetSegmentLength(s){return u.GetDistanceBetweenTwoPoint(s[0],s[1])}static GetAngleBetweenTwoLine(s,o){const l=s[0].y-s[1].y,d=o[0].y-o[1].y,g=s[1].x-s[0].x,f=o[1].x-o[0].x;return Math.acos((l*d+g*f)/(Math.sqrt(l*l+g*g)*Math.sqrt(d*d+f*f)))}static PointInRect(s,o){return o===null?null:o.x>=s.left&&o.x<=s.width+s.left&&o.y>=s.top&&o.y<=s.top+s.height?o:null}static GetRotatedPoint(s,o,l){return{x:s.x*Math.cos(l)+s.y*Math.sin(l)+o.x,y:s.y*Math.cos(l)-s.x*Math.sin(l)+o.y}}static LimitPointToCircle(s,o,l){if(u.GetDistanceBetweenTwoPoint(s,l)<=o)return l;const d=s.x,g=s.y,f=l.x,S=l.y;let C=Math.sqrt(Math.pow(o,2)*Math.pow(d-f,2)/(Math.pow(d-f,2)+Math.pow(g-S,2)))+d;l.x<0&&(C*=-1);let D=(C-d)*(g-S)/(d-f)+g;return d-f+g===0&&(D=o),{x:C,y:D}}static GetIntersectBetweenTwoSegment(s,o,l){return u.PointInRect(s,u.GetIntersectBeetwenTwoLine(o,l))}static GetIntersectBeetwenTwoLine(s,o){const l=s[0].y-s[1].y,d=o[0].y-o[1].y,g=s[1].x-s[0].x,f=o[1].x-o[0].x,S=s[0].x*s[1].y-s[1].x*s[0].y,C=o[0].x*o[1].y-o[1].x*o[0].y,D=l*C-d*S,F=g*C-f*S,B=-(S*f-C*g)/(l*f-d*g),G=-(l*C-d*S)/(l*f-d*g);if(isFinite(B)&&isFinite(G))return{x:B,y:G};if(Math.abs(D-F)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(s,o){const l=Math.abs(s.x-o.x),d=Math.abs(s.y-o.y),g=Math.max(l,d),f=[s];function S(C,D,F,B,G){return D>C?C+G*(F/B):D<C?C-G*(F/B):C}for(let C=1;C<=g;C+=1)f.push({x:S(s.x,o.x,l,g,C),y:S(s.y,o.y,d,g,C)});return f}}class w extends n{constructor(s,o,l){super(s,l),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=o,this.element.classList.add("stf__item"),this.element.classList.add("--"+l)}newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new w(this.render,this.copiedElement,this.nowDrawingDensity)),this.getTemporaryCopy())}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){this.temporaryCopy!==null&&(this.copiedElement.remove(),this.copiedElement=null,this.temporaryCopy=null)}draw(s){const o=s||this.nowDrawingDensity,l=this.render.convertToGlobal(this.state.position),d=this.render.getRect().pageWidth,g=this.render.getRect().height;this.element.classList.remove("--simple");const f=`
2
2
  display: block;
3
3
  z-index: ${this.element.style.zIndex};
4
4
  left: 0;
5
5
  top: 0;
6
- width: ${l}px;
7
- height: ${d}px;
8
- `;n==="hard"?this.drawHard(p):this.drawSoft(a,p)}drawHard(i=""){const n=this.render.getRect().left+this.render.getRect().width/2,a=this.state.hardDrawingAngle,l=i+`
6
+ width: ${d}px;
7
+ height: ${g}px;
8
+ `;o==="hard"?this.drawHard(f):this.drawSoft(l,f)}drawHard(s=""){const o=this.render.getRect().left+this.render.getRect().width/2,l=this.state.hardDrawingAngle,d=s+`
9
9
  backface-visibility: hidden;
10
10
  -webkit-backface-visibility: hidden;
11
11
  clip-path: none;
12
12
  -webkit-clip-path: none;
13
13
  `+(this.orientation===0?`transform-origin: ${this.render.getRect().pageWidth}px 0;
14
- transform: translate3d(0, 0, 0) rotateY(${a}deg);`:`transform-origin: 0 0;
15
- transform: translate3d(${n}px, 0, 0) rotateY(${a}deg);`);this.element.style.cssText=l}drawSoft(i,n=""){let a="polygon( ";for(const d of this.state.area)if(d!==null){let p=this.render.getDirection()===1?{x:-d.x+this.state.position.x,y:d.y-this.state.position.y}:{x:d.x-this.state.position.x,y:d.y-this.state.position.y};p=c.GetRotatedPoint(p,{x:0,y:0},this.state.angle),a+=p.x+"px "+p.y+"px, "}a=a.slice(0,-2),a+=")";const l=n+`transform-origin: 0 0; clip-path: ${a}; -webkit-clip-path: ${a};`+(this.render.isSafari()&&this.state.angle===0?`transform: translate(${i.x}px, ${i.y}px);`:`transform: translate3d(${i.x}px, ${i.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=l}simpleDraw(i){const n=this.render.getRect(),a=n.pageWidth,l=n.height,d=i===1?n.left+n.pageWidth:n.left,p=n.top;this.element.classList.add("--simple"),this.element.style.cssText=`
14
+ transform: translate3d(0, 0, 0) rotateY(${l}deg);`:`transform-origin: 0 0;
15
+ transform: translate3d(${o}px, 0, 0) rotateY(${l}deg);`);this.element.style.cssText=d}drawSoft(s,o=""){let l="polygon( ";for(const g of this.state.area)if(g!==null){let f=this.render.getDirection()===1?{x:-g.x+this.state.position.x,y:g.y-this.state.position.y}:{x:g.x-this.state.position.x,y:g.y-this.state.position.y};f=u.GetRotatedPoint(f,{x:0,y:0},this.state.angle),l+=f.x+"px "+f.y+"px, "}l=l.slice(0,-2),l+=")";const d=o+`transform-origin: 0 0; clip-path: ${l}; -webkit-clip-path: ${l};`+(this.render.isSafari()&&this.state.angle===0?`transform: translate(${s.x}px, ${s.y}px);`:`transform: translate3d(${s.x}px, ${s.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=d}simpleDraw(s){const o=this.render.getRect(),l=o.pageWidth,d=o.height,g=s===1?o.left+o.pageWidth:o.left,f=o.top;this.element.classList.add("--simple"),this.element.style.cssText=`
16
16
  position: absolute;
17
17
  display: block;
18
- height: ${l}px;
19
- left: ${d}px;
20
- top: ${p}px;
21
- width: ${a}px;
22
- z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(i){super.setOrientation(i),this.element.classList.remove("--left","--right"),this.element.classList.add(i===1?"--right":"--left")}setDrawingDensity(i){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+i),super.setDrawingDensity(i)}}class P extends h{constructor(i,n,a,l){super(i,n),this.element=a,this.pagesElement=l}load(){for(const i of this.pagesElement){const n=new b(this.render,i,i.dataset.density==="hard"?"hard":"soft");n.load(),this.pages.push(n)}this.createSpread()}}class A{constructor(i,n,a,l){this.direction=i,this.corner=n,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(a,10),this.pageHeight=parseInt(l,10)}calc(i){try{return this.position=this.calcAngleAndPosition(i),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const i=[];let n=!1;return i.push(this.rect.topLeft),i.push(this.topIntersectPoint),this.sideIntersectPoint===null?n=!0:(i.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(n=!1)),i.push(this.bottomIntersectPoint),(n||this.corner==="bottom")&&i.push(this.rect.bottomLeft),i}getBottomClipArea(){const i=[];return i.push(this.topIntersectPoint),this.corner==="top"?i.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&i.push({x:this.pageWidth,y:0}),i.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?c.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&i.push(this.sideIntersectPoint):this.corner==="top"&&i.push({x:this.pageWidth,y:this.pageHeight}),i.push(this.bottomIntersectPoint),i.push(this.topIntersectPoint),i}getAngle(){return this.direction===0?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return this.direction===0?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return this.direction===1?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return this.corner==="top"?this.topIntersectPoint:this.sideIntersectPoint!==null?this.sideIntersectPoint:this.topIntersectPoint}getShadowAngle(){const i=c.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?i:Math.PI-i}calcAngleAndPosition(i){let n=i;if(this.updateAngleAndGeometry(n),n=this.corner==="top"?this.checkPositionAtCenterLine(n,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(n,{x:0,y:this.pageHeight},{x:0,y:0}),Math.abs(n.x-this.pageWidth)<1&&Math.abs(n.y)<1)throw new Error("Point is too small");return n}updateAngleAndGeometry(i){this.angle=this.calculateAngle(i),this.rect=this.getPageRect(i)}calculateAngle(i){const n=this.pageWidth-i.x+1,a=this.corner==="bottom"?this.pageHeight-i.y:i.y;let l=2*Math.acos(n/Math.sqrt(a*a+n*n));a<0&&(l=-l);const d=Math.PI-l;if(!isFinite(l)||d>=0&&d<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(l=-l),l}getPageRect(i){return this.corner==="top"?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],i):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],i)}getRectFromBasePoint(i,n){return{topLeft:this.getRotatedPoint(i[0],n),topRight:this.getRotatedPoint(i[1],n),bottomLeft:this.getRotatedPoint(i[2],n),bottomRight:this.getRotatedPoint(i[3],n)}}getRotatedPoint(i,n){return{x:i.x*Math.cos(this.angle)+i.y*Math.sin(this.angle)+n.x,y:i.y*Math.cos(this.angle)-i.x*Math.sin(this.angle)+n.y}}calculateIntersectPoint(i){const n={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=c.GetIntersectBetweenTwoSegment(n,[i,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=c.GetIntersectBetweenTwoSegment(n,[i,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=c.GetIntersectBetweenTwoSegment(n,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=c.GetIntersectBetweenTwoSegment(n,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=c.GetIntersectBetweenTwoSegment(n,[i,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=c.GetIntersectBetweenTwoSegment(n,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(i,n,a){let l=i;const d=c.LimitPointToCircle(n,this.pageWidth,l);l!==d&&(l=d,this.updateAngleAndGeometry(l));const p=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let y=this.rect.bottomRight,f=this.rect.topLeft;if(this.corner==="bottom"&&(y=this.rect.topRight,f=this.rect.bottomLeft),y.x<=0){const R=c.LimitPointToCircle(a,p,f);R!==l&&(l=R,this.updateAngleAndGeometry(l))}return l}getSegmentToShadowLine(){const i=this.getShadowStartPoint();return[i,i!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class F{constructor(i,n){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=i,this.app=n}fold(i){this.setState("user_fold"),this.calc===null&&this.start(i),this.do(this.render.convertToPage(i))}flip(i){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(i)||(this.calc!==null&&this.render.finishAnimation(),!this.start(i)))return;const n=this.getBoundsRect();this.setState("flipping");const a=n.height/10,l=this.calc.getCorner()==="bottom"?n.height-a:a,d=this.calc.getCorner()==="bottom"?n.height:0;this.calc.calc({x:n.pageWidth-a,y:l}),this.animateFlippingTo({x:n.pageWidth-a,y:l},{x:-n.pageWidth,y:d},!0)}start(i){this.reset();const n=this.render.convertToBook(i),a=this.getBoundsRect(),l=this.getDirectionByPoint(n),d=n.y>=a.height/2?"bottom":"top";if(!this.checkDirection(l))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(l),this.bottomPage=this.app.getPageCollection().getBottomPage(l),this.render.getOrientation()==="landscape")if(l===1){const p=this.app.getPageCollection().nextBy(this.flippingPage);p!==null&&this.flippingPage.getDensity()!==p.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),p.setDrawingDensity("hard"))}else{const p=this.app.getPageCollection().prevBy(this.flippingPage);p!==null&&this.flippingPage.getDensity()!==p.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),p.setDrawingDensity("hard"))}return this.render.setDirection(l),this.calc=new A(l,d,a.pageWidth.toString(10),a.height.toString(10)),!0}catch{return!1}}do(i){if(this.calc!==null&&this.calc.calc(i)){const n=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea()),this.bottomPage.setPosition(this.calc.getBottomPagePosition()),this.bottomPage.setAngle(0),this.bottomPage.setHardAngle(0),this.flippingPage.setArea(this.calc.getFlippingClipArea()),this.flippingPage.setPosition(this.calc.getActiveCorner()),this.flippingPage.setAngle(this.calc.getAngle()),this.calc.getDirection()===0?this.flippingPage.setHardAngle(90*(200-2*n)/100):this.flippingPage.setHardAngle(-90*(200-2*n)/100),this.render.setPageRect(this.calc.getRect()),this.render.setBottomPage(this.bottomPage),this.render.setFlippingPage(this.flippingPage),this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),n,this.calc.getDirection())}}flipToPage(i,n){const a=this.app.getPageCollection().getCurrentSpreadIndex(),l=this.app.getPageCollection().getSpreadIndexByPage(i);try{l>a&&(this.app.getPageCollection().setCurrentSpreadIndex(l-1),this.flipNext(n)),l<a&&(this.app.getPageCollection().setCurrentSpreadIndex(l+1),this.flipPrev(n))}catch{}}flipNext(i){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:i==="top"?1:this.render.getRect().height-2})}flipPrev(i){this.flip({x:10,y:i==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const i=this.calc.getPosition(),n=this.getBoundsRect(),a=this.calc.getCorner()==="bottom"?n.height:0;i.x<=0?this.animateFlippingTo(i,{x:-n.pageWidth,y:a},!0):this.animateFlippingTo(i,{x:n.pageWidth,y:a},!1)}showCorner(i){if(!this.checkState("read","fold_corner"))return;const n=this.getBoundsRect(),a=n.pageWidth;if(this.isPointOnCorners(i))if(this.calc===null){if(!this.start(i))return;this.setState("fold_corner"),this.calc.calc({x:a-1,y:1});const l=50,d=this.calc.getCorner()==="bottom"?n.height-1:1,p=this.calc.getCorner()==="bottom"?n.height-l:l;this.animateFlippingTo({x:a-1,y:d},{x:a-l,y:p},!1,!1)}else this.do(this.render.convertToPage(i));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(i,n,a,l=!0){const d=c.GetCordsFromTwoPoint(i,n),p=[];for(const f of d)p.push(()=>this.do(f));const y=this.getAnimationDuration(d.length);this.render.startAnimation(p,y,()=>{this.calc&&(a&&(this.calc.getDirection()===1?this.app.turnToPrevPage():this.app.turnToNextPage()),l&&(this.render.setBottomPage(null),this.render.setFlippingPage(null),this.render.clearShadow(),this.setState("read"),this.reset()))})}getCalculation(){return this.calc}getState(){return this.state}setState(i){this.state!==i&&(this.app.updateState(i),this.state=i)}getDirectionByPoint(i){const n=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(i.x-n.pageWidth<=n.width/5)return 1}else if(i.x<n.width/2)return 1;return 0}getAnimationDuration(i){const n=this.app.getSettings().flippingTime;return i>=1e3?n:i/1e3*n}checkDirection(i){return i===0?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null,this.flippingPage=null,this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(...i){for(const n of i)if(this.state===n)return!0;return!1}isPointOnCorners(i){const n=this.getBoundsRect(),a=n.pageWidth,l=Math.sqrt(Math.pow(a,2)+Math.pow(n.height,2))/5,d=this.render.convertToBook(i);return d.x>0&&d.y>0&&d.x<n.width&&d.y<n.height&&(d.x<l||d.x>n.width-l)&&(d.y<l||d.y>n.height-l)}}class k{constructor(i,n){this.leftPage=null,this.rightPage=null,this.flippingPage=null,this.bottomPage=null,this.direction=null,this.orientation=null,this.shadow=null,this.animation=null,this.pageRect=null,this.boundsRect=null,this.timer=0,this.safari=!1,this.setting=n,this.app=i;const a=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=a.exec(window.navigator.userAgent)!==null}render(i){if(this.animation!==null){const n=Math.round((i-this.animation.startedAt)/this.animation.durationFrame);n<this.animation.frames.length?this.animation.frames[n]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=i,this.drawFrame()}start(){this.update();const i=n=>{this.render(n),requestAnimationFrame(i)};requestAnimationFrame(i)}startAnimation(i,n,a){this.finishAnimation(),this.animation={frames:i,duration:n,durationFrame:n/i.length,onAnimateEnd:a,startedAt:this.timer}}finishAnimation(){this.animation!==null&&(this.animation.frames[this.animation.frames.length-1](),this.animation.onAnimateEnd!==null&&this.animation.onAnimateEnd()),this.animation=null}update(){this.boundsRect=null;const i=this.calculateBoundsRect();this.orientation!==i&&(this.orientation=i,this.app.updateOrientation(i))}calculateBoundsRect(){let i="landscape";const n=this.getBlockWidth(),a=n/2,l=this.getBlockHeight()/2,d=this.setting.width/this.setting.height;let p=this.setting.width,y=this.setting.height,f=a-p;return this.setting.size==="stretch"?(n<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(i="portrait"),p=i==="portrait"?this.getBlockWidth():this.getBlockWidth()/2,p>this.setting.maxWidth&&(p=this.setting.maxWidth),y=p/d,y>this.getBlockHeight()&&(y=this.getBlockHeight(),p=y*d),f=i==="portrait"?a-p/2-p:a-p):n<2*p&&this.app.getSettings().usePortrait&&(i="portrait",f=a-p/2-p),this.boundsRect={left:f,top:l-y/2,width:2*p,height:y,pageWidth:p},i}setShadowData(i,n,a,l){if(!this.app.getSettings().drawShadow)return;const d=100*this.getSettings().maxShadowOpacity;this.shadow={pos:i,angle:n,width:3*this.getRect().pageWidth/4*a/100,opacity:(100-a)*d/100/100,direction:l,progress:2*a}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){return this.boundsRect===null&&this.calculateBoundsRect(),this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(i){this.pageRect=i}setDirection(i){this.direction=i}setRightPage(i){i!==null&&i.setOrientation(1),this.rightPage=i}setLeftPage(i){i!==null&&i.setOrientation(0),this.leftPage=i}setBottomPage(i){i!==null&&i.setOrientation(this.direction===1?0:1),this.bottomPage=i}setFlippingPage(i){i!==null&&i.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=i}convertToBook(i){const n=this.getRect();return{x:i.x-n.left,y:i.y-n.top}}isSafari(){return this.safari}convertToPage(i,n){n||(n=this.direction);const a=this.getRect();return{x:n===0?i.x-a.left-a.width/2:a.width/2-i.x+a.left,y:i.y-a.top}}convertToGlobal(i,n){if(n||(n=this.direction),i==null)return null;const a=this.getRect();return{x:n===0?i.x+a.left+a.width/2:a.width/2-i.x+a.left,y:i.y+a.top}}convertRectToGlobal(i,n){return n||(n=this.direction),{topLeft:this.convertToGlobal(i.topLeft,n),topRight:this.convertToGlobal(i.topRight,n),bottomLeft:this.convertToGlobal(i.bottomLeft,n),bottomRight:this.convertToGlobal(i.bottomRight,n)}}}class T extends k{constructor(i,n,a){super(i,n),this.canvas=a,this.ctx=a.getContext("2d")}getContext(){return this.ctx}reload(){}drawFrame(){this.clear(),this.orientation!=="portrait"&&this.leftPage!=null&&this.leftPage.simpleDraw(0),this.rightPage!=null&&this.rightPage.simpleDraw(1),this.bottomPage!=null&&this.bottomPage.draw(),this.drawBookShadow(),this.flippingPage!=null&&this.flippingPage.draw(),this.shadow!=null&&(this.drawOuterShadow(),this.drawInnerShadow());const i=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(i.left+i.pageWidth,i.top,i.width,i.height),this.ctx.clip())}drawBookShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath();const n=i.width/20;this.ctx.rect(i.left,i.top,i.width,i.height);const a={x:i.left+i.width/2-n/2,y:0};this.ctx.translate(a.x,a.y);const l=this.ctx.createLinearGradient(0,0,n,0);l.addColorStop(0,"rgba(0, 0, 0, 0)"),l.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),l.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),l.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),l.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),l.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=l,this.ctx.fillRect(0,0,n,2*i.height),this.ctx.restore()}drawOuterShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(i.left,i.top,i.width,i.height);const n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y});this.ctx.translate(n.x,n.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const a=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),a.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),a.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),a.addColorStop(0,"rgba(0, 0, 0, 0)"),a.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=a,this.ctx.fillRect(0,0,this.shadow.width,2*i.height),this.ctx.restore()}drawInnerShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath();const n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),a=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(a.topLeft.x,a.topLeft.y),this.ctx.lineTo(a.topRight.x,a.topRight.y),this.ctx.lineTo(a.bottomRight.x,a.bottomRight.y),this.ctx.lineTo(a.bottomLeft.x,a.bottomLeft.y),this.ctx.translate(n.x,n.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const l=3*this.shadow.width/4,d=this.ctx.createLinearGradient(0,0,l,0);this.shadow.direction===0?(this.ctx.translate(-l,-100),d.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")"),d.addColorStop(.9,"rgba(0, 0, 0, 0.05)"),d.addColorStop(.7,"rgba(0, 0, 0, "+this.shadow.opacity+")"),d.addColorStop(0,"rgba(0, 0, 0, 0)")):(this.ctx.translate(0,-100),d.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),d.addColorStop(.1,"rgba(0, 0, 0, 0.05)"),d.addColorStop(.3,"rgba(0, 0, 0, "+this.shadow.opacity+")"),d.addColorStop(1,"rgba(0, 0, 0, 0)")),this.ctx.clip(),this.ctx.fillStyle=d,this.ctx.fillRect(0,0,l,2*i.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class D{constructor(i,n,a){this.touchPoint=null,this.swipeTimeout=250,this.onResize=()=>{this.update()},this.onMouseDown=d=>{if(this.checkTarget(d.target)){const p=this.getMousePos(d.clientX,d.clientY);this.app.startUserTouch(p),d.preventDefault()}},this.onTouchStart=d=>{if(this.checkTarget(d.target)&&d.changedTouches.length>0){const p=d.changedTouches[0],y=this.getMousePos(p.clientX,p.clientY);this.touchPoint={point:y,time:Date.now()},setTimeout(()=>{this.touchPoint!==null&&this.app.startUserTouch(y)},this.swipeTimeout),this.app.getSettings().mobileScrollSupport||d.preventDefault()}},this.onMouseUp=d=>{const p=this.getMousePos(d.clientX,d.clientY);this.app.userStop(p)},this.onMouseMove=d=>{const p=this.getMousePos(d.clientX,d.clientY);this.app.userMove(p,!1)},this.onTouchMove=d=>{if(d.changedTouches.length>0){const p=d.changedTouches[0],y=this.getMousePos(p.clientX,p.clientY);this.app.getSettings().mobileScrollSupport?(this.touchPoint!==null&&(Math.abs(this.touchPoint.point.x-y.x)>10||this.app.getState()!=="read")&&d.cancelable&&this.app.userMove(y,!0),this.app.getState()!=="read"&&d.preventDefault()):this.app.userMove(y,!0)}},this.onTouchEnd=d=>{if(d.changedTouches.length>0){const p=d.changedTouches[0],y=this.getMousePos(p.clientX,p.clientY);let f=!1;if(this.touchPoint!==null){const R=y.x-this.touchPoint.point.x,z=Math.abs(y.y-this.touchPoint.point.y);Math.abs(R)>this.swipeDistance&&z<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(R>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"),f=!0),this.touchPoint=null}this.app.userStop(y,f)}},this.parentElement=i,i.classList.add("stf__parent"),i.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=i.querySelector(".stf__wrapper"),this.app=n;const l=this.app.getSettings().usePortrait?1:2;i.style.minWidth=a.minWidth*l+"px",i.style.minHeight=a.minHeight+"px",a.size==="fixed"&&(i.style.minWidth=a.width*l+"px",i.style.minHeight=a.height+"px"),a.autoSize&&(i.style.width="100%",i.style.maxWidth=2*a.maxWidth+"px"),i.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=a.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(i){this.wrapper.classList.remove("--portrait","--landscape"),i==="portrait"?(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%"),this.wrapper.classList.add("--portrait")):(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%"),this.wrapper.classList.add("--landscape")),this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize),this.distElement.removeEventListener("mousedown",this.onMouseDown),this.distElement.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1),this.app.getSettings().useMouseEvents&&(this.distElement.addEventListener("mousedown",this.onMouseDown),this.distElement.addEventListener("touchstart",this.onTouchStart),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport}),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("touchend",this.onTouchEnd))}getMousePos(i,n){const a=this.distElement.getBoundingClientRect();return{x:i-a.left,y:n-a.top}}checkTarget(i){return!this.app.getSettings().clickEventForward||!["a","button"].includes(i.tagName.toLowerCase())}}class W extends D{constructor(i,n,a,l){super(i,n,a),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=i.querySelector(".stf__block"),this.items=l;for(const d of l)this.distElement.appendChild(d);this.setHandlers()}clear(){for(const i of this.items)this.parentElement.appendChild(i)}updateItems(i){this.removeHandlers(),this.distElement.innerHTML="";for(const n of i)this.distElement.appendChild(n);this.items=i,this.setHandlers()}update(){this.app.getRender().update()}}class Q extends D{constructor(i,n,a){super(i,n,a),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=i.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const i=getComputedStyle(this.canvas),n=parseInt(i.getPropertyValue("width"),10),a=parseInt(i.getPropertyValue("height"),10);this.canvas.width=n,this.canvas.height=a}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class _ extends k{constructor(i,n,a){super(i,n),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=a,this.createShadows()}createShadows(){this.element.insertAdjacentHTML("beforeend",`<div class="stf__outerShadow"></div>
18
+ height: ${d}px;
19
+ left: ${g}px;
20
+ top: ${f}px;
21
+ width: ${l}px;
22
+ z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(s){super.setOrientation(s),this.element.classList.remove("--left","--right"),this.element.classList.add(s===1?"--right":"--left")}setDrawingDensity(s){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+s),super.setDrawingDensity(s)}}class x extends a{constructor(s,o,l,d){super(s,o),this.element=l,this.pagesElement=d}load(){for(const s of this.pagesElement){const o=new w(this.render,s,s.dataset.density==="hard"?"hard":"soft");o.load(),this.pages.push(o)}this.createSpread()}}class P{constructor(s,o,l,d){this.direction=s,this.corner=o,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(l,10),this.pageHeight=parseInt(d,10)}calc(s){try{return this.position=this.calcAngleAndPosition(s),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const s=[];let o=!1;return s.push(this.rect.topLeft),s.push(this.topIntersectPoint),this.sideIntersectPoint===null?o=!0:(s.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(o=!1)),s.push(this.bottomIntersectPoint),(o||this.corner==="bottom")&&s.push(this.rect.bottomLeft),s}getBottomClipArea(){const s=[];return s.push(this.topIntersectPoint),this.corner==="top"?s.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&s.push({x:this.pageWidth,y:0}),s.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?u.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&s.push(this.sideIntersectPoint):this.corner==="top"&&s.push({x:this.pageWidth,y:this.pageHeight}),s.push(this.bottomIntersectPoint),s.push(this.topIntersectPoint),s}getAngle(){return this.direction===0?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return this.direction===0?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return this.direction===1?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return this.corner==="top"?this.topIntersectPoint:this.sideIntersectPoint!==null?this.sideIntersectPoint:this.topIntersectPoint}getShadowAngle(){const s=u.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?s:Math.PI-s}calcAngleAndPosition(s){let o=s;if(this.updateAngleAndGeometry(o),o=this.corner==="top"?this.checkPositionAtCenterLine(o,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(o,{x:0,y:this.pageHeight},{x:0,y:0}),Math.abs(o.x-this.pageWidth)<1&&Math.abs(o.y)<1)throw new Error("Point is too small");return o}updateAngleAndGeometry(s){this.angle=this.calculateAngle(s),this.rect=this.getPageRect(s)}calculateAngle(s){const o=this.pageWidth-s.x+1,l=this.corner==="bottom"?this.pageHeight-s.y:s.y;let d=2*Math.acos(o/Math.sqrt(l*l+o*o));l<0&&(d=-d);const g=Math.PI-d;if(!isFinite(d)||g>=0&&g<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(d=-d),d}getPageRect(s){return this.corner==="top"?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],s):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],s)}getRectFromBasePoint(s,o){return{topLeft:this.getRotatedPoint(s[0],o),topRight:this.getRotatedPoint(s[1],o),bottomLeft:this.getRotatedPoint(s[2],o),bottomRight:this.getRotatedPoint(s[3],o)}}getRotatedPoint(s,o){return{x:s.x*Math.cos(this.angle)+s.y*Math.sin(this.angle)+o.x,y:s.y*Math.cos(this.angle)-s.x*Math.sin(this.angle)+o.y}}calculateIntersectPoint(s){const o={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=u.GetIntersectBetweenTwoSegment(o,[s,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=u.GetIntersectBetweenTwoSegment(o,[s,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=u.GetIntersectBetweenTwoSegment(o,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=u.GetIntersectBetweenTwoSegment(o,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=u.GetIntersectBetweenTwoSegment(o,[s,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=u.GetIntersectBetweenTwoSegment(o,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(s,o,l){let d=s;const g=u.LimitPointToCircle(o,this.pageWidth,d);d!==g&&(d=g,this.updateAngleAndGeometry(d));const f=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let S=this.rect.bottomRight,C=this.rect.topLeft;if(this.corner==="bottom"&&(S=this.rect.topRight,C=this.rect.bottomLeft),S.x<=0){const D=u.LimitPointToCircle(l,f,C);D!==d&&(d=D,this.updateAngleAndGeometry(d))}return d}getSegmentToShadowLine(){const s=this.getShadowStartPoint();return[s,s!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class z{constructor(s,o){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=s,this.app=o}fold(s){this.setState("user_fold"),this.calc===null&&this.start(s),this.do(this.render.convertToPage(s))}flip(s){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(s)||(this.calc!==null&&this.render.finishAnimation(),!this.start(s)))return;const o=this.getBoundsRect();this.setState("flipping");const l=o.height/10,d=this.calc.getCorner()==="bottom"?o.height-l:l,g=this.calc.getCorner()==="bottom"?o.height:0;this.calc.calc({x:o.pageWidth-l,y:d}),this.animateFlippingTo({x:o.pageWidth-l,y:d},{x:-o.pageWidth,y:g},!0)}start(s){this.reset();const o=this.render.convertToBook(s),l=this.getBoundsRect(),d=this.getDirectionByPoint(o),g=o.y>=l.height/2?"bottom":"top";if(!this.checkDirection(d))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(d),this.bottomPage=this.app.getPageCollection().getBottomPage(d),this.render.getOrientation()==="landscape")if(d===1){const f=this.app.getPageCollection().nextBy(this.flippingPage);f!==null&&this.flippingPage.getDensity()!==f.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),f.setDrawingDensity("hard"))}else{const f=this.app.getPageCollection().prevBy(this.flippingPage);f!==null&&this.flippingPage.getDensity()!==f.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),f.setDrawingDensity("hard"))}return this.render.setDirection(d),this.calc=new P(d,g,l.pageWidth.toString(10),l.height.toString(10)),!0}catch{return!1}}do(s){if(this.calc!==null&&this.calc.calc(s)){const o=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea()),this.bottomPage.setPosition(this.calc.getBottomPagePosition()),this.bottomPage.setAngle(0),this.bottomPage.setHardAngle(0),this.flippingPage.setArea(this.calc.getFlippingClipArea()),this.flippingPage.setPosition(this.calc.getActiveCorner()),this.flippingPage.setAngle(this.calc.getAngle()),this.calc.getDirection()===0?this.flippingPage.setHardAngle(90*(200-2*o)/100):this.flippingPage.setHardAngle(-90*(200-2*o)/100),this.render.setPageRect(this.calc.getRect()),this.render.setBottomPage(this.bottomPage),this.render.setFlippingPage(this.flippingPage),this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),o,this.calc.getDirection())}}flipToPage(s,o){const l=this.app.getPageCollection().getCurrentSpreadIndex(),d=this.app.getPageCollection().getSpreadIndexByPage(s);try{d>l&&(this.app.getPageCollection().setCurrentSpreadIndex(d-1),this.flipNext(o)),d<l&&(this.app.getPageCollection().setCurrentSpreadIndex(d+1),this.flipPrev(o))}catch{}}flipNext(s){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:s==="top"?1:this.render.getRect().height-2})}flipPrev(s){this.flip({x:10,y:s==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const s=this.calc.getPosition(),o=this.getBoundsRect(),l=this.calc.getCorner()==="bottom"?o.height:0;s.x<=0?this.animateFlippingTo(s,{x:-o.pageWidth,y:l},!0):this.animateFlippingTo(s,{x:o.pageWidth,y:l},!1)}showCorner(s){if(!this.checkState("read","fold_corner"))return;const o=this.getBoundsRect(),l=o.pageWidth;if(this.isPointOnCorners(s))if(this.calc===null){if(!this.start(s))return;this.setState("fold_corner"),this.calc.calc({x:l-1,y:1});const d=50,g=this.calc.getCorner()==="bottom"?o.height-1:1,f=this.calc.getCorner()==="bottom"?o.height-d:d;this.animateFlippingTo({x:l-1,y:g},{x:l-d,y:f},!1,!1)}else this.do(this.render.convertToPage(s));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(s,o,l,d=!0){const g=u.GetCordsFromTwoPoint(s,o),f=[];for(const C of g)f.push(()=>this.do(C));const S=this.getAnimationDuration(g.length);this.render.startAnimation(f,S,()=>{this.calc&&(l&&(this.calc.getDirection()===1?this.app.turnToPrevPage():this.app.turnToNextPage()),d&&(this.render.setBottomPage(null),this.render.setFlippingPage(null),this.render.clearShadow(),this.setState("read"),this.reset()))})}getCalculation(){return this.calc}getState(){return this.state}setState(s){this.state!==s&&(this.app.updateState(s),this.state=s)}getDirectionByPoint(s){const o=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(s.x-o.pageWidth<=o.width/5)return 1}else if(s.x<o.width/2)return 1;return 0}getAnimationDuration(s){const o=this.app.getSettings().flippingTime;return s>=1e3?o:s/1e3*o}checkDirection(s){return s===0?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null,this.flippingPage=null,this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(...s){for(const o of s)if(this.state===o)return!0;return!1}isPointOnCorners(s){const o=this.getBoundsRect(),l=o.pageWidth,d=Math.sqrt(Math.pow(l,2)+Math.pow(o.height,2))/5,g=this.render.convertToBook(s);return g.x>0&&g.y>0&&g.x<o.width&&g.y<o.height&&(g.x<d||g.x>o.width-d)&&(g.y<d||g.y>o.height-d)}}class k{constructor(s,o){this.leftPage=null,this.rightPage=null,this.flippingPage=null,this.bottomPage=null,this.direction=null,this.orientation=null,this.shadow=null,this.animation=null,this.pageRect=null,this.boundsRect=null,this.timer=0,this.safari=!1,this.setting=o,this.app=s;const l=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=l.exec(window.navigator.userAgent)!==null}render(s){if(this.animation!==null){const o=Math.round((s-this.animation.startedAt)/this.animation.durationFrame);o<this.animation.frames.length?this.animation.frames[o]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=s,this.drawFrame()}start(){this.update();const s=o=>{this.render(o),requestAnimationFrame(s)};requestAnimationFrame(s)}startAnimation(s,o,l){this.finishAnimation(),this.animation={frames:s,duration:o,durationFrame:o/s.length,onAnimateEnd:l,startedAt:this.timer}}finishAnimation(){this.animation!==null&&(this.animation.frames[this.animation.frames.length-1](),this.animation.onAnimateEnd!==null&&this.animation.onAnimateEnd()),this.animation=null}update(){this.boundsRect=null;const s=this.calculateBoundsRect();this.orientation!==s&&(this.orientation=s,this.app.updateOrientation(s))}calculateBoundsRect(){let s="landscape";const o=this.getBlockWidth(),l=o/2,d=this.getBlockHeight()/2,g=this.setting.width/this.setting.height;let f=this.setting.width,S=this.setting.height,C=l-f;return this.setting.size==="stretch"?(o<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(s="portrait"),f=s==="portrait"?this.getBlockWidth():this.getBlockWidth()/2,f>this.setting.maxWidth&&(f=this.setting.maxWidth),S=f/g,S>this.getBlockHeight()&&(S=this.getBlockHeight(),f=S*g),C=s==="portrait"?l-f/2-f:l-f):o<2*f&&this.app.getSettings().usePortrait&&(s="portrait",C=l-f/2-f),this.boundsRect={left:C,top:d-S/2,width:2*f,height:S,pageWidth:f},s}setShadowData(s,o,l,d){if(!this.app.getSettings().drawShadow)return;const g=100*this.getSettings().maxShadowOpacity;this.shadow={pos:s,angle:o,width:3*this.getRect().pageWidth/4*l/100,opacity:(100-l)*g/100/100,direction:d,progress:2*l}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){return this.boundsRect===null&&this.calculateBoundsRect(),this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(s){this.pageRect=s}setDirection(s){this.direction=s}setRightPage(s){s!==null&&s.setOrientation(1),this.rightPage=s}setLeftPage(s){s!==null&&s.setOrientation(0),this.leftPage=s}setBottomPage(s){s!==null&&s.setOrientation(this.direction===1?0:1),this.bottomPage=s}setFlippingPage(s){s!==null&&s.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=s}convertToBook(s){const o=this.getRect();return{x:s.x-o.left,y:s.y-o.top}}isSafari(){return this.safari}convertToPage(s,o){o||(o=this.direction);const l=this.getRect();return{x:o===0?s.x-l.left-l.width/2:l.width/2-s.x+l.left,y:s.y-l.top}}convertToGlobal(s,o){if(o||(o=this.direction),s==null)return null;const l=this.getRect();return{x:o===0?s.x+l.left+l.width/2:l.width/2-s.x+l.left,y:s.y+l.top}}convertRectToGlobal(s,o){return o||(o=this.direction),{topLeft:this.convertToGlobal(s.topLeft,o),topRight:this.convertToGlobal(s.topRight,o),bottomLeft:this.convertToGlobal(s.bottomLeft,o),bottomRight:this.convertToGlobal(s.bottomRight,o)}}}class m extends k{constructor(s,o,l){super(s,o),this.canvas=l,this.ctx=l.getContext("2d")}getContext(){return this.ctx}reload(){}drawFrame(){this.clear(),this.orientation!=="portrait"&&this.leftPage!=null&&this.leftPage.simpleDraw(0),this.rightPage!=null&&this.rightPage.simpleDraw(1),this.bottomPage!=null&&this.bottomPage.draw(),this.drawBookShadow(),this.flippingPage!=null&&this.flippingPage.draw(),this.shadow!=null&&(this.drawOuterShadow(),this.drawInnerShadow());const s=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(s.left+s.pageWidth,s.top,s.width,s.height),this.ctx.clip())}drawBookShadow(){const s=this.getRect();this.ctx.save(),this.ctx.beginPath();const o=s.width/20;this.ctx.rect(s.left,s.top,s.width,s.height);const l={x:s.left+s.width/2-o/2,y:0};this.ctx.translate(l.x,l.y);const d=this.ctx.createLinearGradient(0,0,o,0);d.addColorStop(0,"rgba(0, 0, 0, 0)"),d.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),d.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),d.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),d.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),d.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=d,this.ctx.fillRect(0,0,o,2*s.height),this.ctx.restore()}drawOuterShadow(){const s=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(s.left,s.top,s.width,s.height);const o=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y});this.ctx.translate(o.x,o.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const l=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),l.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),l.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),l.addColorStop(0,"rgba(0, 0, 0, 0)"),l.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=l,this.ctx.fillRect(0,0,this.shadow.width,2*s.height),this.ctx.restore()}drawInnerShadow(){const s=this.getRect();this.ctx.save(),this.ctx.beginPath();const o=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),l=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(l.topLeft.x,l.topLeft.y),this.ctx.lineTo(l.topRight.x,l.topRight.y),this.ctx.lineTo(l.bottomRight.x,l.bottomRight.y),this.ctx.lineTo(l.bottomLeft.x,l.bottomLeft.y),this.ctx.translate(o.x,o.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const d=3*this.shadow.width/4,g=this.ctx.createLinearGradient(0,0,d,0);this.shadow.direction===0?(this.ctx.translate(-d,-100),g.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")"),g.addColorStop(.9,"rgba(0, 0, 0, 0.05)"),g.addColorStop(.7,"rgba(0, 0, 0, "+this.shadow.opacity+")"),g.addColorStop(0,"rgba(0, 0, 0, 0)")):(this.ctx.translate(0,-100),g.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),g.addColorStop(.1,"rgba(0, 0, 0, 0.05)"),g.addColorStop(.3,"rgba(0, 0, 0, "+this.shadow.opacity+")"),g.addColorStop(1,"rgba(0, 0, 0, 0)")),this.ctx.clip(),this.ctx.fillStyle=g,this.ctx.fillRect(0,0,d,2*s.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class y{constructor(s,o,l){this.touchPoint=null,this.swipeTimeout=250,this.onResize=()=>{this.update()},this.onMouseDown=g=>{if(this.checkTarget(g.target)){const f=this.getMousePos(g.clientX,g.clientY);this.app.startUserTouch(f),g.preventDefault()}},this.onTouchStart=g=>{if(this.checkTarget(g.target)&&g.changedTouches.length>0){const f=g.changedTouches[0],S=this.getMousePos(f.clientX,f.clientY);this.touchPoint={point:S,time:Date.now()},setTimeout(()=>{this.touchPoint!==null&&this.app.startUserTouch(S)},this.swipeTimeout),this.app.getSettings().mobileScrollSupport||g.preventDefault()}},this.onMouseUp=g=>{const f=this.getMousePos(g.clientX,g.clientY);this.app.userStop(f)},this.onMouseMove=g=>{const f=this.getMousePos(g.clientX,g.clientY);this.app.userMove(f,!1)},this.onTouchMove=g=>{if(g.changedTouches.length>0){const f=g.changedTouches[0],S=this.getMousePos(f.clientX,f.clientY);this.app.getSettings().mobileScrollSupport?(this.touchPoint!==null&&(Math.abs(this.touchPoint.point.x-S.x)>10||this.app.getState()!=="read")&&g.cancelable&&this.app.userMove(S,!0),this.app.getState()!=="read"&&g.preventDefault()):this.app.userMove(S,!0)}},this.onTouchEnd=g=>{if(g.changedTouches.length>0){const f=g.changedTouches[0],S=this.getMousePos(f.clientX,f.clientY);let C=!1;if(this.touchPoint!==null){const D=S.x-this.touchPoint.point.x,F=Math.abs(S.y-this.touchPoint.point.y);Math.abs(D)>this.swipeDistance&&F<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(D>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"),C=!0),this.touchPoint=null}this.app.userStop(S,C)}},this.parentElement=s,s.classList.add("stf__parent"),s.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=s.querySelector(".stf__wrapper"),this.app=o;const d=this.app.getSettings().usePortrait?1:2;s.style.minWidth=l.minWidth*d+"px",s.style.minHeight=l.minHeight+"px",l.size==="fixed"&&(s.style.minWidth=l.width*d+"px",s.style.minHeight=l.height+"px"),l.autoSize&&(s.style.width="100%",s.style.maxWidth=2*l.maxWidth+"px"),s.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=l.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(s){this.wrapper.classList.remove("--portrait","--landscape"),s==="portrait"?(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%"),this.wrapper.classList.add("--portrait")):(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%"),this.wrapper.classList.add("--landscape")),this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize),this.distElement.removeEventListener("mousedown",this.onMouseDown),this.distElement.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1),this.app.getSettings().useMouseEvents&&(this.distElement.addEventListener("mousedown",this.onMouseDown),this.distElement.addEventListener("touchstart",this.onTouchStart),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport}),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("touchend",this.onTouchEnd))}getMousePos(s,o){const l=this.distElement.getBoundingClientRect();return{x:s-l.left,y:o-l.top}}checkTarget(s){return!this.app.getSettings().clickEventForward||!["a","button"].includes(s.tagName.toLowerCase())}}class A extends y{constructor(s,o,l,d){super(s,o,l),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=s.querySelector(".stf__block"),this.items=d;for(const g of d)this.distElement.appendChild(g);this.setHandlers()}clear(){for(const s of this.items)this.parentElement.appendChild(s)}updateItems(s){this.removeHandlers(),this.distElement.innerHTML="";for(const o of s)this.distElement.appendChild(o);this.items=s,this.setHandlers()}update(){this.app.getRender().update()}}class U extends y{constructor(s,o,l){super(s,o,l),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=s.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const s=getComputedStyle(this.canvas),o=parseInt(s.getPropertyValue("width"),10),l=parseInt(s.getPropertyValue("height"),10);this.canvas.width=o,this.canvas.height=l}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class W extends k{constructor(s,o,l){super(s,o),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=l,this.createShadows()}createShadows(){this.element.insertAdjacentHTML("beforeend",`<div class="stf__outerShadow"></div>
23
23
  <div class="stf__innerShadow"></div>
24
24
  <div class="stf__hardShadow"></div>
25
- <div class="stf__hardInnerShadow"></div>`),this.outerShadow=this.element.querySelector(".stf__outerShadow"),this.innerShadow=this.element.querySelector(".stf__innerShadow"),this.hardShadow=this.element.querySelector(".stf__hardShadow"),this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow(),this.outerShadow.style.cssText="display: none",this.innerShadow.style.cssText="display: none",this.hardShadow.style.cssText="display: none",this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const i=this.getRect(),n=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let a=(100-n)*(2.5*i.pageWidth)/100+20;a>i.pageWidth&&(a=i.pageWidth);let l=`
25
+ <div class="stf__hardInnerShadow"></div>`),this.outerShadow=this.element.querySelector(".stf__outerShadow"),this.innerShadow=this.element.querySelector(".stf__innerShadow"),this.hardShadow=this.element.querySelector(".stf__hardShadow"),this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow(),this.outerShadow.style.cssText="display: none",this.innerShadow.style.cssText="display: none",this.hardShadow.style.cssText="display: none",this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const s=this.getRect(),o=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let l=(100-o)*(2.5*s.pageWidth)/100+20;l>s.pageWidth&&(l=s.pageWidth);let d=`
26
26
  display: block;
27
27
  z-index: ${(this.getSettings().startZIndex+5).toString(10)};
28
- width: ${a}px;
29
- height: ${i.height}px;
28
+ width: ${l}px;
29
+ height: ${s.height}px;
30
30
  background: linear-gradient(to right,
31
- rgba(0, 0, 0, ${this.shadow.opacity*n/100}) 5%,
31
+ rgba(0, 0, 0, ${this.shadow.opacity*o/100}) 5%,
32
32
  rgba(0, 0, 0, 0) 100%);
33
- left: ${i.left+i.width/2}px;
33
+ left: ${s.left+s.width/2}px;
34
34
  transform-origin: 0 0;
35
- `;l+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0);":"transform: translate3d(0, 0, 0) rotateY(180deg);",this.hardInnerShadow.style.cssText=l}drawHardOuterShadow(){const i=this.getRect();let n=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*i.pageWidth)/100+20;n>i.pageWidth&&(n=i.pageWidth);let a=`
35
+ `;d+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0);":"transform: translate3d(0, 0, 0) rotateY(180deg);",this.hardInnerShadow.style.cssText=d}drawHardOuterShadow(){const s=this.getRect();let o=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*s.pageWidth)/100+20;o>s.pageWidth&&(o=s.pageWidth);let l=`
36
36
  display: block;
37
37
  z-index: ${(this.getSettings().startZIndex+4).toString(10)};
38
- width: ${n}px;
39
- height: ${i.height}px;
38
+ width: ${o}px;
39
+ height: ${s.height}px;
40
40
  background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
41
- left: ${i.left+i.width/2}px;
41
+ left: ${s.left+s.width/2}px;
42
42
  transform-origin: 0 0;
43
- `;a+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);",this.hardShadow.style.cssText=a}drawInnerShadow(){const i=this.getRect(),n=3*this.shadow.width/4,a=this.getDirection()===0?n:0,l=this.getDirection()===0?"to left":"to right",d=this.convertToGlobal(this.shadow.pos),p=this.shadow.angle+3*Math.PI/2,y=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let f="polygon( ";for(const z of y){let H=this.getDirection()===1?{x:-z.x+this.shadow.pos.x,y:z.y-this.shadow.pos.y}:{x:z.x-this.shadow.pos.x,y:z.y-this.shadow.pos.y};H=c.GetRotatedPoint(H,{x:a,y:100},p),f+=H.x+"px "+H.y+"px, "}f=f.slice(0,-2),f+=")";const R=`
43
+ `;l+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);",this.hardShadow.style.cssText=l}drawInnerShadow(){const s=this.getRect(),o=3*this.shadow.width/4,l=this.getDirection()===0?o:0,d=this.getDirection()===0?"to left":"to right",g=this.convertToGlobal(this.shadow.pos),f=this.shadow.angle+3*Math.PI/2,S=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let C="polygon( ";for(const F of S){let B=this.getDirection()===1?{x:-F.x+this.shadow.pos.x,y:F.y-this.shadow.pos.y}:{x:F.x-this.shadow.pos.x,y:F.y-this.shadow.pos.y};B=u.GetRotatedPoint(B,{x:l,y:100},f),C+=B.x+"px "+B.y+"px, "}C=C.slice(0,-2),C+=")";const D=`
44
44
  display: block;
45
45
  z-index: ${(this.getSettings().startZIndex+10).toString(10)};
46
- width: ${n}px;
47
- height: ${2*i.height}px;
48
- background: linear-gradient(${l},
46
+ width: ${o}px;
47
+ height: ${2*s.height}px;
48
+ background: linear-gradient(${d},
49
49
  rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
50
50
  rgba(0, 0, 0, 0.05) 15%,
51
51
  rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
52
52
  rgba(0, 0, 0, 0) 100%);
53
- transform-origin: ${a}px 100px;
54
- transform: translate3d(${d.x-a}px, ${d.y-100}px, 0) rotate(${p}rad);
55
- clip-path: ${f};
56
- -webkit-clip-path: ${f};
57
- `;this.innerShadow.style.cssText=R}drawOuterShadow(){const i=this.getRect(),n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),a=this.shadow.angle+3*Math.PI/2,l=this.getDirection()===1?this.shadow.width:0,d=this.getDirection()===0?"to right":"to left",p=[{x:0,y:0},{x:i.pageWidth,y:0},{x:i.pageWidth,y:i.height},{x:0,y:i.height}];let y="polygon( ";for(const R of p)if(R!==null){let z=this.getDirection()===1?{x:-R.x+this.shadow.pos.x,y:R.y-this.shadow.pos.y}:{x:R.x-this.shadow.pos.x,y:R.y-this.shadow.pos.y};z=c.GetRotatedPoint(z,{x:l,y:100},a),y+=z.x+"px "+z.y+"px, "}y=y.slice(0,-2),y+=")";const f=`
53
+ transform-origin: ${l}px 100px;
54
+ transform: translate3d(${g.x-l}px, ${g.y-100}px, 0) rotate(${f}rad);
55
+ clip-path: ${C};
56
+ -webkit-clip-path: ${C};
57
+ `;this.innerShadow.style.cssText=D}drawOuterShadow(){const s=this.getRect(),o=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),l=this.shadow.angle+3*Math.PI/2,d=this.getDirection()===1?this.shadow.width:0,g=this.getDirection()===0?"to right":"to left",f=[{x:0,y:0},{x:s.pageWidth,y:0},{x:s.pageWidth,y:s.height},{x:0,y:s.height}];let S="polygon( ";for(const D of f)if(D!==null){let F=this.getDirection()===1?{x:-D.x+this.shadow.pos.x,y:D.y-this.shadow.pos.y}:{x:D.x-this.shadow.pos.x,y:D.y-this.shadow.pos.y};F=u.GetRotatedPoint(F,{x:d,y:100},l),S+=F.x+"px "+F.y+"px, "}S=S.slice(0,-2),S+=")";const C=`
58
58
  display: block;
59
59
  z-index: ${(this.getSettings().startZIndex+10).toString(10)};
60
60
  width: ${this.shadow.width}px;
61
- height: ${2*i.height}px;
62
- background: linear-gradient(${d}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
63
- transform-origin: ${l}px 100px;
64
- transform: translate3d(${n.x-l}px, ${n.y-100}px, 0) rotate(${a}rad);
65
- clip-path: ${y};
66
- -webkit-clip-path: ${y};
67
- `;this.outerShadow.style.cssText=f}drawLeftPage(){this.orientation!=="portrait"&&this.leftPage!==null&&(this.direction===1&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.leftPage.draw(this.flippingPage.getDrawingDensity())):this.leftPage.simpleDraw(0))}drawRightPage(){this.rightPage!==null&&(this.direction===0&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.rightPage.draw(this.flippingPage.getDrawingDensity())):this.rightPage.simpleDraw(1))}drawBottomPage(){if(this.bottomPage===null)return;const i=this.flippingPage!=null?this.flippingPage.getDrawingDensity():null;this.orientation==="portrait"&&this.direction===1||(this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10),this.bottomPage.draw(i))}drawFrame(){this.clear(),this.drawLeftPage(),this.drawRightPage(),this.drawBottomPage(),this.flippingPage!=null&&(this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.flippingPage.draw()),this.shadow!=null&&this.flippingPage!==null&&(this.flippingPage.getDrawingDensity()==="soft"?(this.drawOuterShadow(),this.drawInnerShadow()):(this.drawHardOuterShadow(),this.drawHardInnerShadow()))}clear(){for(const i of this.app.getPageCollection().getPages())i!==this.leftPage&&i!==this.rightPage&&i!==this.flippingPage&&i!==this.bottomPage&&(i.getElement().style.cssText="display: none"),i.getTemporaryCopy()!==this.flippingPage&&i.hideTemporaryCopy()}update(){super.update(),this.rightPage!==null&&this.rightPage.setOrientation(1),this.leftPage!==null&&this.leftPage.setOrientation(0)}}class G{constructor(){this._default={startPage:0,size:"fixed",width:0,height:0,minWidth:0,maxWidth:0,minHeight:0,maxHeight:0,drawShadow:!0,flippingTime:1e3,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:1,showCover:!1,mobileScrollSupport:!0,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,showPageCorners:!0,disableFlipByClick:!1}}getSettings(i){const n=this._default;if(Object.assign(n,i),n.size!=="stretch"&&n.size!=="fixed")throw new Error('Invalid size type. Available only "fixed" and "stretch" value');if(n.width<=0||n.height<=0)throw new Error("Invalid width or height");if(n.flippingTime<=0)throw new Error("Invalid flipping time");return n.size==="stretch"?(n.minWidth<=0&&(n.minWidth=100),n.maxWidth<n.minWidth&&(n.maxWidth=2e3),n.minHeight<=0&&(n.minHeight=100),n.maxHeight<n.minHeight&&(n.maxHeight=2e3)):(n.minWidth=n.width,n.maxWidth=n.width,n.minHeight=n.height,n.maxHeight=n.height),n}}(function(m,i){i===void 0&&(i={});var n=i.insertAt;if(typeof document<"u"){var a=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css",n==="top"&&a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l),l.styleSheet?l.styleSheet.cssText=m:l.appendChild(document.createTextNode(m))}})(`.stf__parent {
61
+ height: ${2*s.height}px;
62
+ background: linear-gradient(${g}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
63
+ transform-origin: ${d}px 100px;
64
+ transform: translate3d(${o.x-d}px, ${o.y-100}px, 0) rotate(${l}rad);
65
+ clip-path: ${S};
66
+ -webkit-clip-path: ${S};
67
+ `;this.outerShadow.style.cssText=C}drawLeftPage(){this.orientation!=="portrait"&&this.leftPage!==null&&(this.direction===1&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.leftPage.draw(this.flippingPage.getDrawingDensity())):this.leftPage.simpleDraw(0))}drawRightPage(){this.rightPage!==null&&(this.direction===0&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.rightPage.draw(this.flippingPage.getDrawingDensity())):this.rightPage.simpleDraw(1))}drawBottomPage(){if(this.bottomPage===null)return;const s=this.flippingPage!=null?this.flippingPage.getDrawingDensity():null;this.orientation==="portrait"&&this.direction===1||(this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10),this.bottomPage.draw(s))}drawFrame(){this.clear(),this.drawLeftPage(),this.drawRightPage(),this.drawBottomPage(),this.flippingPage!=null&&(this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.flippingPage.draw()),this.shadow!=null&&this.flippingPage!==null&&(this.flippingPage.getDrawingDensity()==="soft"?(this.drawOuterShadow(),this.drawInnerShadow()):(this.drawHardOuterShadow(),this.drawHardInnerShadow()))}clear(){for(const s of this.app.getPageCollection().getPages())s!==this.leftPage&&s!==this.rightPage&&s!==this.flippingPage&&s!==this.bottomPage&&(s.getElement().style.cssText="display: none"),s.getTemporaryCopy()!==this.flippingPage&&s.hideTemporaryCopy()}update(){super.update(),this.rightPage!==null&&this.rightPage.setOrientation(1),this.leftPage!==null&&this.leftPage.setOrientation(0)}}class q{constructor(){this._default={startPage:0,size:"fixed",width:0,height:0,minWidth:0,maxWidth:0,minHeight:0,maxHeight:0,drawShadow:!0,flippingTime:1e3,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:1,showCover:!1,mobileScrollSupport:!0,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,showPageCorners:!0,disableFlipByClick:!1}}getSettings(s){const o=this._default;if(Object.assign(o,s),o.size!=="stretch"&&o.size!=="fixed")throw new Error('Invalid size type. Available only "fixed" and "stretch" value');if(o.width<=0||o.height<=0)throw new Error("Invalid width or height");if(o.flippingTime<=0)throw new Error("Invalid flipping time");return o.size==="stretch"?(o.minWidth<=0&&(o.minWidth=100),o.maxWidth<o.minWidth&&(o.maxWidth=2e3),o.minHeight<=0&&(o.minHeight=100),o.maxHeight<o.minHeight&&(o.maxHeight=2e3)):(o.minWidth=o.width,o.maxWidth=o.width,o.minHeight=o.height,o.maxHeight=o.height),o}}(function(v,s){s===void 0&&(s={});var o=s.insertAt;if(typeof document<"u"){var l=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.type="text/css",o==="top"&&l.firstChild?l.insertBefore(d,l.firstChild):l.appendChild(d),d.styleSheet?d.styleSheet.cssText=v:d.appendChild(document.createTextNode(v))}})(`.stf__parent {
68
68
  position: relative;
69
69
  display: block;
70
70
  box-sizing: border-box;
@@ -124,8 +124,8 @@ var FlipbookEngine=function(x,E){"use strict";var Ei=Object.defineProperty;var D
124
124
  position: absolute;
125
125
  left: 0;
126
126
  top: 0;
127
- }`),s.PageFlip=class extends class{constructor(){this.events=new Map}on(m,i){return this.events.has(m)?this.events.get(m).push(i):this.events.set(m,[i]),this}off(m){this.events.delete(m)}trigger(m,i,n=null){if(this.events.has(m))for(const a of this.events.get(m))a({data:n,object:i})}}{constructor(m,i){super(),this.isUserTouch=!1,this.isUserMove=!1,this.setting=null,this.pages=null,this.setting=new G().getSettings(i),this.block=m}destroy(){this.ui.destroy(),this.block.remove()}update(){this.render.update(),this.pages.show()}loadFromImages(m){this.ui=new Q(this.block,this,this.setting);const i=this.ui.getCanvas();this.render=new T(this,this.setting,i),this.flipController=new F(this.render,this),this.pages=new u(this,this.render,m),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}loadFromHTML(m){this.ui=new W(this.block,this,this.setting,m),this.render=new _(this,this.setting,this.ui.getDistElement()),this.flipController=new F(this.render,this),this.pages=new P(this,this.render,this.ui.getDistElement(),m),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}updateFromImages(m){const i=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new u(this,this.render,m),this.pages.load(),this.pages.show(i),this.trigger("update",this,{page:i,mode:this.render.getOrientation()})}updateFromHtml(m){const i=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new P(this,this.render,this.ui.getDistElement(),m),this.pages.load(),this.ui.updateItems(m),this.render.reload(),this.pages.show(i),this.trigger("update",this,{page:i,mode:this.render.getOrientation()})}clear(){this.pages.destroy(),this.ui.clear()}turnToPrevPage(){this.pages.showPrev()}turnToNextPage(){this.pages.showNext()}turnToPage(m){this.pages.show(m)}flipNext(m="top"){this.flipController.flipNext(m)}flipPrev(m="top"){this.flipController.flipPrev(m)}flip(m,i="top"){this.flipController.flipToPage(m,i)}updateState(m){this.trigger("changeState",this,m)}updatePageIndex(m){this.trigger("flip",this,m)}updateOrientation(m){this.ui.setOrientationStyle(m),this.update(),this.trigger("changeOrientation",this,m)}getPageCount(){return this.pages.getPageCount()}getCurrentPageIndex(){return this.pages.getCurrentPageIndex()}getPage(m){return this.pages.getPage(m)}getRender(){return this.render}getFlipController(){return this.flipController}getOrientation(){return this.render.getOrientation()}getBoundsRect(){return this.render.getRect()}getSettings(){return this.setting}getUI(){return this.ui}getState(){return this.flipController.getState()}getPageCollection(){return this.pages}startUserTouch(m){this.mousePosition=m,this.isUserTouch=!0,this.isUserMove=!1}userMove(m,i){this.isUserTouch||i||!this.setting.showPageCorners?this.isUserTouch&&c.GetDistanceBetweenTwoPoint(this.mousePosition,m)>5&&(this.isUserMove=!0,this.flipController.fold(m)):this.flipController.showCorner(m)}userStop(m,i=!1){this.isUserTouch&&(this.isUserTouch=!1,i||(this.isUserMove?this.flipController.stopMove():this.flipController.flip(m)))}},Object.defineProperty(s,"__esModule",{value:!0})})})(Ht,Ht.exports);var wi=Ht.exports;/**
128
- * @license FlipbookEngine v0.6.5
127
+ }`),i.PageFlip=class extends class{constructor(){this.events=new Map}on(v,s){return this.events.has(v)?this.events.get(v).push(s):this.events.set(v,[s]),this}off(v){this.events.delete(v)}trigger(v,s,o=null){if(this.events.has(v))for(const l of this.events.get(v))l({data:o,object:s})}}{constructor(v,s){super(),this.isUserTouch=!1,this.isUserMove=!1,this.setting=null,this.pages=null,this.setting=new q().getSettings(s),this.block=v}destroy(){this.ui.destroy(),this.block.remove()}update(){this.render.update(),this.pages.show()}loadFromImages(v){this.ui=new U(this.block,this,this.setting);const s=this.ui.getCanvas();this.render=new m(this,this.setting,s),this.flipController=new z(this.render,this),this.pages=new h(this,this.render,v),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}loadFromHTML(v){this.ui=new A(this.block,this,this.setting,v),this.render=new W(this,this.setting,this.ui.getDistElement()),this.flipController=new z(this.render,this),this.pages=new x(this,this.render,this.ui.getDistElement(),v),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}updateFromImages(v){const s=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new h(this,this.render,v),this.pages.load(),this.pages.show(s),this.trigger("update",this,{page:s,mode:this.render.getOrientation()})}updateFromHtml(v){const s=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new x(this,this.render,this.ui.getDistElement(),v),this.pages.load(),this.ui.updateItems(v),this.render.reload(),this.pages.show(s),this.trigger("update",this,{page:s,mode:this.render.getOrientation()})}clear(){this.pages.destroy(),this.ui.clear()}turnToPrevPage(){this.pages.showPrev()}turnToNextPage(){this.pages.showNext()}turnToPage(v){this.pages.show(v)}flipNext(v="top"){this.flipController.flipNext(v)}flipPrev(v="top"){this.flipController.flipPrev(v)}flip(v,s="top"){this.flipController.flipToPage(v,s)}updateState(v){this.trigger("changeState",this,v)}updatePageIndex(v){this.trigger("flip",this,v)}updateOrientation(v){this.ui.setOrientationStyle(v),this.update(),this.trigger("changeOrientation",this,v)}getPageCount(){return this.pages.getPageCount()}getCurrentPageIndex(){return this.pages.getCurrentPageIndex()}getPage(v){return this.pages.getPage(v)}getRender(){return this.render}getFlipController(){return this.flipController}getOrientation(){return this.render.getOrientation()}getBoundsRect(){return this.render.getRect()}getSettings(){return this.setting}getUI(){return this.ui}getState(){return this.flipController.getState()}getPageCollection(){return this.pages}startUserTouch(v){this.mousePosition=v,this.isUserTouch=!0,this.isUserMove=!1}userMove(v,s){this.isUserTouch||s||!this.setting.showPageCorners?this.isUserTouch&&u.GetDistanceBetweenTwoPoint(this.mousePosition,v)>5&&(this.isUserMove=!0,this.flipController.fold(v)):this.flipController.showCorner(v)}userStop(v,s=!1){this.isUserTouch&&(this.isUserTouch=!1,s||(this.isUserMove?this.flipController.stopMove():this.flipController.flip(v)))}},Object.defineProperty(i,"__esModule",{value:!0})})})(Xe,Xe.exports);var Gi=Xe.exports;/**
128
+ * @license FlipbookEngine v1.0.0
129
129
  * Copyright (c) 2026 Murat Dogan
130
130
  *
131
131
  * This source code is dual-licensed under the AGPLv3 and a Commercial License.
@@ -137,8 +137,8 @@ var FlipbookEngine=function(x,E){"use strict";var Ei=Object.defineProperty;var D
137
137
  * closed-source, or SaaS products without the AGPLv3 obligations,
138
138
  * you must purchase a Commercial License from:
139
139
  * https://flipbookengine.com/pricing
140
- */function vi(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function yi(e,t=vi()){return t?0:typeof e=="number"&&e>=0?e:1e3}class bi{constructor(t,s,o){v(this,"pageFlip",null);v(this,"bookContainer");v(this,"options");v(this,"store");v(this,"unsubs",[]);v(this,"audioEl",null);v(this,"audioUnlockHandler",null);v(this,"isLibraryFlipping",!1);v(this,"autoPlayTimer",null);v(this,"layoutUpdateTimer",null);this.bookContainer=t,this.options=s,this.store=o,s.soundUrl&&(this.audioEl=new Audio(s.soundUrl),this.unlockAudio())}unlockAudio(){if(!this.audioEl)return;const t=()=>{if(this.audioEl){const s=this.audioEl.play();s&&typeof s.then=="function"&&s.then(()=>{this.audioEl.pause(),this.audioEl.currentTime=0}).catch(()=>{})}document.removeEventListener("touchstart",t),document.removeEventListener("click",t),this.audioUnlockHandler=null};this.audioUnlockHandler=t,document.addEventListener("touchstart",t,{once:!0}),document.addEventListener("click",t,{once:!0})}init(t,s){this.pageFlip=new wi.PageFlip(this.bookContainer,{width:t,height:s,size:"stretch",minWidth:100,maxWidth:3e3,minHeight:100,maxHeight:3e3,drawShadow:!0,showCover:!0,usePortrait:!0,mobileScrollSupport:!0,maxShadowOpacity:this.options.maxShadowOpacity||.5,flippingTime:yi(this.options.flippingTime)});const o=this.bookContainer.querySelectorAll(".bz-page");this.pageFlip.loadFromHTML(Array.from(o)),this.bindEvents(),this.setupSignalSync()}bindEvents(){this.pageFlip.on("flip",t=>{this.store.currentPage.value!==t.data&&(this.isLibraryFlipping=!0,this.store.currentPage.value=t.data,this.playSound(),this.isLibraryFlipping=!1)}),this.pageFlip.on("changeState",t=>{this.store.flipState.value=t.data}),this.pageFlip.on("changeOrientation",t=>{this.store.orientation.value!==t.data&&(this.store.orientation.value=t.data)})}setupSignalSync(){this.unsubs.push(U(()=>{const t=this.store.currentPage.value,s=this.store.flipState.peek();if(!this.pageFlip||this.isLibraryFlipping||s!=="read")return;const o=this.pageFlip.getCurrentPageIndex();if(o!==t&&!this.store.isSingleMode.value){const r=c=>c===0?0:Math.ceil(c/2),h=r(t),u=r(o);h===u+1?this.pageFlip.flipNext():h===u-1?this.pageFlip.flipPrev():h!==u&&this.pageFlip.turnToPage(t)}})),this.unsubs.push(U(()=>{this.store.isSingleMode.value,this.pageFlip&&(this.layoutUpdateTimer&&clearTimeout(this.layoutUpdateTimer),this.layoutUpdateTimer=setTimeout(()=>{this.layoutUpdateTimer=null,this.pageFlip&&this.pageFlip.update(),window.dispatchEvent(new Event("resize"))},50))})),this.unsubs.push(U(()=>{const t=this.store.isAutoPlaying.value,s=this.store.autoPlayInterval.value||3e3;this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),t&&(this.autoPlayTimer=setInterval(()=>{const o=this.store.pages.value.length-1;if(this.store.currentPage.peek()>=o||this.store.currentPage.peek()>=o-1&&!this.store.isSingleMode.peek()){this.store.isAutoPlaying.value=!1;return}this.turnToNextPage()},s))}))}turnToNextPage(){if(this.store.isSingleMode.value){const t=this.store.currentPage.value+1;t<this.store.pages.value.length&&(this.store.currentPage.value=t,this.playSound())}else this.pageFlip&&this.pageFlip.flipNext()}turnToPrevPage(){if(this.store.isSingleMode.value){const t=this.store.currentPage.value-1;t>=0&&(this.store.currentPage.value=t,this.playSound())}else this.pageFlip&&this.pageFlip.flipPrev()}playSound(){if(this.store.soundEnabled.value&&this.audioEl){this.audioEl.currentTime=0;const t=this.audioEl.play();t&&typeof t.catch=="function"&&t.catch(s=>console.warn("Flipbook Audio Play Error:",s))}}update(){this.pageFlip&&this.pageFlip.update(),this.layoutUpdateTimer&&(clearTimeout(this.layoutUpdateTimer),this.layoutUpdateTimer=null)}destroy(){this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),this.audioUnlockHandler&&(document.removeEventListener("touchstart",this.audioUnlockHandler),document.removeEventListener("click",this.audioUnlockHandler),this.audioUnlockHandler=null),this.unsubs.forEach(t=>t()),this.unsubs=[],this.pageFlip&&(this.pageFlip.destroy(),this.pageFlip=null)}}/**
141
- * @license FlipbookEngine v0.6.5
140
+ */function ji(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function qi(t,e=ji()){return e?0:typeof t=="number"&&t>=0?t:1e3}class Vi{constructor(e,i,n){b(this,"pageFlip",null);b(this,"bookContainer");b(this,"options");b(this,"store");b(this,"unsubs",[]);b(this,"audioEl",null);b(this,"audioUnlockHandler",null);b(this,"isLibraryFlipping",!1);b(this,"autoPlayTimer",null);b(this,"layoutUpdateTimer",null);this.bookContainer=e,this.options=i,this.store=n,i.soundUrl&&(this.audioEl=new Audio(i.soundUrl),this.unlockAudio())}unlockAudio(){if(!this.audioEl)return;const e=()=>{if(this.audioEl){const i=this.audioEl.play();i&&typeof i.then=="function"&&i.then(()=>{this.audioEl.pause(),this.audioEl.currentTime=0}).catch(()=>{})}document.removeEventListener("touchstart",e),document.removeEventListener("click",e),this.audioUnlockHandler=null};this.audioUnlockHandler=e,document.addEventListener("touchstart",e,{once:!0}),document.addEventListener("click",e,{once:!0})}init(e,i){this.pageFlip=new Gi.PageFlip(this.bookContainer,{width:e,height:i,size:"stretch",minWidth:100,maxWidth:3e3,minHeight:100,maxHeight:3e3,drawShadow:!0,showCover:!0,usePortrait:!0,mobileScrollSupport:!0,maxShadowOpacity:this.options.maxShadowOpacity||.5,flippingTime:qi(this.options.flippingTime)});const n=this.bookContainer.querySelectorAll(".bz-page");this.pageFlip.loadFromHTML(Array.from(n)),this.bindEvents(),this.setupSignalSync()}bindEvents(){this.pageFlip.on("flip",e=>{this.store.currentPage.value!==e.data&&(this.isLibraryFlipping=!0,this.store.currentPage.value=e.data,this.playSound(),this.isLibraryFlipping=!1)}),this.pageFlip.on("changeState",e=>{this.store.flipState.value=e.data}),this.pageFlip.on("changeOrientation",e=>{this.store.orientation.value!==e.data&&(this.store.orientation.value=e.data)})}setupSignalSync(){this.unsubs.push(X(()=>{const e=this.store.currentPage.value,i=this.store.flipState.peek();if(!this.pageFlip||this.isLibraryFlipping||i!=="read")return;const n=this.pageFlip.getCurrentPageIndex();if(n!==e&&!this.store.isSingleMode.value){const r=u=>u===0?0:Math.ceil(u/2),a=r(e),h=r(n);a===h+1?this.pageFlip.flipNext():a===h-1?this.pageFlip.flipPrev():a!==h&&this.pageFlip.turnToPage(e)}})),this.unsubs.push(X(()=>{this.store.isSingleMode.value,this.pageFlip&&(this.layoutUpdateTimer&&clearTimeout(this.layoutUpdateTimer),this.layoutUpdateTimer=setTimeout(()=>{this.layoutUpdateTimer=null,this.pageFlip&&this.pageFlip.update(),window.dispatchEvent(new Event("resize"))},50))})),this.unsubs.push(X(()=>{const e=this.store.isAutoPlaying.value,i=this.store.autoPlayInterval.value||3e3;this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),e&&(this.autoPlayTimer=setInterval(()=>{const n=this.store.pages.value.length-1;if(this.store.currentPage.peek()>=n||this.store.currentPage.peek()>=n-1&&!this.store.isSingleMode.peek()){this.store.isAutoPlaying.value=!1;return}this.turnToNextPage()},i))}))}turnToNextPage(){if(this.store.isSingleMode.value){const e=this.store.currentPage.value+1;e<this.store.pages.value.length&&(this.store.currentPage.value=e,this.playSound())}else this.pageFlip&&this.pageFlip.flipNext()}turnToPrevPage(){if(this.store.isSingleMode.value){const e=this.store.currentPage.value-1;e>=0&&(this.store.currentPage.value=e,this.playSound())}else this.pageFlip&&this.pageFlip.flipPrev()}playSound(){if(this.store.soundEnabled.value&&this.audioEl){this.audioEl.currentTime=0;const e=this.audioEl.play();e&&typeof e.catch=="function"&&e.catch(i=>console.warn("Flipbook Audio Play Error:",i))}}update(){this.pageFlip&&this.pageFlip.update(),this.layoutUpdateTimer&&(clearTimeout(this.layoutUpdateTimer),this.layoutUpdateTimer=null)}destroy(){this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),this.audioUnlockHandler&&(document.removeEventListener("touchstart",this.audioUnlockHandler),document.removeEventListener("click",this.audioUnlockHandler),this.audioUnlockHandler=null),this.unsubs.forEach(e=>e()),this.unsubs=[],this.pageFlip&&(this.pageFlip.destroy(),this.pageFlip=null)}}/**
141
+ * @license FlipbookEngine v1.0.0
142
142
  * Copyright (c) 2026 Murat Dogan
143
143
  *
144
144
  * This source code is dual-licensed under the AGPLv3 and a Commercial License.
@@ -150,8 +150,8 @@ var FlipbookEngine=function(x,E){"use strict";var Ei=Object.defineProperty;var D
150
150
  * closed-source, or SaaS products without the AGPLv3 obligations,
151
151
  * you must purchase a Commercial License from:
152
152
  * https://flipbookengine.com/pricing
153
- */class Pi{constructor(t,s){v(this,"wrapperElement",null);v(this,"sizerElement",null);v(this,"pageViewport");v(this,"store");v(this,"resizeObserver",null);v(this,"orientationMediaQuery",null);v(this,"orientationChangeHandler",null);v(this,"unsubs",[]);v(this,"updateTimer",null);v(this,"onResizeCallback");this.pageViewport=t,this.store=s}init(t,s){this.wrapperElement=t,this.sizerElement=s,this.setupResizeObserver(),this.setupOrientationMedia(),this.setupStateSync(),this.updateBookAspectRatio()}setupStateSync(){this.unsubs.push(U(()=>{this.store.isSingleMode.value,this.store.orientation.value,this.scheduleAspectRatioUpdate()}))}setupResizeObserver(){typeof ResizeObserver<"u"&&this.wrapperElement&&(this.resizeObserver=new ResizeObserver(()=>{this.updateBookAspectRatio()}),this.resizeObserver.observe(this.wrapperElement))}setupOrientationMedia(){if(typeof window<"u"&&window.matchMedia){this.orientationMediaQuery=window.matchMedia("(orientation: portrait)");const t=s=>{s.matches,this.updateBookAspectRatio()};this.orientationChangeHandler=t,this.orientationMediaQuery.addEventListener?this.orientationMediaQuery.addEventListener("change",t):this.orientationMediaQuery.addListener(t),t(this.orientationMediaQuery)}}updateBookAspectRatio(){if(!this.wrapperElement||!this.sizerElement)return;const t=this.wrapperElement.clientWidth,s=this.wrapperElement.clientHeight;if(t===0||s===0)return;const o=this.pageViewport.width,r=this.pageViewport.height,u=this.store.isDoublePageLayout.value?o*2/r:o/r;let c=t,b=t/u;b>s&&(b=s,c=s*u);let P=Math.ceil(c);P%2!==0&&(P+=1),this.sizerElement.style.width=`${P}px`,this.sizerElement.style.height=`${Math.floor(b)}px`,this.sizerElement.style.aspectRatio="",this.onResizeCallback&&this.onResizeCallback()}destroy(){this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null),this.unsubs.forEach(t=>t()),this.unsubs=[],this.resizeObserver&&this.wrapperElement&&(this.resizeObserver.unobserve(this.wrapperElement),this.resizeObserver.disconnect(),this.resizeObserver=null),this.orientationMediaQuery&&(this.orientationChangeHandler&&(this.orientationMediaQuery.removeEventListener?this.orientationMediaQuery.removeEventListener("change",this.orientationChangeHandler):this.orientationMediaQuery.removeListener(this.orientationChangeHandler)),this.orientationChangeHandler=null,this.orientationMediaQuery=null)}scheduleAspectRatioUpdate(){this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateTimer=null,this.updateBookAspectRatio()},10)}}/**
154
- * @license FlipbookEngine v0.6.5
153
+ */class Zi{constructor(e,i){b(this,"wrapperElement",null);b(this,"sizerElement",null);b(this,"pageViewport");b(this,"store");b(this,"resizeObserver",null);b(this,"orientationMediaQuery",null);b(this,"orientationChangeHandler",null);b(this,"unsubs",[]);b(this,"updateTimer",null);b(this,"onResizeCallback");this.pageViewport=e,this.store=i}init(e,i){this.wrapperElement=e,this.sizerElement=i,this.setupResizeObserver(),this.setupOrientationMedia(),this.setupStateSync(),this.updateBookAspectRatio()}setupStateSync(){this.unsubs.push(X(()=>{this.store.isSingleMode.value,this.store.orientation.value,this.scheduleAspectRatioUpdate()}))}setupResizeObserver(){typeof ResizeObserver<"u"&&this.wrapperElement&&(this.resizeObserver=new ResizeObserver(()=>{this.updateBookAspectRatio()}),this.resizeObserver.observe(this.wrapperElement))}setupOrientationMedia(){if(typeof window<"u"&&window.matchMedia){this.orientationMediaQuery=window.matchMedia("(orientation: portrait)");const e=i=>{i.matches,this.updateBookAspectRatio()};this.orientationChangeHandler=e,this.orientationMediaQuery.addEventListener?this.orientationMediaQuery.addEventListener("change",e):this.orientationMediaQuery.addListener(e),e(this.orientationMediaQuery)}}updateBookAspectRatio(){if(!this.wrapperElement||!this.sizerElement)return;const e=this.wrapperElement.clientWidth,i=this.wrapperElement.clientHeight;if(e===0||i===0)return;const n=this.pageViewport.width,r=this.pageViewport.height,h=this.store.isDoublePageLayout.value?n*2/r:n/r;let u=e,w=e/h;w>i&&(w=i,u=i*h);let x=Math.ceil(u);x%2!==0&&(x+=1),this.sizerElement.style.width=`${x}px`,this.sizerElement.style.height=`${Math.floor(w)}px`,this.sizerElement.style.aspectRatio="",this.onResizeCallback&&this.onResizeCallback()}destroy(){this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null),this.unsubs.forEach(e=>e()),this.unsubs=[],this.resizeObserver&&this.wrapperElement&&(this.resizeObserver.unobserve(this.wrapperElement),this.resizeObserver.disconnect(),this.resizeObserver=null),this.orientationMediaQuery&&(this.orientationChangeHandler&&(this.orientationMediaQuery.removeEventListener?this.orientationMediaQuery.removeEventListener("change",this.orientationChangeHandler):this.orientationMediaQuery.removeListener(this.orientationChangeHandler)),this.orientationChangeHandler=null,this.orientationMediaQuery=null)}scheduleAspectRatioUpdate(){this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateTimer=null,this.updateBookAspectRatio()},10)}}/**
154
+ * @license FlipbookEngine v1.0.0
155
155
  * Copyright (c) 2026 Murat Dogan
156
156
  *
157
157
  * This source code is dual-licensed under the AGPLv3 and a Commercial License.
@@ -163,13 +163,22 @@ var FlipbookEngine=function(x,E){"use strict";var Ei=Object.defineProperty;var D
163
163
  * closed-source, or SaaS products without the AGPLv3 obligations,
164
164
  * you must purchase a Commercial License from:
165
165
  * https://flipbookengine.com/pricing
166
- */class xi{constructor(t,s,o){v(this,"container");v(this,"pageFlipAdapter");v(this,"store");v(this,"touchStartX",null);v(this,"unsubs",[]);v(this,"listenerAbortController");var h;this.container=t,this.pageFlipAdapter=s,this.store=o;const r=((h=t.ownerDocument.defaultView)==null?void 0:h.AbortController)??globalThis.AbortController;this.listenerAbortController=new r}init(){this.bindWheel(),this.bindMouseDrag(),this.bindTouch(),this.setupStateSync()}setupStateSync(){this.unsubs.push(U(()=>{this.store.isZoomed.value=this.store.zoomState.value.isActive,this.store.zoomState.value.isActive?(this.container.style.transform=`translate(${this.store.zoomState.value.translateX}px, ${this.store.zoomState.value.translateY}px) scale(${this.store.zoomState.value.scale})`,this.container.style.transition="none"):(this.container.style.transform="",this.container.style.transition="transform 0.3s ease")}))}bindWheel(){this.container.addEventListener("wheel",t=>{this.store.zoomState.value.isActive&&(t.preventDefault(),this.updateZoomPan(this.store.zoomState.value.translateX-t.deltaX,this.store.zoomState.value.translateY-t.deltaY))},{passive:!1,signal:this.listenerAbortController.signal})}bindMouseDrag(){let t=!1,s=0,o=0,r=0,h=0;this.container.addEventListener("mousedown",u=>{this.store.zoomState.value.isActive&&(t=!0,s=u.clientX,o=u.clientY,r=this.store.zoomState.value.translateX,h=this.store.zoomState.value.translateY,this.container.style.cursor="grabbing")},{signal:this.listenerAbortController.signal}),window.addEventListener("mousemove",u=>{if(!t||!this.store.zoomState.value.isActive)return;const c=u.clientX-s,b=u.clientY-o;this.updateZoomPan(r+c,h+b)},{signal:this.listenerAbortController.signal}),window.addEventListener("mouseup",()=>{t&&(t=!1,this.container.style.cursor=this.store.zoomState.value.isActive?"grab":"")},{signal:this.listenerAbortController.signal})}bindTouch(){let t=!1,s=0,o=0;this.container.addEventListener("touchstart",r=>{if(r.touches.length===1)if(!this.store.zoomState.value.isActive)this.touchStartX=r.touches[0].clientX;else{t=!0,this.touchStartX=r.touches[0].clientX;const h=r.touches[0].clientY;s=this.store.zoomState.value.translateX,o=this.store.zoomState.value.translateY,this.container._touchStartY=h}},{passive:!0,signal:this.listenerAbortController.signal}),this.container.addEventListener("touchmove",r=>{if(t&&this.store.zoomState.value.isActive&&r.touches.length===1&&this.touchStartX!==null){r.preventDefault();const h=r.touches[0].clientX-this.touchStartX,u=r.touches[0].clientY-this.container._touchStartY;this.updateZoomPan(s+h,o+u)}},{passive:!1,signal:this.listenerAbortController.signal}),this.container.addEventListener("touchend",r=>{if(this.touchStartX!==null&&!this.store.zoomState.value.isActive&&this.store.isSingleMode.value&&r.changedTouches.length===1){const h=r.changedTouches[0].clientX-this.touchStartX;h>50&&this.store.currentPage.value>0?this.pageFlipAdapter.turnToPrevPage():h<-50&&this.store.currentPage.value<this.store.totalPages.value-1&&this.pageFlipAdapter.turnToNextPage()}this.touchStartX=null,t=!1},{passive:!0,signal:this.listenerAbortController.signal})}zoomIn(){let t=this.store.zoomState.value.scale+.5;t>5&&(t=5),this.store.zoomState.value={...this.store.zoomState.value,isActive:t>1,scale:t},t>1&&(this.container.style.cursor="grab")}zoomOut(){let t=this.store.zoomState.value.scale-.5;t<=1?(t=1,this.store.zoomState.value={...this.store.zoomState.value,isActive:!1,translateX:0,translateY:0,scale:1},this.container.style.cursor=""):this.store.zoomState.value={...this.store.zoomState.value,isActive:!0,scale:t}}updateZoomPan(t,s){this.store.zoomState.value={...this.store.zoomState.value,translateX:t,translateY:s}}destroy(){this.listenerAbortController.abort(),this.unsubs.forEach(t=>t()),this.unsubs=[]}}function be(e,t,s){if(!e||typeof e.title!="string"||!e.title.trim()||!Number.isFinite(e.pageIndex))return null;const o=Math.max(0,t-1),r=Array.isArray(e.children)?e.children.map((h,u)=>be(h,t,s+"-"+u)).filter(h=>h!==null):[];return{id:e.id??s,title:e.title.trim(),pageIndex:Math.max(0,Math.min(o,Math.trunc(e.pageIndex))),...r.length?{children:r}:{}}}function Bt(e,t){return Array.isArray(e)?e.map((s,o)=>be(s,t,"toc-"+o)).filter(s=>s!==null):[]}/**
167
- * @license FlipbookEngine v0.6.5
166
+ */class Xi{constructor(e,i,n){b(this,"container");b(this,"pageFlipAdapter");b(this,"store");b(this,"touchStartX",null);b(this,"unsubs",[]);b(this,"listenerAbortController");var a;this.container=e,this.pageFlipAdapter=i,this.store=n;const r=((a=e.ownerDocument.defaultView)==null?void 0:a.AbortController)??globalThis.AbortController;this.listenerAbortController=new r}init(){this.bindWheel(),this.bindMouseDrag(),this.bindTouch(),this.setupStateSync()}setupStateSync(){this.unsubs.push(X(()=>{this.store.isZoomed.value=this.store.zoomState.value.isActive,this.store.zoomState.value.isActive?(this.container.style.transform=`translate(${this.store.zoomState.value.translateX}px, ${this.store.zoomState.value.translateY}px) scale(${this.store.zoomState.value.scale})`,this.container.style.transition="none"):(this.container.style.transform="",this.container.style.transition="transform 0.3s ease")}))}bindWheel(){this.container.addEventListener("wheel",e=>{this.store.zoomState.value.isActive&&(e.preventDefault(),this.updateZoomPan(this.store.zoomState.value.translateX-e.deltaX,this.store.zoomState.value.translateY-e.deltaY))},{passive:!1,signal:this.listenerAbortController.signal})}bindMouseDrag(){let e=!1,i=0,n=0,r=0,a=0;this.container.addEventListener("mousedown",h=>{this.store.zoomState.value.isActive&&(e=!0,i=h.clientX,n=h.clientY,r=this.store.zoomState.value.translateX,a=this.store.zoomState.value.translateY,this.container.style.cursor="grabbing")},{signal:this.listenerAbortController.signal}),window.addEventListener("mousemove",h=>{if(!e||!this.store.zoomState.value.isActive)return;const u=h.clientX-i,w=h.clientY-n;this.updateZoomPan(r+u,a+w)},{signal:this.listenerAbortController.signal}),window.addEventListener("mouseup",()=>{e&&(e=!1,this.container.style.cursor=this.store.zoomState.value.isActive?"grab":"")},{signal:this.listenerAbortController.signal})}bindTouch(){let e=!1,i=0,n=0;this.container.addEventListener("touchstart",r=>{if(r.touches.length===1)if(!this.store.zoomState.value.isActive)this.touchStartX=r.touches[0].clientX;else{e=!0,this.touchStartX=r.touches[0].clientX;const a=r.touches[0].clientY;i=this.store.zoomState.value.translateX,n=this.store.zoomState.value.translateY,this.container._touchStartY=a}},{passive:!0,signal:this.listenerAbortController.signal}),this.container.addEventListener("touchmove",r=>{if(e&&this.store.zoomState.value.isActive&&r.touches.length===1&&this.touchStartX!==null){r.preventDefault();const a=r.touches[0].clientX-this.touchStartX,h=r.touches[0].clientY-this.container._touchStartY;this.updateZoomPan(i+a,n+h)}},{passive:!1,signal:this.listenerAbortController.signal}),this.container.addEventListener("touchend",r=>{if(this.touchStartX!==null&&!this.store.zoomState.value.isActive&&this.store.isSingleMode.value&&r.changedTouches.length===1){const a=r.changedTouches[0].clientX-this.touchStartX;a>50&&this.store.currentPage.value>0?this.pageFlipAdapter.turnToPrevPage():a<-50&&this.store.currentPage.value<this.store.totalPages.value-1&&this.pageFlipAdapter.turnToNextPage()}this.touchStartX=null,e=!1},{passive:!0,signal:this.listenerAbortController.signal})}zoomIn(){let e=this.store.zoomState.value.scale+.5;e>5&&(e=5),this.store.zoomState.value={...this.store.zoomState.value,isActive:e>1,scale:e},e>1&&(this.container.style.cursor="grab")}zoomOut(){let e=this.store.zoomState.value.scale-.5;e<=1?(e=1,this.store.zoomState.value={...this.store.zoomState.value,isActive:!1,translateX:0,translateY:0,scale:1},this.container.style.cursor=""):this.store.zoomState.value={...this.store.zoomState.value,isActive:!0,scale:e}}updateZoomPan(e,i){this.store.zoomState.value={...this.store.zoomState.value,translateX:e,translateY:i}}destroy(){this.listenerAbortController.abort(),this.unsubs.forEach(e=>e()),this.unsubs=[]}}function Dt(t,e,i){if(!t||typeof t.title!="string"||!t.title.trim()||!Number.isFinite(t.pageIndex))return null;const n=Math.max(0,e-1),r=Array.isArray(t.children)?t.children.map((a,h)=>Dt(a,e,i+"-"+h)).filter(a=>a!==null):[];return{id:t.id??i,title:t.title.trim(),pageIndex:Math.max(0,Math.min(n,Math.trunc(t.pageIndex))),...r.length?{children:r}:{}}}function Ae(t,e){return Array.isArray(t)?t.map((i,n)=>Dt(i,e,"toc-"+n)).filter(i=>i!==null):[]}/**
167
+ * @license FlipbookEngine v1.0.0
168
168
  * Copyright (c) 2026 Murat Dogan
169
169
  *
170
170
  * This source code is dual-licensed under the AGPLv3 and a Commercial License.
171
- */const Pe=()=>({isActive:!1,translateX:0,translateY:0,isDragging:!1,scale:1});function xe(){const e=I(0),t=I(0),s=I(!1),o=I(!1),r=I(!1),h=I(!0),u=I("landscape"),c=I("read"),b=I("auto"),P=I(!0),A=I(!1),F=I("#7367f0"),k=I(!1),T=I(!1),D=I(!1),W=I(3e3),Q=I(!0),_=I("en"),G=I({}),m=I(Pe()),i=I([]),n=I([]),a=w(()=>!s.value&&u.value==="landscape"),l=w(()=>a.value&&e.value===0),d=w(()=>a.value&&e.value>=t.value-1);return{currentPage:e,totalPages:t,isSingleMode:s,showThumbs:o,showToc:r,showArrows:h,orientation:u,flipState:c,themeMode:b,allowDownload:P,hasDownloadUrl:A,primaryColor:F,whiteLabel:k,isZoomed:T,isAutoPlaying:D,autoPlayInterval:W,soundEnabled:Q,locale:_,messages:G,zoomState:m,pages:i,toc:n,isDoublePageLayout:a,isFrontCover:l,isBackCover:d,init:(f,R,z,H)=>{t.value=R,i.value=z,A.value=H,f.theme!==void 0&&(b.value=f.theme),f.primaryColor!==void 0&&(F.value=f.primaryColor),f.showThumbs!==void 0&&(o.value=f.showThumbs),f.showToc!==void 0&&(r.value=f.showToc),n.value=Bt(f.toc??[],R),f.showArrows!==void 0&&(h.value=f.showArrows),f.allowDownload!==void 0&&(P.value=f.allowDownload),f.whiteLabel!==void 0&&(k.value=f.whiteLabel),f.soundEnabled!==void 0&&(Q.value=f.soundEnabled),f.locale!==void 0&&(_.value=f.locale),f.messages!==void 0&&(G.value=f.messages),f.isSingleMode!==void 0&&(s.value=f.isSingleMode),f.singleMode!==void 0&&(s.value=f.singleMode),f.autoPlay!==void 0&&(D.value=f.autoPlay),f.autoPlayInterval!==void 0&&(W.value=f.autoPlayInterval),e.value=0},reset:()=>{e.value=0,t.value=0,s.value=!1,o.value=!1,h.value=!0,u.value="landscape",c.value="read",b.value="auto",P.value=!0,A.value=!1,F.value="#7367f0",k.value=!1,T.value=!1,D.value=!1,W.value=3e3,Q.value=!0,_.value="en",G.value={},m.value=Pe(),i.value=[],n.value=[]}}}const C=xe();C.currentPage,C.totalPages,C.isSingleMode,C.showThumbs,C.showToc,C.showArrows,C.orientation,C.flipState,C.themeMode,C.allowDownload,C.hasDownloadUrl,C.primaryColor,C.whiteLabel,C.isZoomed,C.isAutoPlaying,C.autoPlayInterval,C.soundEnabled,C.locale,C.messages,C.zoomState,C.pages,C.toc,C.isDoublePageLayout,C.isFrontCover,C.isBackCover;function Se(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.normal=="string"&&typeof t.low=="string"&&typeof t.thumb=="string"}function Si(e){return Array.isArray(e.pageNumbers)&&e.pageNumbers.length>0?e.pageNumbers:typeof e.pageNumber=="number"?e.kind==="spread"?[e.pageNumber,e.pageNumber+1]:[e.pageNumber]:[]}function ki(e){return e==="rtl"?["right","left"]:["left","right"]}function ke(e){const t=[];let s=1;return e.forEach((o,r)=>{const h=o.kind??"single",u=o.id??`asset-${r}`,c=o.splitDirection??"ltr",b=Si(o);if(h==="spread"){const A=b.length>=2?b.slice(0,2):[s,s+1],F=ki(c);A.forEach((k,T)=>{t.push({index:t.length,assetId:u,pageNumber:k,sourcePageNumber:k,cropMode:F[T]??"full",normal:o.normal,low:o.low,thumb:o.thumb})}),s=A[A.length-1]+1;return}const P=b[0]??s;t.push({index:t.length,assetId:u,pageNumber:P,sourcePageNumber:P,cropMode:"full",normal:o.normal,low:o.low,thumb:o.thumb}),s=P+1}),t}function Ti(e){return e?'url("'+e.replace(/["\\\r\n]/g,s=>"\\"+s)+'")':void 0}function Te(e,t){e.classList.add("bk-container"),e.classList.remove("bk-theme-light","bk-theme-dark"),e.classList.add("bk-theme-"+(t.theme??"auto")),t.primaryColor&&e.style.setProperty("--flipbook-accent",t.primaryColor);const s=t.background??{},o=t.backgroundColor||t.backgroundImage?{color:t.backgroundColor,image:t.backgroundImage}:void 0,r=(u,c)=>{const b={["--flipbook-bg-"+u+"-color"]:c==null?void 0:c.color,["--flipbook-bg-"+u+"-image"]:Ti(c==null?void 0:c.image),["--flipbook-bg-"+u+"-size"]:c==null?void 0:c.size,["--flipbook-bg-"+u+"-position"]:c==null?void 0:c.position,["--flipbook-bg-"+u+"-repeat"]:c==null?void 0:c.repeat};Object.entries(b).forEach(([P,A])=>{A?e.style.setProperty(P,A):e.style.removeProperty(P)})};r("light",s.light??o),r("dark",s.dark);const h=t.cssVariables??{};Object.entries(h).forEach(([u,c])=>{const b=u.startsWith("--")?u:"--"+u;e.style.setProperty(b,c)})}class Ci{constructor(t=32){v(this,"entries",new Map);v(this,"hits",0);v(this,"misses",0);if(this.maxEntries=t,!Number.isInteger(t)||t<0)throw new RangeError("PDF render cache size must be a non-negative integer.")}get(t){const s=this.entries.get(t);if(s===void 0){this.misses++;return}return this.hits++,this.entries.delete(t),this.entries.set(t,s),s}set(t,s){if(!(this.maxEntries===0||!s))for(this.entries.delete(t),this.entries.set(t,s);this.entries.size>this.maxEntries;){const o=this.entries.keys().next().value;if(o===void 0)break;this.entries.delete(o)}}clear(){this.entries.clear(),this.hits=0,this.misses=0}get size(){return this.entries.size}getStats(){return{size:this.size,maxEntries:this.maxEntries,hits:this.hits,misses:this.misses}}}const _t=1190.55,Gt=841.89;function Ce(e,t){const s=Math.max(e,t),o=Math.min(e,t),r=s/o,h=Math.abs(s-_t)/_t<=.08&&Math.abs(o-Gt)/Gt<=.08;return e>=t&&h&&Math.abs(r-_t/Gt)<=.04}class Ai{constructor(t={}){v(this,"pdfDoc",null);v(this,"loadingTask",null);v(this,"options");v(this,"cache");const s=Number.isFinite(t.cacheSize)?Math.max(0,Math.floor(t.cacheSize)):32;this.options={scale:t.scale||1.5,quality:t.quality||.85,format:t.format||"image/webp",workerSrc:t.workerSrc||"",concurrency:Math.max(1,Math.floor(t.concurrency||3)),cacheSize:s},this.cache=new Ci(this.options.cacheSize),this.options.workerSrc&&(et.GlobalWorkerOptions.workerSrc=this.options.workerSrc)}async loadDocument(t,s){this.throwIfAborted(s),this.cache.clear();const o=et.getDocument(t);this.loadingTask=o;const r=()=>{var h;return(h=o.destroy)==null?void 0:h.call(o)};s==null||s.addEventListener("abort",r,{once:!0});try{return this.pdfDoc=await o.promise,this.throwIfAborted(s),this.pdfDoc.numPages}catch(h){throw s!=null&&s.aborted?this.createAbortError():h}finally{s==null||s.removeEventListener("abort",r),this.loadingTask===o&&(this.loadingTask=null)}}async renderPageToDataUrl(t,s){if(!this.pdfDoc)throw new Error("PDF document is not loaded.");this.throwIfAborted(s);const o=this.cache.get(t);if(o!==void 0)return o;try{const r=await this.pdfDoc.getPage(t);this.throwIfAborted(s);const h=r.getViewport({scale:this.options.scale}),u=document.createElement("canvas");u.width=h.width,u.height=h.height;const c=u.getContext("2d");if(c){const b=r.render({canvasContext:c,viewport:h}),P=()=>{var F;return(F=b.cancel)==null?void 0:F.call(b)};s==null||s.addEventListener("abort",P,{once:!0});try{await b.promise,this.throwIfAborted(s)}finally{s==null||s.removeEventListener("abort",P)}const A=u.toDataURL(this.options.format,this.options.quality);return this.cache.set(t,A),A}throw new Error("Unable to create a PDF canvas rendering context.")}catch(r){throw s!=null&&s.aborted?this.createAbortError():r}}async getPageLayouts(t="auto"){if(!this.pdfDoc)return[];const s=[];for(let o=1;o<=this.pdfDoc.numPages;o++){const h=(await this.pdfDoc.getPage(o)).getViewport({scale:1}),u=t==="split"?h.width>=h.height:t==="auto"&&Ce(h.width,h.height);s.push({width:h.width,height:h.height,split:u})}return s}async calculateViewportDimensions(t=420,s){if(!this.pdfDoc)throw new Error("PDF document is not loaded.");const o=await this.pdfDoc.getPage(1),r=s?{width:s.split?s.width/2:s.width,height:s.height}:o.getViewport({scale:1}),h=r.width/r.height;return h>=1?{width:Math.round(t*h),height:t}:{width:t,height:Math.round(t/h)}}async renderAllPages(t,s){if(!this.pdfDoc)return[];this.throwIfAborted(t);const o=this.pdfDoc.numPages,r=new Array(o);let h=1,u=0;const c=async()=>{for(;;){this.throwIfAborted(t);const P=h++;if(P>o)return;const A=await this.renderPageToDataUrl(P,t);r[P-1]={index:P-1,assetId:`pdf-page-${P}`,pageNumber:P,cropMode:"full",normal:A,low:A,thumb:A},u++,s==null||s({completed:u,total:o})}},b=Math.min(this.options.concurrency,o);return await Promise.all(Array.from({length:b},()=>c())),this.throwIfAborted(t),r}getCacheStats(){return this.cache.getStats()}throwIfAborted(t){if(t!=null&&t.aborted)throw this.createAbortError()}createAbortError(){const t=new Error("PDF rendering was aborted.");return t.name="AbortError",t}destroy(){var t,s,o,r;(s=(t=this.loadingTask)==null?void 0:t.destroy)==null||s.call(t),this.loadingTask=null,this.pdfDoc&&((r=(o=this.pdfDoc).destroy)==null||r.call(o),this.pdfDoc=null),this.cache.clear()}}/**
172
- * @license FlipbookEngine v0.6.5
171
+ */const Lt=()=>({isActive:!1,translateX:0,translateY:0,isDragging:!1,scale:1});function Nt(){const t=T(0),e=T(0),i=T(!1),n=T(!1),r=T(!1),a=T(!1),h=T(!1),u=T(!0),w=T("landscape"),x=T("read"),P=T("auto"),z=T(!0),k=T(!1),m=T(!1),y=T("#7367f0"),A=T(!1),U=T(!1),W=T(!1),q=T(new Set),v=T(new Map),s=T(3e3),o=T(!0),l=T(""),d=T([]),g=T([]),f=T(null),S=T([]),C=T(null),D=T("en"),F=T({}),B=T(Lt()),G=T([]),Y=T([]),ae=p(()=>!i.value&&w.value==="landscape"),Je=p(()=>ae.value&&t.value===0),is=p(()=>ae.value&&t.value>=e.value-1);return{currentPage:t,totalPages:e,isSingleMode:i,showThumbs:n,showToc:r,showNotes:a,showSearch:h,showArrows:u,orientation:w,flipState:x,themeMode:P,allowDownload:z,bookmarkedPages:q,pageNotes:v,hasDownloadUrl:k,isPdfMode:m,primaryColor:y,whiteLabel:A,isZoomed:U,isAutoPlaying:W,autoPlayInterval:s,soundEnabled:o,searchQuery:l,searchResults:d,hotspots:g,activeHotspotId:f,annotations:S,activeAnnotationId:C,locale:D,messages:F,zoomState:B,pages:G,toc:Y,isDoublePageLayout:ae,isFrontCover:Je,isBackCover:is,init:(I,Ie,ss,Xt,ns=Xt)=>{e.value=Ie,G.value=ss,k.value=Xt,m.value=ns,I.theme!==void 0&&(P.value=I.theme),I.primaryColor!==void 0&&(y.value=I.primaryColor),I.showThumbs!==void 0&&(n.value=I.showThumbs),I.showToc!==void 0&&(r.value=I.showToc),a.value=!1,h.value=!1,l.value="",d.value=[],g.value=I.hotspots??[],f.value=null,S.value=I.annotations??[],C.value=null,Y.value=Ae(I.toc??[],Ie),I.showArrows!==void 0&&(u.value=I.showArrows),I.allowDownload!==void 0&&(z.value=I.allowDownload),I.whiteLabel!==void 0&&(A.value=I.whiteLabel),I.soundEnabled!==void 0&&(o.value=I.soundEnabled),I.locale!==void 0&&(D.value=I.locale),I.messages!==void 0&&(F.value=I.messages),I.isSingleMode!==void 0&&(i.value=I.isSingleMode),I.singleMode!==void 0&&(i.value=I.singleMode),I.autoPlay!==void 0&&(W.value=I.autoPlay),I.autoPlayInterval!==void 0&&(s.value=I.autoPlayInterval),q.value=new Set((I.bookmarks??[]).map(Z=>Math.trunc(Z)).filter(Z=>Number.isInteger(Z)&&Z>=0&&Z<Ie)),v.value=new Map(Object.entries(I.notes??{}).map(([Z,et])=>[Math.trunc(Number(Z)),String(et).trim()]).filter(([Z,et])=>Number.isInteger(Z)&&Z>=0&&Z<Ie&&et.length>0)),t.value=0},reset:()=>{t.value=0,e.value=0,i.value=!1,n.value=!1,r.value=!1,a.value=!1,h.value=!1,u.value=!0,w.value="landscape",x.value="read",P.value="auto",z.value=!0,k.value=!1,m.value=!1,y.value="#7367f0",A.value=!1,U.value=!1,W.value=!1,s.value=3e3,o.value=!0,D.value="en",F.value={},B.value=Lt(),G.value=[],Y.value=[],q.value=new Set,v.value=new Map,l.value="",d.value=[],g.value=[],f.value=null,S.value=[],C.value=null}}}const M=Nt();M.currentPage,M.totalPages,M.isSingleMode,M.showThumbs,M.showToc,M.showNotes,M.showSearch,M.showArrows,M.orientation,M.flipState,M.themeMode,M.allowDownload,M.bookmarkedPages,M.pageNotes,M.hasDownloadUrl,M.isPdfMode,M.primaryColor,M.whiteLabel,M.isZoomed,M.isAutoPlaying,M.autoPlayInterval,M.soundEnabled,M.searchQuery,M.searchResults,M.hotspots,M.activeHotspotId,M.annotations,M.activeAnnotationId,M.locale,M.messages,M.zoomState,M.pages,M.toc,M.isDoublePageLayout,M.isFrontCover,M.isBackCover;function zt(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.normal=="string"&&typeof e.low=="string"&&typeof e.thumb=="string"}function Qi(t){return Array.isArray(t.pageNumbers)&&t.pageNumbers.length>0?t.pageNumbers:typeof t.pageNumber=="number"?t.kind==="spread"?[t.pageNumber,t.pageNumber+1]:[t.pageNumber]:[]}function Yi(t){return t==="rtl"?["right","left"]:["left","right"]}function Ft(t){const e=[];let i=1;return t.forEach((n,r)=>{const a=n.kind??"single",h=n.id??`asset-${r}`,u=n.splitDirection??"ltr",w=Qi(n);if(a==="spread"){const P=w.length>=2?w.slice(0,2):[i,i+1],z=Yi(u);P.forEach((k,m)=>{e.push({index:e.length,assetId:h,pageNumber:k,sourcePageNumber:k,cropMode:z[m]??"full",normal:n.normal,low:n.low,thumb:n.thumb})}),i=P[P.length-1]+1;return}const x=w[0]??i;e.push({index:e.length,assetId:h,pageNumber:x,sourcePageNumber:x,cropMode:"full",normal:n.normal,low:n.low,thumb:n.thumb}),i=x+1}),e}function Ki(t){return t?'url("'+t.replace(/["\\\r\n]/g,i=>"\\"+i)+'")':void 0}function Ot(t,e){t.classList.add("bk-container"),t.classList.remove("bk-theme-light","bk-theme-dark"),t.classList.add("bk-theme-"+(e.theme??"auto")),e.primaryColor&&t.style.setProperty("--flipbook-accent",e.primaryColor);const i=e.background??{},n=e.backgroundColor||e.backgroundImage?{color:e.backgroundColor,image:e.backgroundImage}:void 0,r=(h,u)=>{const w={["--flipbook-bg-"+h+"-color"]:u==null?void 0:u.color,["--flipbook-bg-"+h+"-image"]:Ki(u==null?void 0:u.image),["--flipbook-bg-"+h+"-size"]:u==null?void 0:u.size,["--flipbook-bg-"+h+"-position"]:u==null?void 0:u.position,["--flipbook-bg-"+h+"-repeat"]:u==null?void 0:u.repeat};Object.entries(w).forEach(([x,P])=>{P?t.style.setProperty(x,P):t.style.removeProperty(x)})};r("light",i.light??n),r("dark",i.dark);const a=e.cssVariables??{};Object.entries(a).forEach(([h,u])=>{const w=h.startsWith("--")?h:"--"+h;t.style.setProperty(w,u)})}class Ji{constructor(e=32){b(this,"entries",new Map);b(this,"hits",0);b(this,"misses",0);if(this.maxEntries=e,!Number.isInteger(e)||e<0)throw new RangeError("PDF render cache size must be a non-negative integer.")}get(e){const i=this.entries.get(e);if(i===void 0){this.misses++;return}return this.hits++,this.entries.delete(e),this.entries.set(e,i),i}set(e,i){if(!(this.maxEntries===0||!i))for(this.entries.delete(e),this.entries.set(e,i);this.entries.size>this.maxEntries;){const n=this.entries.keys().next().value;if(n===void 0)break;this.entries.delete(n)}}clear(){this.entries.clear(),this.hits=0,this.misses=0}get size(){return this.entries.size}getStats(){return{size:this.size,maxEntries:this.maxEntries,hits:this.hits,misses:this.misses}}}const Qe=1190.55,Ye=841.89;function Bt(t,e){const i=Math.max(t,e),n=Math.min(t,e),r=i/n,a=Math.abs(i-Qe)/Qe<=.08&&Math.abs(n-Ye)/Ye<=.08;return t>=e&&a&&Math.abs(r-Qe/Ye)<=.04}class es{constructor(e={}){b(this,"pdfDoc",null);b(this,"loadingTask",null);b(this,"options");b(this,"cache");b(this,"textCache",new Map);const i=Number.isFinite(e.cacheSize)?Math.max(0,Math.floor(e.cacheSize)):32;this.options={scale:e.scale||1.5,quality:e.quality||.85,format:e.format||"image/webp",workerSrc:e.workerSrc||"",concurrency:Math.max(1,Math.floor(e.concurrency||3)),cacheSize:i},this.cache=new Ji(this.options.cacheSize),this.options.workerSrc&&(le.GlobalWorkerOptions.workerSrc=this.options.workerSrc)}async loadDocument(e,i){this.throwIfAborted(i),this.cache.clear();const n=le.getDocument(e);this.loadingTask=n;const r=()=>{var a;return(a=n.destroy)==null?void 0:a.call(n)};i==null||i.addEventListener("abort",r,{once:!0});try{return this.pdfDoc=await n.promise,this.throwIfAborted(i),this.pdfDoc.numPages}catch(a){throw i!=null&&i.aborted?this.createAbortError():a}finally{i==null||i.removeEventListener("abort",r),this.loadingTask===n&&(this.loadingTask=null)}}async renderPageToDataUrl(e,i){if(!this.pdfDoc)throw new Error("PDF document is not loaded.");this.throwIfAborted(i);const n=this.cache.get(e);if(n!==void 0)return n;try{const r=await this.pdfDoc.getPage(e);this.throwIfAborted(i);const a=r.getViewport({scale:this.options.scale}),h=document.createElement("canvas");h.width=a.width,h.height=a.height;const u=h.getContext("2d");if(u){const w=r.render({canvasContext:u,viewport:a}),x=()=>{var z;return(z=w.cancel)==null?void 0:z.call(w)};i==null||i.addEventListener("abort",x,{once:!0});try{await w.promise,this.throwIfAborted(i)}finally{i==null||i.removeEventListener("abort",x)}const P=h.toDataURL(this.options.format,this.options.quality);return this.cache.set(e,P),P}throw new Error("Unable to create a PDF canvas rendering context.")}catch(r){throw i!=null&&i.aborted?this.createAbortError():r}}async extractPageText(e){if(!this.pdfDoc)throw new Error("PDF document is not loaded.");if(!Number.isInteger(e)||e<1||e>this.pdfDoc.numPages)throw new Error("PDF page number is out of range.");const i=this.textCache.get(e);if(i!==void 0)return i;const r=await(await this.pdfDoc.getPage(e)).getTextContent(),a=((r==null?void 0:r.items)??[]).map(h=>typeof(h==null?void 0:h.str)=="string"?h.str:"").filter(Boolean).join(" ").replace(/\s+/g," ").trim();return this.textCache.set(e,a),a}async searchText(e,i={}){const n=String(e??"").trim();if(!this.pdfDoc||!n)return[];const r=i.caseSensitive===!0,a=r?n:n.toLocaleLowerCase(),h=Number.isFinite(i.maxResults)?Math.max(1,Math.trunc(i.maxResults)):100,u=[];for(let w=1;w<=this.pdfDoc.numPages&&u.length<h;w++){const x=await this.pdfDoc.getPage(w),P=await x.getTextContent(),z=((P==null?void 0:P.items)??[]).filter(g=>typeof(g==null?void 0:g.str)=="string"&&g.str.length>0),k=z.map(g=>g.str).join(" ").replace(/\s+/g," ").trim(),m=r?k:k.toLocaleLowerCase();let y=0,A=m.indexOf(a);for(;A>=0;)y++,A=m.indexOf(a,A+Math.max(1,a.length));if(!y)continue;const U=m.indexOf(a),W=Math.max(0,U-70),q=Math.min(k.length,U+n.length+100),v=[],s=typeof x.getViewport=="function"?x.getViewport({scale:1}):null,o=Number(s==null?void 0:s.width),l=Number(s==null?void 0:s.height);o>0&&l>0&&z.forEach(g=>{const f=String(g.str),S=r?f:f.toLocaleLowerCase(),C=Array.isArray(g.transform)?g.transform:[],D=Number(C[4]),F=Number(C[5]),B=Number(g.width)||Math.abs(Number(C[0]))||0,G=Number(g.height)||Math.abs(Number(C[3]))||0;if(!(B>0&&G>0&&Number.isFinite(D)&&Number.isFinite(F)))return;let Y=S.indexOf(a);for(;Y>=0;){const ae=Math.max(0,Math.min(1,Y/Math.max(1,f.length))),Je=Math.max(.02,Math.min(1-ae,a.length/Math.max(1,f.length)));v.push({x:Math.max(0,Math.min(1,(D+B*ae)/o)),y:Math.max(0,Math.min(1,(l-F-G)/l)),width:Math.max(0,Math.min(1,B*Je/o)),height:Math.max(0,Math.min(1,G/l))}),Y=S.indexOf(a,Y+Math.max(1,a.length))}});const d={sourcePageNumber:w,matches:y,snippet:k.slice(W,q).trim()};v.length&&(d.highlights=v),u.push(d)}return u}async getPageLayouts(e="auto"){if(!this.pdfDoc)return[];const i=[];for(let n=1;n<=this.pdfDoc.numPages;n++){const a=(await this.pdfDoc.getPage(n)).getViewport({scale:1}),h=e==="split"?a.width>=a.height:e==="auto"&&Bt(a.width,a.height);i.push({width:a.width,height:a.height,split:h})}return i}async calculateViewportDimensions(e=420,i){if(!this.pdfDoc)throw new Error("PDF document is not loaded.");const n=await this.pdfDoc.getPage(1),r=i?{width:i.split?i.width/2:i.width,height:i.height}:n.getViewport({scale:1}),a=r.width/r.height;return a>=1?{width:Math.round(e*a),height:e}:{width:e,height:Math.round(e/a)}}async renderAllPages(e,i){if(!this.pdfDoc)return[];this.throwIfAborted(e);const n=this.pdfDoc.numPages,r=new Array(n);let a=1,h=0;const u=async()=>{for(;;){this.throwIfAborted(e);const x=a++;if(x>n)return;const P=await this.renderPageToDataUrl(x,e);r[x-1]={index:x-1,assetId:`pdf-page-${x}`,pageNumber:x,cropMode:"full",normal:P,low:P,thumb:P},h++,i==null||i({completed:h,total:n})}},w=Math.min(this.options.concurrency,n);return await Promise.all(Array.from({length:w},()=>u())),this.throwIfAborted(e),r}getCacheStats(){return this.cache.getStats()}throwIfAborted(e){if(e!=null&&e.aborted)throw this.createAbortError()}createAbortError(){const e=new Error("PDF rendering was aborted.");return e.name="AbortError",e}destroy(){var e,i,n,r;(i=(e=this.loadingTask)==null?void 0:e.destroy)==null||i.call(e),this.loadingTask=null,this.pdfDoc&&((r=(n=this.pdfDoc).destroy)==null||r.call(n),this.pdfDoc=null),this.cache.clear()}}/**
172
+ * @license FlipbookEngine v1.0.0
173
+ * Copyright (c) 2026 Murat Dogan
174
+ *
175
+ * This source code is dual-licensed under the AGPLv3 and a Commercial License.
176
+ */const Ht="flipbook:command",$t="flipbook:event",Wt="flipbook:response";function re(){return typeof window>"u"?null:window}function _t(t,e){var n;const i=(n=t.allowedOrigins)==null?void 0:n.filter(Boolean);return i!=null&&i.length?i:[e]}function Ke(t){return t&&typeof t=="object"?t:{}}function Ut(t,e){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} must be a finite number.`);return t}class Gt{constructor(e,i={}){b(this,"engine");b(this,"options");b(this,"listener");b(this,"unsubs",[]);b(this,"connected",!1);b(this,"parentOrigin",null);b(this,"engineEventNames",{init:!0,destroy:!0,pageChange:!0,zoomChange:!0,thumbsToggle:!0,tocToggle:!0,singlePageModeChange:!0,orientationChange:!0,progress:!0,error:!0,deepLinkChange:!0,bookmarkChange:!0,noteChange:!0,searchChange:!0,hotspotActivate:!0,annotationActivate:!0});this.engine=e,this.options=i,this.listener=n=>{this.handleMessage(n)}}connect(){if(this.connected)return this;const e=re();return!e||e.parent===e?this:(this.connected=!0,e.addEventListener("message",this.listener),Object.keys(this.engineEventNames).forEach(i=>{this.unsubs.push(this.engine.on(i,n=>{this.postEvent(i,n)}))}),this)}disconnect(){var e;this.connected&&((e=re())==null||e.removeEventListener("message",this.listener),this.unsubs.splice(0).forEach(i=>i()),this.connected=!1,this.parentOrigin=null)}isAllowedOrigin(e){const i=re(),n=(i==null?void 0:i.location.origin)??"";return _t(this.options,n).includes("*")||_t(this.options,n).includes(e)}post(e){const i=re(),n=i==null?void 0:i.parent;if(!i||!n||n===i)return;const r=this.options.targetOrigin??this.parentOrigin??i.location.origin;n.postMessage(e,r)}postEvent(e,i){this.post({type:$t,event:e,payload:i})}respond(e,i,n){this.post({type:Wt,requestId:e,ok:!n,...n?{error:n instanceof Error?n.message:String(n)}:{result:i}})}async handleMessage(e){const i=re();if(!i||e.source!==i.parent||!this.isAllowedOrigin(e.origin))return;const n=Ke(e.data);if(n.type!==Ht||typeof n.command!="string")return;this.parentOrigin=e.origin;const r=typeof n.requestId=="string"?n.requestId:void 0;try{const a=Ke(n.payload);let h;switch(n.command){case"goToPage":this.engine.goToPage(Math.trunc(Ut(a.pageIndex,"pageIndex"))),h=this.getState();break;case"nextPage":this.engine.nextPage(),h=this.getState();break;case"prevPage":this.engine.prevPage(),h=this.getState();break;case"setZoom":this.engine.setZoom(Ut(a.zoom,"zoom")),h=this.getState();break;case"setSingleMode":if(typeof a.isSingle!="boolean")throw new Error("isSingle must be a boolean.");this.engine.setSingleMode(a.isSingle),h=this.getState();break;case"updateOptions":this.engine.updateOptions(a.options),h=this.getState();break;case"toggleFullscreen":this.engine.toggleFullscreen(),h=this.getState();break;case"search":h=await this.engine.search(String(a.query??""),a.options);break;case"clearSearch":this.engine.clearSearch(),h=this.getState();break;case"getSearchResults":h=this.engine.getSearchResults();break;case"getToc":h=this.engine.getToc();break;case"setToc":if(!Array.isArray(a.entries))throw new Error("entries must be an array.");this.engine.setToc(a.entries,typeof a.show=="boolean"?a.show:void 0),h=this.getState();break;case"getState":h=this.getState();break;default:throw new Error(`Unknown embed command: ${n.command}`)}this.respond(r,h)}catch(a){this.respond(r,void 0,a)}}getState(){return{currentPage:this.engine.getCurrentPage(),totalPages:this.engine.getTotalPages(),zoom:this.engine.getZoom()}}}function ts(t,e={}){const i=re(),n=e.targetOrigin??(i==null?void 0:i.location.origin)??"*",r=e.responseTimeout??5e3,a=new Map,h={};let u=0;const w=k=>n==="*"||k===n,x=k=>{var y;if(k.source!==t.contentWindow||!w(k.origin))return;const m=Ke(k.data);if(m.type===Wt&&typeof m.requestId=="string"){const A=a.get(m.requestId);if(!A)return;a.delete(m.requestId),clearTimeout(A.timer),m.ok?A.resolve(m.result):A.reject(new Error(typeof m.error=="string"?m.error:"Embed command failed."));return}m.type===$t&&typeof m.event=="string"&&((y=h[m.event])==null||y.forEach(A=>A(m.payload)))};i==null||i.addEventListener("message",x);const P=(k,m)=>{const y=`flipbook-${++u}`;return new Promise((A,U)=>{if(!t.contentWindow){U(new Error("The embed iframe is not ready."));return}const W=setTimeout(()=>{a.delete(y),U(new Error(`Embed command timed out: ${k}`))},r);a.set(y,{resolve:A,reject:U,timer:W}),t.contentWindow.postMessage({type:Ht,command:k,payload:m,requestId:y},n)})};return{send:P,goToPage:k=>P("goToPage",{pageIndex:k}),nextPage:()=>P("nextPage"),prevPage:()=>P("prevPage"),setZoom:k=>P("setZoom",{zoom:k}),setSingleMode:k=>P("setSingleMode",{isSingle:k}),updateOptions:k=>P("updateOptions",{options:k}),toggleFullscreen:()=>P("toggleFullscreen"),search:(k,m)=>P("search",{query:k,options:m}),clearSearch:()=>P("clearSearch"),getSearchResults:()=>P("getSearchResults"),getToc:()=>P("getToc"),setToc:(k,m)=>P("setToc",{entries:k,show:m}),getState:()=>P("getState"),on:(k,m)=>{const y=h[k]??new Set;return y.add(m),h[k]=y,()=>y.delete(m)},destroy:()=>{i==null||i.removeEventListener("message",x),a.forEach(k=>{clearTimeout(k.timer),k.reject(new Error("Embed controller destroyed."))}),a.clear(),Object.keys(h).forEach(k=>delete h[k])}}}/**
177
+ * @license FlipbookEngine v1.0.0
178
+ * Copyright (c) 2026 Murat Dogan
179
+ * SPDX-License-Identifier: AGPL-3.0-or-later
180
+ */class jt{constructor(){b(this,"version",T(0));b(this,"activePanelId",T(null));b(this,"plugins",new Map)}install(e,i){const n=String((i==null?void 0:i.name)||"").trim();if(!n)throw new Error("Flipbook plugin name is required.");if(this.plugins.has(n))throw new Error(`Flipbook plugin "${n}" is already installed.`);const r={plugin:i,context:void 0,cleanups:new Set,toolbarButtons:new Map,panels:new Map,apis:new Map},a={engine:e,pluginName:n,activePanelId:this.activePanelId,registerToolbarButton:h=>{const u=this.requireContributionId(h==null?void 0:h.id,"toolbar button");if(r.toolbarButtons.has(u))throw new Error(`Plugin "${n}" already registered toolbar button "${u}".`);return r.toolbarButtons.set(u,h),this.version.value++,()=>{r.toolbarButtons.delete(u)&&this.version.value++}},registerPanel:h=>{const u=this.requireContributionId(h==null?void 0:h.id,"panel");if(r.panels.has(u))throw new Error(`Plugin "${n}" already registered panel "${u}".`);return r.panels.set(u,h),this.version.value++,()=>{r.panels.delete(u)&&(this.activePanelId.value===this.key(n,u)&&(this.activePanelId.value=null),this.version.value++)}},registerApi:(h,u)=>{const w=this.requireContributionId(h,"API");if(r.apis.has(w))throw new Error(`Plugin "${n}" already registered API "${w}".`);return r.apis.set(w,u),this.version.value++,()=>{r.apis.delete(w)&&this.version.value++}},on:(h,u)=>{const w=e.on(h,u);return r.cleanups.add(w),()=>{r.cleanups.delete(w),w()}},openPanel:h=>{const u=this.requireContributionId(h,"panel");if(!r.panels.has(u))throw new Error(`Plugin "${n}" has no panel "${u}".`);this.activePanelId.value=this.key(n,u)},closePanel:h=>{const u=h?this.key(n,h):null;(!h||this.activePanelId.value===u)&&(this.activePanelId.value=null)},addCleanup:h=>{typeof h=="function"&&r.cleanups.add(h)}};r.context=a,this.plugins.set(n,r);try{const h=i.install(e,a);typeof h=="function"&&r.cleanups.add(h)}catch(h){throw this.plugins.delete(n),r.cleanups.forEach(u=>u()),h}this.version.value++}uninstall(e){var n;const i=this.plugins.get(e);return i?((n=this.activePanelId.value)!=null&&n.startsWith(e+":")&&(this.activePanelId.value=null),i.cleanups.forEach(r=>r()),i.toolbarButtons.clear(),i.panels.clear(),i.apis.clear(),this.plugins.delete(e),this.version.value++,!0):!1}clear(){Array.from(this.plugins.keys()).forEach(e=>this.uninstall(e))}getPluginNames(){return Array.from(this.plugins.keys())}getToolbarButtons(){const e=[];return this.plugins.forEach((i,n)=>i.toolbarButtons.forEach((r,a)=>{e.push({...r,pluginName:n,key:this.key(n,a)})})),e}getPanels(){const e=[];return this.plugins.forEach((i,n)=>i.panels.forEach((r,a)=>{e.push({...r,pluginName:n,key:this.key(n,a)})})),e}getApi(e,i){var n;return(n=this.plugins.get(e))==null?void 0:n.apis.get(i)}async callApi(e,i,...n){const r=this.getApi(e,i);if(!r)throw new Error(`Plugin API "${e}.${i}" is not registered.`);return await r(...n)}key(e,i){return`${e}:${i}`}requireContributionId(e,i){const n=String(e||"").trim();if(!n)throw new Error(`Flipbook plugin ${i} id is required.`);return n}}/**
181
+ * @license FlipbookEngine v1.0.0
173
182
  * Copyright (c) 2026 Murat Dogan
174
183
  *
175
184
  * This source code is dual-licensed under the AGPLv3 and a Commercial License.
@@ -181,5 +190,5 @@ var FlipbookEngine=function(x,E){"use strict";var Ei=Object.defineProperty;var D
181
190
  * closed-source, or SaaS products without the AGPLv3 obligations,
182
191
  * you must purchase a Commercial License from:
183
192
  * https://flipbookengine.com/pricing
184
- */const Pt=class Pt{constructor(t,s={}){v(this,"container",null);v(this,"options");v(this,"store",xe());v(this,"pageFlipAdapter",null);v(this,"layoutManager",null);v(this,"interactionManager",null);v(this,"pdfRenderer",null);v(this,"listeners",{});v(this,"initializationTimer",null);v(this,"initGeneration",0);v(this,"initAbortController",null);v(this,"eventsReady",!1);v(this,"lastEventState",{currentPage:0,zoom:1,zoomActive:!1,showThumbs:!1,showToc:!1,isSingle:!1,orientation:""});v(this,"eventSyncStop",null);v(this,"qualityObserver",null);v(this,"pdfLazyStop",null);v(this,"hasActiveSession",!1);v(this,"pdfPageRequests",new Map);v(this,"pdfRenderedPages",new Set);v(this,"pdfRenderedSources",new Map);v(this,"pdfSourcePageCount",0);this.selector=t,this.options={allowDownload:!0,showThumbs:!1,primaryColor:"#7367f0",theme:"auto",soundUrl:"https://flipbookengine.com/Content/page-flip.mp3",autoPlayInterval:3e3,pdfRenderScale:1.5,pdfRenderQuality:.85,pdfRenderFormat:"image/webp",pdfRenderConcurrency:3,pdfRenderCacheSize:32,pdfPageMode:"auto",...s},this.setupEventSync()}async init(t,s){if(typeof this.selector=="string"?this.container=document.querySelector(this.selector):this.container=this.selector,!this.container)return;this.eventsReady=!1,this.destroy(!0);const o=this.initGeneration,r=new AbortController;this.initAbortController=r;let h=[],u={...Pt.DEFAULT_PAGE_VIEWPORT};if(s&&s.length>0){if(r.signal.aborted)return;const T=s.filter(Se);h=ke(T);const D=h[0];if(D){const W=await this.loadImageSize(D.low||D.normal);if(W){const _=(D.cropMode!=="full"?W.width/2:W.width)/W.height,G=420;u=_>=1?{width:Math.round(G*_),height:G}:{width:G,height:Math.round(G/_)}}}}else if(t){if(r.signal.aborted)return;let T="load";try{this.pdfRenderer=new Ai({scale:this.options.pdfRenderScale,quality:this.options.pdfRenderQuality,format:this.options.pdfRenderFormat,concurrency:this.options.pdfRenderConcurrency,cacheSize:this.options.pdfRenderCacheSize,workerSrc:this.options.pdfWorkerSrc}),this.emit("progress",{phase:"loading",completed:0,total:0});const D=await this.pdfRenderer.loadDocument(t,r.signal);T="render",this.emit("progress",{phase:"loading",completed:1,total:D});const W=await this.pdfRenderer.getPageLayouts(this.options.pdfPageMode);u=W.length?await this.pdfRenderer.calculateViewportDimensions(420,W[0]):await this.pdfRenderer.calculateViewportDimensions(),h=W.length?this.createPdfPlaceholders(W):Array.from({length:D},(Q,_)=>this.createPdfPlaceholder(_+1)),this.pdfSourcePageCount=D}catch(D){r.signal.aborted||(console.error("PDF load failed:",D),this.emit("error",{code:T==="load"?"PDF_LOAD_FAILED":"PDF_RENDER_FAILED",message:D instanceof Error?D.message:"Unable to load PDF.",cause:D}));return}}if(r.signal.aborted||o!==this.initGeneration||!h.length)return;this.store.init(this.options,h.length,h,!!t),Te(this.container,this.options),this.container.innerHTML="";let c,b,P;const A={current:null},F={current:null},k=fi({pageFlipAdapterRef:A,interactionManagerRef:F,bookWrapperRef:T=>c=T,bookSizerRef:T=>b=T,bookContainerRef:T=>P=T,className:this.options.className,store:this.store,onToggleFullscreen:()=>this.toggleFullscreen(),onDownload:()=>{t&&(this.options.onDownload?this.options.onDownload(t):window.open(t,"_blank"))}});this.container.appendChild(k),this.setupQualityLoading(),this.layoutManager=new Pi(u,this.store),this.layoutManager.onResizeCallback=()=>{this.pageFlipAdapter&&this.pageFlipAdapter.update()},this.layoutManager.init(c,b),this.pageFlipAdapter=new bi(P,this.options,this.store),A.current=this.pageFlipAdapter,await new Promise(T=>{const D=()=>{r.signal.removeEventListener("abort",D),T()};r.signal.addEventListener("abort",D,{once:!0}),this.initializationTimer=setTimeout(async()=>{if(this.initializationTimer=null,r.signal.removeEventListener("abort",D),r.signal.aborted||o!==this.initGeneration||!this.pageFlipAdapter){T();return}if(this.pageFlipAdapter.init(u.width,u.height),this.interactionManager=new xi(c,this.pageFlipAdapter,this.store),this.interactionManager.init(),F.current=this.interactionManager,this.setupPdfLazyLoading(),this.pdfRenderer&&t)try{await this.renderPdfPage(1,r.signal)}catch{T();return}if(r.signal.aborted||o!==this.initGeneration){T();return}this.eventsReady=!0,this.captureEventState(),this.hasActiveSession=!0,this.emit("init",{totalPages:h.length}),T()},10)}),this.initAbortController===r&&(this.initAbortController=null)}createPdfPlaceholder(t){const s="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";return{index:t-1,assetId:"pdf-page-"+t+"-full",pageNumber:t,sourcePageNumber:t,cropMode:"full",normal:s,low:s,thumb:s}}createPdfPlaceholders(t){const s="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",o=[];return t.forEach((r,h)=>{const u=h+1;(r.split?["left","right"]:["full"]).forEach(b=>{const P=o.length+1;o.push({index:o.length,assetId:`pdf-page-${u}-${b}`,pageNumber:P,sourcePageNumber:u,cropMode:b,normal:s,low:s,thumb:s})})}),o}renderPdfPage(t,s){const o=this.pdfRenderer,r=this.initGeneration;if(!o)return Promise.resolve("");const h=this.pdfPageRequests.get(t);if(h)return h;if(this.pdfRenderedPages.has(t)){const c=this.pdfRenderedSources.get(t);return c&&this.hydratePdfImages(t,c),Promise.resolve(c||"")}const u=o.renderPageToDataUrl(t,s).then(c=>{if(r!==this.initGeneration||s!=null&&s.aborted)throw this.createAbortError();if(!c)throw new Error("PDF page "+t+" produced no image.");return this.pdfRenderedPages.add(t),this.pdfRenderedSources.set(t,c),this.hydratePdfImages(t,c),this.emit("progress",{phase:"rendering",completed:this.pdfRenderedPages.size,total:this.pdfSourcePageCount||this.store.totalPages.value}),c}).catch(c=>{throw r!==this.initGeneration&&(c==null?void 0:c.name)!=="AbortError"?this.createAbortError():((c==null?void 0:c.name)==="AbortError"||this.emit("error",{code:"PDF_RENDER_FAILED",message:c instanceof Error?c.message:"Unable to render PDF page.",cause:c}),c)}).finally(()=>{this.pdfPageRequests.get(t)===u&&this.pdfPageRequests.delete(t)});return this.pdfPageRequests.set(t,u),u}hydratePdfImages(t,s){var o;(o=this.container)==null||o.querySelectorAll("img").forEach(r=>{r.dataset.pdfPage===String(t)&&(r.src=s,delete r.dataset.pdfPage)})}setupPdfLazyLoading(){var t;(t=this.pdfLazyStop)==null||t.call(this),this.pdfLazyStop=null,this.pdfRenderer&&(this.pdfLazyStop=U(()=>{const s=this.store.pages.value[this.store.currentPage.value],o=this.store.pages.value[this.store.currentPage.value+1];new Set([(s==null?void 0:s.sourcePageNumber)??(s==null?void 0:s.pageNumber),(o==null?void 0:o.sourcePageNumber)??(o==null?void 0:o.pageNumber)]).forEach(h=>{h&&this.renderPdfPage(h).catch(()=>{})})}))}loadImageSize(t){return new Promise(s=>{const o=new Image;o.onload=()=>s({width:o.naturalWidth||o.width,height:o.naturalHeight||o.height}),o.onerror=()=>s(null),o.src=t})}goToPage(t){const s=Math.max(0,this.store.totalPages.value-1);this.store.currentPage.value=Math.max(0,Math.min(s,Math.trunc(t)))}getTotalPages(){return this.store.totalPages.value}getCurrentPage(){return this.store.currentPage.value}getZoom(){return this.store.zoomState.value.scale}setZoom(t){const s=Number.isFinite(t)?t:1,o=Math.max(.5,Math.min(5,s));this.store.zoomState.value={...this.store.zoomState.value,scale:o,isActive:o>1,...o<=1?{translateX:0,translateY:0}:{}},this.store.isZoomed.value=o>1}nextPage(){this.pageFlipAdapter&&this.pageFlipAdapter.turnToNextPage()}toggleFullscreen(){var s,o;const t=this.container;t&&(document.fullscreenElement?(o=document.exitFullscreen)==null||o.call(document).catch(r=>console.warn("Exit fullscreen err:",r)):(s=t.requestFullscreen)==null||s.call(t).catch(r=>console.warn("Fullscreen err:",r)))}setLocale(t,s){const o=s?{...this.options.messages,[t]:s[t]??s}:this.options.messages;this.options={...this.options,locale:t,messages:o},this.store.locale.value=t,o&&(this.store.messages.value=o)}prevPage(){this.pageFlipAdapter&&this.pageFlipAdapter.turnToPrevPage()}setSingleMode(t){this.store.isSingleMode.value=t,t&&this.pdfRenderer&&setTimeout(()=>{const s=this.store.pages.value[this.store.currentPage.value],o=(s==null?void 0:s.sourcePageNumber)??(s==null?void 0:s.pageNumber);o&&this.renderPdfPage(o).catch(()=>{})},0)}updateOptions(t){this.options={...this.options,...t},t.theme!==void 0&&(this.store.themeMode.value=t.theme),t.primaryColor!==void 0&&(this.store.primaryColor.value=t.primaryColor),t.showThumbs!==void 0&&(this.store.showThumbs.value=t.showThumbs),t.showToc!==void 0&&(this.store.showToc.value=t.showToc),t.toc!==void 0&&(this.store.toc.value=Bt(t.toc,this.store.totalPages.value)),t.showArrows!==void 0&&(this.store.showArrows.value=t.showArrows),t.allowDownload!==void 0&&(this.store.allowDownload.value=t.allowDownload),t.whiteLabel!==void 0&&(this.store.whiteLabel.value=t.whiteLabel),t.soundEnabled!==void 0&&(this.store.soundEnabled.value=t.soundEnabled),t.locale!==void 0&&(this.store.locale.value=t.locale),t.messages!==void 0&&(this.store.messages.value=t.messages),t.singleMode!==void 0&&(this.store.isSingleMode.value=t.singleMode),t.isSingleMode!==void 0&&(this.store.isSingleMode.value=t.isSingleMode),t.autoPlay!==void 0&&(this.store.isAutoPlaying.value=t.autoPlay),t.autoPlayInterval!==void 0&&(this.store.autoPlayInterval.value=t.autoPlayInterval),this.container&&Te(this.container,this.options)}async setPages(t,s){if(!(t!=null&&t.length)){s&&await this.init(s);return}await this.init(s||"",t)}setupQualityLoading(){var r;if(this.teardownQualityLoading(),!this.container)return;const t=Array.from(this.container.querySelectorAll("img[data-src], img[data-pdf-page]")),s=h=>{const u=Number(h.dataset.pdfPage);if(Number.isInteger(u)&&u>0){this.renderPdfPage(u).catch(()=>{});return}const c=h.dataset.src;c&&(h.src=c,delete h.dataset.src)},o=(r=this.container.ownerDocument.defaultView)==null?void 0:r.IntersectionObserver;if(!o){const h=new Set;t.forEach(u=>{const c=Number(u.dataset.pdfPage);Number.isInteger(c)&&c>0?h.size<2&&(h.add(c),s(u)):s(u)});return}this.qualityObserver=new o(h=>{h.forEach(u=>{var c;u.isIntersecting&&(s(u.target),(c=this.qualityObserver)==null||c.unobserve(u.target))})},{root:this.container,rootMargin:"240px"}),t.forEach(h=>{var u;return(u=this.qualityObserver)==null?void 0:u.observe(h)})}teardownQualityLoading(){var t;(t=this.qualityObserver)==null||t.disconnect(),this.qualityObserver=null}setupEventSync(){this.eventSyncStop=U(()=>{const t={currentPage:this.store.currentPage.value,zoom:this.store.zoomState.value.scale,zoomActive:this.store.zoomState.value.isActive,showThumbs:this.store.showThumbs.value,showToc:this.store.showToc.value,isSingle:this.store.isSingleMode.value,orientation:this.store.orientation.value};if(!this.eventsReady){this.lastEventState=t;return}t.currentPage!==this.lastEventState.currentPage&&this.emit("pageChange",{currentPage:t.currentPage,pageNumber:t.currentPage+1,totalPages:this.store.totalPages.value,isSingle:t.isSingle}),(t.zoom!==this.lastEventState.zoom||t.zoomActive!==this.lastEventState.zoomActive)&&this.emit("zoomChange",{zoom:t.zoom,isActive:t.zoomActive}),t.showThumbs!==this.lastEventState.showThumbs&&this.emit("thumbsToggle",{showThumbs:t.showThumbs}),t.showToc!==this.lastEventState.showToc&&this.emit("tocToggle",{showToc:t.showToc}),t.isSingle!==this.lastEventState.isSingle&&this.emit("singlePageModeChange",{isSingle:t.isSingle}),t.orientation!==this.lastEventState.orientation&&this.emit("orientationChange",{orientation:t.orientation}),this.lastEventState=t})}captureEventState(){this.lastEventState={currentPage:this.store.currentPage.value,zoom:this.store.zoomState.value.scale,zoomActive:this.store.zoomState.value.isActive,showThumbs:this.store.showThumbs.value,showToc:this.store.showToc.value,isSingle:this.store.isSingleMode.value,orientation:this.store.orientation.value}}destroy(t=!1){var o,r;const s=this.hasActiveSession||!!this.initAbortController||!!this.pageFlipAdapter||!!this.layoutManager||!!this.interactionManager||!!this.pdfRenderer;this.initGeneration++,(o=this.initAbortController)==null||o.abort(),this.initAbortController=null,this.initializationTimer&&(clearTimeout(this.initializationTimer),this.initializationTimer=null),this.pageFlipAdapter&&this.pageFlipAdapter.destroy(),this.layoutManager&&this.layoutManager.destroy(),this.interactionManager&&this.interactionManager.destroy(),this.teardownQualityLoading(),(r=this.pdfLazyStop)==null||r.call(this),this.pdfLazyStop=null,this.pdfPageRequests.clear(),this.pdfRenderedPages.clear(),this.pdfRenderedSources.clear(),this.pdfSourcePageCount=0,this.pdfRenderer&&this.pdfRenderer.destroy(),this.pageFlipAdapter=null,this.layoutManager=null,this.interactionManager=null,this.pdfRenderer=null,this.eventsReady=!1,this.hasActiveSession=!1,this.store.reset(),!t&&this.container&&(this.container.innerHTML=""),s&&this.emit("destroy",void 0)}createAbortError(){const t=new Error("Flipbook initialization was aborted.");return t.name="AbortError",t}on(t,s){const o=this.listeners[t]??new Set;return o.add(s),this.listeners[t]=o,()=>this.off(t,s)}off(t,s){var o;(o=this.listeners[t])==null||o.delete(s)}emit(t,s){var o;(o=this.listeners[t])==null||o.forEach(r=>{r(s)})}};v(Pt,"DEFAULT_PAGE_VIEWPORT",{width:420,height:594});let bt=Pt;const Ae=globalThis,Ee=Ae.FlipbookEngine||{};return Ee.FlipbookEngine=bt,Ae.FlipbookEngine=Ee,x.FlipbookEngine=bt,x.isA3Landscape=Ce,x.isFlipbookPageAsset=Se,x.normalizeFlipbookPages=ke,x.normalizeFlipbookToc=Bt,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"}),x}({},pdfjsLib);
193
+ */const Ee=class Ee{constructor(e,i={}){b(this,"container",null);b(this,"options");b(this,"store",Nt());b(this,"pageFlipAdapter",null);b(this,"layoutManager",null);b(this,"interactionManager",null);b(this,"pdfRenderer",null);b(this,"listeners",{});b(this,"initializationTimer",null);b(this,"initGeneration",0);b(this,"initAbortController",null);b(this,"eventsReady",!1);b(this,"lastEventState",{currentPage:0,zoom:1,zoomActive:!1,showThumbs:!1,showToc:!1,isSingle:!1,orientation:""});b(this,"eventSyncStop",null);b(this,"qualityObserver",null);b(this,"pdfLazyStop",null);b(this,"hasActiveSession",!1);b(this,"pdfPageRequests",new Map);b(this,"pdfRenderedPages",new Set);b(this,"pdfRenderedSources",new Map);b(this,"pdfSourcePageCount",0);b(this,"deepLinkListener",null);b(this,"pluginRegistry",new jt);this.selector=e,this.options={allowDownload:!0,showThumbs:!1,primaryColor:"#7367f0",theme:"auto",soundUrl:"https://flipbookengine.com/Content/page-flip.mp3",autoPlayInterval:3e3,pdfRenderScale:1.5,pdfRenderQuality:.85,pdfRenderFormat:"image/webp",pdfRenderConcurrency:3,pdfRenderCacheSize:32,pdfPageMode:"auto",deepLink:!1,...i},this.setupEventSync(),(i.plugins??[]).forEach(n=>this.installPlugin(n))}async init(e,i){if(typeof this.selector=="string"?this.container=document.querySelector(this.selector):this.container=this.selector,!this.container)return;this.eventsReady=!1,this.destroy(!0),this.setupDeepLinkListener();const n=this.initGeneration,r=new AbortController;this.initAbortController=r;let a=[],h={...Ee.DEFAULT_PAGE_VIEWPORT};if(i&&i.length>0){if(r.signal.aborted)return;const m=i.filter(zt);a=Ft(m);const y=a[0];if(y){const A=await this.loadImageSize(y.low||y.normal);if(A){const W=(y.cropMode!=="full"?A.width/2:A.width)/A.height,q=420;h=W>=1?{width:Math.round(q*W),height:q}:{width:q,height:Math.round(q/W)}}}}else if(e){if(r.signal.aborted)return;let m="load";try{this.pdfRenderer=new es({scale:this.options.pdfRenderScale,quality:this.options.pdfRenderQuality,format:this.options.pdfRenderFormat,concurrency:this.options.pdfRenderConcurrency,cacheSize:this.options.pdfRenderCacheSize,workerSrc:this.options.pdfWorkerSrc}),this.emit("progress",{phase:"loading",completed:0,total:0});const y=await this.pdfRenderer.loadDocument(e,r.signal);m="render",this.emit("progress",{phase:"loading",completed:1,total:y});const A=await this.pdfRenderer.getPageLayouts(this.options.pdfPageMode);h=A.length?await this.pdfRenderer.calculateViewportDimensions(420,A[0]):await this.pdfRenderer.calculateViewportDimensions(),a=A.length?this.createPdfPlaceholders(A):Array.from({length:y},(U,W)=>this.createPdfPlaceholder(W+1)),this.pdfSourcePageCount=y}catch(y){r.signal.aborted||(console.error("PDF load failed:",y),this.emit("error",{code:m==="load"?"PDF_LOAD_FAILED":"PDF_RENDER_FAILED",message:y instanceof Error?y.message:"Unable to load PDF.",cause:y}));return}}if(r.signal.aborted||n!==this.initGeneration||!a.length)return;this.store.init(this.options,a.length,a,!!e,!(i!=null&&i.length)&&!!e),this.applyInitialDeepLink(),Ot(this.container,this.options),this.container.innerHTML="";let u,w,x;const P={current:null},z={current:null},k=_i({pageFlipAdapterRef:P,interactionManagerRef:z,bookWrapperRef:m=>u=m,bookSizerRef:m=>w=m,bookContainerRef:m=>x=m,className:this.options.className,store:this.store,pluginRegistry:this.pluginRegistry,onToggleFullscreen:()=>this.toggleFullscreen(),onDownload:()=>{e&&(this.options.onDownload?this.options.onDownload(e):window.open(e,"_blank"))},onShare:()=>{this.sharePage().then(m=>{var y,A;return(A=(y=this.options).onShare)==null?void 0:A.call(y,m)}).catch(m=>{console.warn("Share err:",m)})},onToggleBookmark:()=>this.toggleBookmark(),onToggleNotes:()=>{this.store.showNotes.value=!this.store.showNotes.value},onSaveNote:m=>this.setNote(this.getCurrentPage(),m),onClearNote:()=>this.clearNote(this.getCurrentPage()),onCloseNotes:()=>{this.store.showNotes.value=!1},onSearch:(m,y)=>{this.search(m,y)},onClearSearch:()=>this.clearSearch(),onCloseSearch:()=>{this.store.showSearch.value=!1},onSelectSearchResult:m=>{this.goToPage(m),this.store.showSearch.value=!1},onHotspotActivate:m=>this.activateHotspot(m.id),onHotspotClose:()=>this.closeHotspot(),onAnnotationActivate:m=>this.activateAnnotation(m.id),onAnnotationClose:()=>this.closeAnnotation()});this.container.appendChild(k),this.setupQualityLoading(),this.layoutManager=new Zi(h,this.store),this.layoutManager.onResizeCallback=()=>{this.pageFlipAdapter&&this.pageFlipAdapter.update()},this.layoutManager.init(u,w),this.pageFlipAdapter=new Vi(x,this.options,this.store),P.current=this.pageFlipAdapter,await new Promise(m=>{const y=()=>{r.signal.removeEventListener("abort",y),m()};r.signal.addEventListener("abort",y,{once:!0}),this.initializationTimer=setTimeout(async()=>{if(this.initializationTimer=null,r.signal.removeEventListener("abort",y),r.signal.aborted||n!==this.initGeneration||!this.pageFlipAdapter){m();return}if(this.pageFlipAdapter.init(h.width,h.height),this.interactionManager=new Xi(u,this.pageFlipAdapter,this.store),this.interactionManager.init(),z.current=this.interactionManager,this.setupPdfLazyLoading(),this.pdfRenderer&&e)try{await this.renderPdfPage(1,r.signal)}catch{m();return}if(r.signal.aborted||n!==this.initGeneration){m();return}this.eventsReady=!0,this.captureEventState(),this.hasActiveSession=!0,this.emit("init",{totalPages:a.length}),m()},10)}),this.initAbortController===r&&(this.initAbortController=null)}createPdfPlaceholder(e){const i="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";return{index:e-1,assetId:"pdf-page-"+e+"-full",pageNumber:e,sourcePageNumber:e,cropMode:"full",normal:i,low:i,thumb:i}}createPdfPlaceholders(e){const i="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",n=[];return e.forEach((r,a)=>{const h=a+1;(r.split?["left","right"]:["full"]).forEach(w=>{const x=n.length+1;n.push({index:n.length,assetId:`pdf-page-${h}-${w}`,pageNumber:x,sourcePageNumber:h,cropMode:w,normal:i,low:i,thumb:i})})}),n}renderPdfPage(e,i){const n=this.pdfRenderer,r=this.initGeneration;if(!n)return Promise.resolve("");const a=this.pdfPageRequests.get(e);if(a)return a;if(this.pdfRenderedPages.has(e)){const u=this.pdfRenderedSources.get(e);return u&&this.hydratePdfImages(e,u),Promise.resolve(u||"")}const h=n.renderPageToDataUrl(e,i).then(u=>{if(r!==this.initGeneration||i!=null&&i.aborted)throw this.createAbortError();if(!u)throw new Error("PDF page "+e+" produced no image.");return this.pdfRenderedPages.add(e),this.pdfRenderedSources.set(e,u),this.hydratePdfImages(e,u),this.emit("progress",{phase:"rendering",completed:this.pdfRenderedPages.size,total:this.pdfSourcePageCount||this.store.totalPages.value}),u}).catch(u=>{throw r!==this.initGeneration&&(u==null?void 0:u.name)!=="AbortError"?this.createAbortError():((u==null?void 0:u.name)==="AbortError"||this.emit("error",{code:"PDF_RENDER_FAILED",message:u instanceof Error?u.message:"Unable to render PDF page.",cause:u}),u)}).finally(()=>{this.pdfPageRequests.get(e)===h&&this.pdfPageRequests.delete(e)});return this.pdfPageRequests.set(e,h),h}hydratePdfImages(e,i){var n;(n=this.container)==null||n.querySelectorAll("img").forEach(r=>{r.dataset.pdfPage===String(e)&&(r.src=i,delete r.dataset.pdfPage)})}setupPdfLazyLoading(){var e;(e=this.pdfLazyStop)==null||e.call(this),this.pdfLazyStop=null,this.pdfRenderer&&(this.pdfLazyStop=X(()=>{const i=this.store.pages.value[this.store.currentPage.value],n=this.store.pages.value[this.store.currentPage.value+1];new Set([(i==null?void 0:i.sourcePageNumber)??(i==null?void 0:i.pageNumber),(n==null?void 0:n.sourcePageNumber)??(n==null?void 0:n.pageNumber)]).forEach(a=>{a&&this.renderPdfPage(a).catch(()=>{})})}))}loadImageSize(e){return new Promise(i=>{const n=new Image;n.onload=()=>i({width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}),n.onerror=()=>i(null),n.src=e})}goToPage(e){const i=Math.max(0,this.store.totalPages.value-1);this.store.currentPage.value=Math.max(0,Math.min(i,Math.trunc(e)))}getTotalPages(){return this.store.totalPages.value}getCurrentPage(){return this.store.currentPage.value}getToc(){const e=i=>({...i,...i.children?{children:i.children.map(e)}:{}});return this.store.toc.value.map(e)}setToc(e,i=this.store.showToc.value){this.store.toc.value=Ae(e,this.store.totalPages.value),this.store.showToc.value=!!i&&this.store.toc.value.length>0}installPlugin(e){return this.pluginRegistry.install(this,e),this}uninstallPlugin(e){return this.pluginRegistry.uninstall(e)}getPluginNames(){return this.pluginRegistry.getPluginNames()}callPluginApi(e,i,...n){return this.pluginRegistry.callApi(e,i,...n)}getPluginRegistry(){return this.pluginRegistry}getBookmarkedPages(){return Array.from(this.store.bookmarkedPages.value).sort((e,i)=>e-i)}isBookmarked(e=this.getCurrentPage()){return this.store.bookmarkedPages.value.has(Math.trunc(e))}setBookmark(e,i=!0){if(this.store.totalPages.value===0||!Number.isFinite(e))return;const n=Math.max(0,Math.min(this.store.totalPages.value-1,Math.trunc(e))),r=this.store.bookmarkedPages.value;if(r.has(n)===i)return;const a=new Set(r);i?a.add(n):a.delete(n),this.store.bookmarkedPages.value=a,this.emit("bookmarkChange",{pageIndex:n,pageNumber:n+1,bookmarked:i})}toggleBookmark(e=this.getCurrentPage()){this.setBookmark(e,!this.isBookmarked(e))}getNotes(){return Object.fromEntries(this.store.pageNotes.value)}getNote(e=this.getCurrentPage()){return this.store.pageNotes.value.get(Math.trunc(e))}setNote(e,i){if(this.store.totalPages.value===0||!Number.isFinite(e))return;const n=Math.max(0,Math.min(this.store.totalPages.value-1,Math.trunc(e))),r=String(i??"").trim();if(this.store.pageNotes.value.get(n)===(r||void 0))return;const h=new Map(this.store.pageNotes.value);r?h.set(n,r):h.delete(n),this.store.pageNotes.value=h,this.emit("noteChange",{pageIndex:n,pageNumber:n+1,note:r||null})}clearNote(e=this.getCurrentPage()){this.setNote(e,"")}async search(e,i={}){const n=String(e??"").trim();if(!n||!this.pdfRenderer||!this.store.isPdfMode.value)return this.store.searchQuery.value=n,this.store.searchResults.value=[],this.emit("searchChange",{query:n,results:[]}),[];const r=await this.pdfRenderer.searchText(n,i),a=[];r.forEach(u=>{this.store.pages.value.forEach(w=>{var P;if((w.sourcePageNumber??w.pageNumber)!==u.sourcePageNumber)return;const x=this.mapSearchHighlights(u.highlights,w.cropMode);(P=u.highlights)!=null&&P.length&&!x.length||a.push({pageIndex:w.index,pageNumber:w.pageNumber,sourcePageNumber:u.sourcePageNumber,matches:u.matches,snippet:u.snippet,...u.highlights?{highlights:x}:{}})})});const h=Number.isFinite(i.maxResults)?Math.max(1,Math.trunc(i.maxResults)):100;return this.store.searchQuery.value=n,this.store.searchResults.value=a.slice(0,h),this.emit("searchChange",{query:n,results:this.store.searchResults.value}),this.store.searchResults.value}mapSearchHighlights(e,i){if(!(e!=null&&e.length)||i==="full")return e??[];const n=i==="right"?.5:0;return e.flatMap(r=>{const a=Math.max(n,r.x),h=Math.min(n+.5,r.x+r.width);return h<=a?[]:[{x:Math.max(0,Math.min(1,(a-n)*2)),y:Math.max(0,Math.min(1,r.y)),width:Math.max(0,Math.min(1,(h-a)*2)),height:Math.max(0,Math.min(1,r.height))}]})}clearSearch(){this.store.searchQuery.value="",this.store.searchResults.value=[],this.emit("searchChange",{query:"",results:[]})}getSearchResults(){return this.store.searchResults.value.slice()}getHotspots(e=this.getCurrentPage()){return this.store.hotspots.value.filter(i=>i.pageIndex===e)}activateHotspot(e){const i=this.store.hotspots.value.find(n=>n.id===e);i&&(this.store.activeHotspotId.value=i.id,this.emit("hotspotActivate",{hotspot:i,pageIndex:i.pageIndex}))}closeHotspot(){this.store.activeHotspotId.value=null}getAnnotations(e=this.getCurrentPage()){return this.store.annotations.value.filter(i=>i.pageIndex===e)}activateAnnotation(e){const i=this.store.annotations.value.find(n=>n.id===e);i&&(this.store.activeAnnotationId.value=i.id,this.emit("annotationActivate",{annotation:i,pageIndex:i.pageIndex}))}closeAnnotation(){this.store.activeAnnotationId.value=null}getZoom(){return this.store.zoomState.value.scale}setZoom(e){const i=Number.isFinite(e)?e:1,n=Math.max(.5,Math.min(5,i));this.store.zoomState.value={...this.store.zoomState.value,scale:n,isActive:n>1,...n<=1?{translateX:0,translateY:0}:{}},this.store.isZoomed.value=n>1}nextPage(){this.pageFlipAdapter&&this.pageFlipAdapter.turnToNextPage()}toggleFullscreen(){var i,n;const e=this.container;e&&(document.fullscreenElement?(n=document.exitFullscreen)==null||n.call(document).catch(r=>console.warn("Exit fullscreen err:",r)):(i=e.requestFullscreen)==null||i.call(e).catch(r=>console.warn("Fullscreen err:",r)))}setLocale(e,i){const n=i?{...this.options.messages,[e]:i[e]??i}:this.options.messages;this.options={...this.options,locale:e,messages:n},this.store.locale.value=e,n&&(this.store.messages.value=n)}prevPage(){this.pageFlipAdapter&&this.pageFlipAdapter.turnToPrevPage()}setSingleMode(e){this.store.isSingleMode.value=e,e&&this.pdfRenderer&&setTimeout(()=>{const i=this.store.pages.value[this.store.currentPage.value],n=(i==null?void 0:i.sourcePageNumber)??(i==null?void 0:i.pageNumber);n&&this.renderPdfPage(n).catch(()=>{})},0)}updateOptions(e){const i=e.deepLink!==void 0&&e.deepLink!==this.options.deepLink;this.options={...this.options,...e},i&&(this.options.deepLink?this.setupDeepLinkListener():this.teardownDeepLinkListener()),e.theme!==void 0&&(this.store.themeMode.value=e.theme),e.primaryColor!==void 0&&(this.store.primaryColor.value=e.primaryColor),e.showThumbs!==void 0&&(this.store.showThumbs.value=e.showThumbs),e.showToc!==void 0&&(this.store.showToc.value=e.showToc),e.toc!==void 0&&(this.store.toc.value=Ae(e.toc,this.store.totalPages.value)),e.showArrows!==void 0&&(this.store.showArrows.value=e.showArrows),e.allowDownload!==void 0&&(this.store.allowDownload.value=e.allowDownload),e.whiteLabel!==void 0&&(this.store.whiteLabel.value=e.whiteLabel),e.soundEnabled!==void 0&&(this.store.soundEnabled.value=e.soundEnabled),e.locale!==void 0&&(this.store.locale.value=e.locale),e.messages!==void 0&&(this.store.messages.value=e.messages),e.singleMode!==void 0&&(this.store.isSingleMode.value=e.singleMode),e.isSingleMode!==void 0&&(this.store.isSingleMode.value=e.isSingleMode),e.autoPlay!==void 0&&(this.store.isAutoPlaying.value=e.autoPlay),e.autoPlayInterval!==void 0&&(this.store.autoPlayInterval.value=e.autoPlayInterval),e.bookmarks!==void 0&&(this.store.bookmarkedPages.value=new Set(e.bookmarks.map(n=>Math.trunc(n)).filter(n=>Number.isInteger(n)&&n>=0&&n<this.store.totalPages.value))),e.notes!==void 0&&(this.store.pageNotes.value=new Map(Object.entries(e.notes).map(([n,r])=>[Math.trunc(Number(n)),String(r).trim()]).filter(([n,r])=>Number.isInteger(n)&&n>=0&&n<this.store.totalPages.value&&r.length>0))),e.hotspots!==void 0&&(this.store.hotspots.value=e.hotspots),e.annotations!==void 0&&(this.store.annotations.value=e.annotations),this.container&&Ot(this.container,this.options)}setupDeepLinkListener(){this.teardownDeepLinkListener(),!(!this.options.deepLink||typeof window>"u")&&(this.deepLinkListener=()=>{if(!this.eventsReady||this.store.totalPages.value===0)return;const e=this.readDeepLinkPage();e!==null&&e!==this.store.currentPage.value&&this.goToPage(e)},window.addEventListener("popstate",this.deepLinkListener),window.addEventListener("hashchange",this.deepLinkListener))}teardownDeepLinkListener(){!this.deepLinkListener||typeof window>"u"||(window.removeEventListener("popstate",this.deepLinkListener),window.removeEventListener("hashchange",this.deepLinkListener),this.deepLinkListener=null)}readDeepLinkPage(e=typeof window>"u"?"":window.location.href){var i;if(!e||this.store.totalPages.value===0)return null;try{const n=new URL(e,typeof document>"u"?void 0:document.baseURI),r=(i=n.hash.match(/(?:^#|&)page=(\d+)/i))==null?void 0:i[1],a=n.searchParams.get("page")??r;if(a==null)return 0;const h=Number(a);return!Number.isInteger(h)||h<1?null:Math.min(h-1,this.store.totalPages.value-1)}catch{return null}}applyInitialDeepLink(){if(!this.options.deepLink)return;const e=this.readDeepLinkPage();e!==null&&(this.store.currentPage.value=e)}updateDeepLink(e){if(!this.options.deepLink||typeof window>"u"||this.store.totalPages.value===0)return;const i=Math.max(0,Math.min(this.store.totalPages.value-1,Math.trunc(e))),n=i+1;try{const r=new URL(window.location.href);r.searchParams.set("page",String(n));const a=r.toString();a!==window.location.href&&window.history.replaceState(window.history.state,"",a),this.emit("deepLinkChange",{pageIndex:i,pageNumber:n,url:a})}catch{}}getPageUrl(e=this.getCurrentPage()){if(typeof window>"u")return"";const i=this.getTotalPages(),n=i>0?Math.max(0,Math.min(i-1,Math.trunc(e))):Math.max(0,Math.trunc(e)),r=new URL(window.location.href);return r.searchParams.set("page",String(n+1)),r.toString()}async sharePage(e=this.getCurrentPage()){var n;const i=this.getPageUrl(e);return typeof navigator<"u"&&typeof navigator.share=="function"?await navigator.share({title:typeof document>"u"?void 0:document.title,url:i}):typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)&&await navigator.clipboard.writeText(i),i}connectEmbed(e={}){return new Gt(this,e).connect()}async setPages(e,i){if(!(e!=null&&e.length)){i&&await this.init(i);return}await this.init(i||"",e)}setupQualityLoading(){var r;if(this.teardownQualityLoading(),!this.container)return;const e=Array.from(this.container.querySelectorAll("img[data-src], img[data-pdf-page]")),i=a=>{const h=Number(a.dataset.pdfPage);if(Number.isInteger(h)&&h>0){this.renderPdfPage(h).catch(()=>{});return}const u=a.dataset.src;u&&(a.src=u,delete a.dataset.src)},n=(r=this.container.ownerDocument.defaultView)==null?void 0:r.IntersectionObserver;if(!n){const a=new Set;e.forEach(h=>{const u=Number(h.dataset.pdfPage);Number.isInteger(u)&&u>0?a.size<2&&(a.add(u),i(h)):i(h)});return}this.qualityObserver=new n(a=>{a.forEach(h=>{var u;h.isIntersecting&&(i(h.target),(u=this.qualityObserver)==null||u.unobserve(h.target))})},{root:this.container,rootMargin:"240px"}),e.forEach(a=>{var h;return(h=this.qualityObserver)==null?void 0:h.observe(a)})}teardownQualityLoading(){var e;(e=this.qualityObserver)==null||e.disconnect(),this.qualityObserver=null}setupEventSync(){this.eventSyncStop=X(()=>{const e={currentPage:this.store.currentPage.value,zoom:this.store.zoomState.value.scale,zoomActive:this.store.zoomState.value.isActive,showThumbs:this.store.showThumbs.value,showToc:this.store.showToc.value,isSingle:this.store.isSingleMode.value,orientation:this.store.orientation.value};if(!this.eventsReady){this.lastEventState=e;return}e.currentPage!==this.lastEventState.currentPage&&(this.emit("pageChange",{currentPage:e.currentPage,pageNumber:e.currentPage+1,totalPages:this.store.totalPages.value,isSingle:e.isSingle}),this.updateDeepLink(e.currentPage)),(e.zoom!==this.lastEventState.zoom||e.zoomActive!==this.lastEventState.zoomActive)&&this.emit("zoomChange",{zoom:e.zoom,isActive:e.zoomActive}),e.showThumbs!==this.lastEventState.showThumbs&&this.emit("thumbsToggle",{showThumbs:e.showThumbs}),e.showToc!==this.lastEventState.showToc&&this.emit("tocToggle",{showToc:e.showToc}),e.isSingle!==this.lastEventState.isSingle&&this.emit("singlePageModeChange",{isSingle:e.isSingle}),e.orientation!==this.lastEventState.orientation&&this.emit("orientationChange",{orientation:e.orientation}),this.lastEventState=e})}captureEventState(){this.lastEventState={currentPage:this.store.currentPage.value,zoom:this.store.zoomState.value.scale,zoomActive:this.store.zoomState.value.isActive,showThumbs:this.store.showThumbs.value,showToc:this.store.showToc.value,isSingle:this.store.isSingleMode.value,orientation:this.store.orientation.value}}destroy(e=!1){var n,r;const i=this.hasActiveSession||!!this.initAbortController||!!this.pageFlipAdapter||!!this.layoutManager||!!this.interactionManager||!!this.pdfRenderer;this.initGeneration++,this.teardownDeepLinkListener(),(n=this.initAbortController)==null||n.abort(),this.initAbortController=null,this.initializationTimer&&(clearTimeout(this.initializationTimer),this.initializationTimer=null),this.pageFlipAdapter&&this.pageFlipAdapter.destroy(),this.layoutManager&&this.layoutManager.destroy(),this.interactionManager&&this.interactionManager.destroy(),this.teardownQualityLoading(),(r=this.pdfLazyStop)==null||r.call(this),this.pdfLazyStop=null,this.pdfPageRequests.clear(),this.pdfRenderedPages.clear(),this.pdfRenderedSources.clear(),this.pdfSourcePageCount=0,this.pdfRenderer&&this.pdfRenderer.destroy(),this.pageFlipAdapter=null,this.layoutManager=null,this.interactionManager=null,this.pdfRenderer=null,this.eventsReady=!1,this.hasActiveSession=!1,this.store.reset(),!e&&this.container&&(this.container.innerHTML=""),i&&this.emit("destroy",void 0),e||this.pluginRegistry.clear()}createAbortError(){const e=new Error("Flipbook initialization was aborted.");return e.name="AbortError",e}on(e,i){const n=this.listeners[e]??new Set;return n.add(i),this.listeners[e]=n,()=>this.off(e,i)}off(e,i){var n;(n=this.listeners[e])==null||n.delete(i)}emit(e,i){var n;(n=this.listeners[e])==null||n.forEach(r=>{r(i)})}};b(Ee,"DEFAULT_PAGE_VIEWPORT",{width:420,height:594});let Me=Ee;const qt=globalThis,Vt=qt.FlipbookEngine||{};return Vt.FlipbookEngine=Me,qt.FlipbookEngine=Vt,E.FlipbookEmbedBridge=Gt,E.FlipbookEngine=Me,E.FlipbookPluginRegistry=jt,E.createFlipbookEmbedController=ts,E.isA3Landscape=Bt,E.isFlipbookPageAsset=zt,E.normalizeFlipbookPages=Ft,E.normalizeFlipbookToc=Ae,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"}),E}({},pdfjsLib);
185
194
  //# sourceMappingURL=flipbook-engine.iife.js.map