@readium/navigator-html-injectables 2.3.1-alpha.1 → 2.3.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2138,7 +2138,7 @@ function xe(r, t, e) {
2138
2138
  function I(r, t, e) {
2139
2139
  return Math.abs(r - t) <= e;
2140
2140
  }
2141
- const gt = typeof window.CSSTransformValue < "u";
2141
+ const gt = () => typeof window.CSSTransformValue < "u";
2142
2142
  function Ut(r) {
2143
2143
  const t = {}, e = r.document.documentElement.style;
2144
2144
  for (const i in r.document.documentElement.style)
@@ -2720,7 +2720,7 @@ const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
2720
2720
  if (this.snappingCancelled) return;
2721
2721
  f || (f = b);
2722
2722
  const x = b - f, B = m(this.overscroll, 0, x, w), q = m(i, u, x, w);
2723
- s.scrollLeft = q, this.overscroll !== 0 && (gt ? s.attributeStyleMap.set("transform", new CSSTransformValue([
2723
+ s.scrollLeft = q, this.overscroll !== 0 && (gt() ? s.attributeStyleMap.set("transform", new CSSTransformValue([
2724
2724
  new CSSTranslate(CSS.px(-B), CSS.px(0), CSS.px(0))
2725
2725
  ])) : s.style.transform = `translate3d(${-B}px, 0px, 0px)`), x < w ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, e || this.reportProgress());
2726
2726
  };
@@ -2764,9 +2764,9 @@ const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
2764
2764
  if (this.touchState === 0) return;
2765
2765
  this.touchState === 1 && (this.touchState = 2, C(this.wnd)), this.endingX = t.touches[0].clientX;
2766
2766
  const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
2767
- i < 0 ? (this.overscroll = i, gt ? this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
2767
+ i < 0 ? (this.overscroll = i, gt() ? this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
2768
2768
  new CSSTranslate(CSS.px(-i), CSS.px(0), CSS.px(0))
2769
- ])) : this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, gt ? this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
2769
+ ])) : this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, gt() ? this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
2770
2770
  new CSSTranslate(CSS.px(-i), CSS.px(0), CSS.px(0))
2771
2771
  ])) : this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + e);
2772
2772
  }
@@ -3628,7 +3628,7 @@ const tt = class tt extends X {
3628
3628
  ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
3629
3629
  value: {
3630
3630
  name: "readium-ts-toolkit",
3631
- version: "2.3.1-alpha.1",
3631
+ version: "2.3.1-alpha.2",
3632
3632
  hasFeature: (s, n = "") => {
3633
3633
  switch (s) {
3634
3634
  case "dom-manipulation":
@@ -1,4 +1,4 @@
1
- (function(A,K){typeof exports=="object"&&typeof module<"u"?K(exports):typeof define=="function"&&define.amd?define(["exports"],K):(A=typeof globalThis<"u"?globalThis:A||self,K(A["navigator-html-injectables"]={}))})(this,(function(A){"use strict";const K=Math.pow(2,32),Ve=()=>Math.round(Math.random()*K).toString(36),qe=()=>`${Math.round(performance.now())}-${Ve()}-${Ve()}`,V=1;class $e{constructor(e){this.destination=null,this.registrar=new Map,this.origin="",this.channelId="",this.receiver=this.receive.bind(this),this.preLog=[],this.wnd=e,e.addEventListener("message",this.receiver)}receive(e){if(e.source===null)throw Error("Event source is null");if(typeof e.data!="object")return;const t=e.data;if(!(!("_readium"in t)||!t._readium||t._readium<=0)){if(t.key==="_ping"){if(!this.destination){if(this.destination=e.source,this.origin=e.origin,this.channelId=t._channel,t._readium!==V){t._readium>V?this.send("error",`received comms version ${t._readium} higher than ${V}`):this.send("error",`received comms version ${t._readium} lower than ${V}`),this.destination=null,this.origin="",this.channelId="";return}this.send("_pong",void 0),this.preLog.forEach(i=>this.send("log",i)),this.preLog=[]}return}else if(this.channelId){if(t._channel!==this.channelId||e.origin!==this.origin)return}else return;this.handle(t)}}handle(e){const t=this.registrar.get(e.key);if(!t||t.length===0){e.strict&&this.send("_unhandled",e);return}t.forEach(i=>i.cb(e.data,n=>{this.send("_ack",n,e.id)}))}register(e,t,i){Array.isArray(e)||(e=[e]),e.forEach(n=>{const o=this.registrar.get(n);if(o&&o.length>=0){if(o.find(a=>a.module===t))throw new Error(`Trying to register another callback for combination of event ${n} and module ${t}`);o.push({cb:i,module:t}),this.registrar.set(n,o)}else this.registrar.set(n,[{cb:i,module:t}])})}unregister(e,t){Array.isArray(e)||(e=[e]),e.forEach(i=>{const n=this.registrar.get(i);!n||n.length===0||n.splice(n.findIndex(o=>o.module===t),1)})}unregisterAll(e){this.registrar.forEach((t,i)=>this.registrar.set(i,t.filter(n=>n.module!==e)))}log(...e){this.destination?this.send("log",e):this.preLog.push(e)}get ready(){return!!this.destination}destroy(){this.destination=null,this.channelId="",this.preLog=[],this.registrar.clear(),this.wnd.removeEventListener("message",this.receiver)}send(e,t,i=void 0,n=[]){if(!this.destination)throw Error("Attempted to send comms message before destination has been initialized");const o={_readium:V,_channel:this.channelId,id:i??qe(),key:e,data:t};try{this.destination.postMessage(o,{targetOrigin:this.origin,transfer:n})}catch(s){if(n.length>0)throw s;this.destination.postMessage(o,this.origin,n)}}}const b=class b{constructor(e){this.uri=e}static deserialize(e){if(!(!e||typeof e!="string"))return new b(e)}serialize(){return this.uri}get isWCAGLevelA(){return this===b.EPUB_A11Y_10_WCAG_20_A||this===b.EPUB_A11Y_11_WCAG_20_A||this===b.EPUB_A11Y_11_WCAG_21_A||this===b.EPUB_A11Y_11_WCAG_22_A}get isWCAGLevelAA(){return this===b.EPUB_A11Y_10_WCAG_20_AA||this===b.EPUB_A11Y_11_WCAG_20_AA||this===b.EPUB_A11Y_11_WCAG_21_AA||this===b.EPUB_A11Y_11_WCAG_22_AA}get isWCAGLevelAAA(){return this===b.EPUB_A11Y_10_WCAG_20_AAA||this===b.EPUB_A11Y_11_WCAG_20_AAA||this===b.EPUB_A11Y_11_WCAG_21_AAA||this===b.EPUB_A11Y_11_WCAG_22_AAA}};b.EPUB_A11Y_10_WCAG_20_A=new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"),b.EPUB_A11Y_10_WCAG_20_AA=new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"),b.EPUB_A11Y_10_WCAG_20_AAA=new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"),b.EPUB_A11Y_11_WCAG_20_A=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"),b.EPUB_A11Y_11_WCAG_20_AA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"),b.EPUB_A11Y_11_WCAG_20_AAA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"),b.EPUB_A11Y_11_WCAG_21_A=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"),b.EPUB_A11Y_11_WCAG_21_AA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"),b.EPUB_A11Y_11_WCAG_21_AAA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"),b.EPUB_A11Y_11_WCAG_22_A=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"),b.EPUB_A11Y_11_WCAG_22_AA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"),b.EPUB_A11Y_11_WCAG_22_AAA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");let je=b;const w=class w{constructor(e){this.value=e}static deserialize(e){if(!(!e||typeof e!="string"))return new w(e)}serialize(){return this.value}};w.AUDITORY=new w("auditory"),w.CHART_ON_VISUAL=new w("chartOnVisual"),w.CHEM_ON_VISUAL=new w("chemOnVisual"),w.COLOR_DEPENDENT=new w("colorDependent"),w.DIAGRAM_ON_VISUAL=new w("diagramOnVisual"),w.MATH_ON_VISUAL=new w("mathOnVisual"),w.MUSIC_ON_VISUAL=new w("musicOnVisual"),w.TACTILE=new w("tactile"),w.TEXT_ON_VISUAL=new w("textOnVisual"),w.TEXTUAL=new w("textual"),w.VISUAL=new w("visual");let Xe=w;const P=class P{constructor(e){if(typeof e=="string"){if(!P.VALID_MODES.has(e.toLowerCase()))return;this.value=e.toLowerCase()}else{const t=e.filter(i=>P.VALID_MODES.has(i.toLowerCase()));if(t.length===0)return;this.value=Array.from(new Set(t))}}static deserialize(e){if(!e)return;if(typeof e=="string")return new P(e);if(!Array.isArray(e))return;const t=e.filter(i=>i?P.VALID_MODES.has(i.toLowerCase()):!1);if(t.length!==0)return new P(t)}serialize(){return this.value}};P.VALID_MODES=new Set(["auditory","tactile","textual","visual"]),P.AUDITORY=new P("auditory"),P.TACTILE=new P("tactile"),P.TEXTUAL=new P("textual"),P.VISUAL=new P("visual");let Ye=P;const c=class c{constructor(e){this.value=e}static deserialize(e){if(!(!e||typeof e!="string"))return new c(e)}serialize(){return this.value}};c.NONE=new c("none"),c.ANNOTATIONS=new c("annotations"),c.ARIA=new c("ARIA"),c.INDEX=new c("index"),c.PAGE_BREAK_MARKERS=new c("pageBreakMarkers"),c.PAGE_NAVIGATION=new c("pageNavigation"),c.PRINT_PAGE_NUMBERS=new c("printPageNumbers"),c.READING_ORDER=new c("readingOrder"),c.STRUCTURAL_NAVIGATION=new c("structuralNavigation"),c.TABLE_OF_CONTENTS=new c("tableOfContents"),c.TAGGED_PDF=new c("taggedPDF"),c.ALTERNATIVE_TEXT=new c("alternativeText"),c.AUDIO_DESCRIPTION=new c("audioDescription"),c.CAPTIONS=new c("captions"),c.CLOSED_CAPTIONS=new c("closedCaptions"),c.DESCRIBED_MATH=new c("describedMath"),c.LONG_DESCRIPTION=new c("longDescription"),c.OPEN_CAPTIONS=new c("openCaptions"),c.SIGN_LANGUAGE=new c("signLanguage"),c.TRANSCRIPT=new c("transcript"),c.DISPLAY_TRANSFORMABILITY=new c("displayTransformability"),c.SYNCHRONIZED_AUDIO_TEXT=new c("synchronizedAudioText"),c.TIMING_CONTROL=new c("timingControl"),c.UNLOCKED=new c("unlocked"),c.CHEM_ML=new c("ChemML"),c.LATEX=new c("latex"),c.LATEX_CHEMISTRY=new c("latex-chemistry"),c.MATH_ML=new c("MathML"),c.MATH_ML_CHEMISTRY=new c("MathML-chemistry"),c.TTS_MARKUP=new c("ttsMarkup"),c.HIGH_CONTRAST_AUDIO=new c("highContrastAudio"),c.HIGH_CONTRAST_DISPLAY=new c("highContrastDisplay"),c.LARGE_PRINT=new c("largePrint"),c.BRAILLE=new c("braille"),c.TACTILE_GRAPHIC=new c("tactileGraphic"),c.TACTILE_OBJECT=new c("tactileObject"),c.FULL_RUBY_ANNOTATIONS=new c("fullRubyAnnotations"),c.HORIZONTAL_WRITING=new c("horizontalWriting"),c.RUBY_ANNOTATIONS=new c("rubyAnnotations"),c.VERTICAL_WRITING=new c("verticalWriting"),c.WITH_ADDITIONAL_WORD_SEGMENTATION=new c("withAdditionalWordSegmentation"),c.WITHOUT_ADDITIONAL_WORD_SEGMENTATION=new c("withoutAdditionalWordSegmentation");let Ke=c;const k=class k{constructor(e){this.value=e}static deserialize(e){if(!(!e||typeof e!="string"))return new k(e)}serialize(){return this.value}};k.FLASHING=new k("flashing"),k.NO_FLASHING_HAZARD=new k("noFlashingHazard"),k.UNKNOWN_FLASHING_HAZARD=new k("unknownFlashingHazard"),k.MOTION_SIMULATION=new k("motionSimulation"),k.NO_MOTION_SIMULATION_HAZARD=new k("noMotionSimulationHazard"),k.UNKNOWN_MOTION_SIMULATION_HAZARD=new k("unknownMotionSimulationHazard"),k.SOUND=new k("sound"),k.NO_SOUND_HAZARD=new k("noSoundHazard"),k.UNKNOWN_SOUND_HAZARD=new k("unknownSoundHazard"),k.UNKNOWN=new k("unknown"),k.NONE=new k("none");let Je=k;const S=class S{constructor(e){this.value=e}static deserialize(e){if(!(!e||typeof e!="string"))return new S(e)}serialize(){return this.value}};S.NONE=new S("none"),S.DOCUMENTED=new S("documented"),S.LEGAL=new S("legal"),S.TEMPORARY=new S("temporary"),S.TECHNICAL=new S("technical"),S.EAA_DISPROPORTIONATE_BURDEN=new S("eaa-disproportionate-burden"),S.EAA_FUNDAMENTAL_ALTERATION=new S("eaa-fundamental-alteration"),S.EAA_MICROENTERPRISE=new S("eaa-microenterprise"),S.EAA_TECHNICAL_IMPOSSIBILITY=new S("eaa-technical-impossibility"),S.EAA_TEMPORARY=new S("eaa-temporary");let Ze=S;const Qe=["en","ar","da","fr","it","pt_PT","sv"],Xt={publication:JSON.parse(`{"format":{"audiobook":"Audiobook","audiobookJSON":"Audiobook Manifest","cbz":"Comic Book Archive","divina":"Divina Publication","divinaJSON":"Divina Publication Manifest","epub":"EPUB","lcpa":"LCP Protected Audiobook","lcpdf":"LCP Protected PDF","lcpl":"LCP License Document","pdf":"PDF","rwp":"Readium Web Publication","rwpm":"Readium Web Publication Manifest","zab":"Audiobook Archive","zip":"ZIP Archive"},"kind":{"audiobook_one":"audiobook","audiobook_other":"audiobooks","book_one":"book","book_other":"books","comic_one":"comic","comic_other":"comics","document_one":"document","document_other":"documents"},"metadata":{"accessibility":{"display-guide":{"accessibility-summary":{"no-metadata":"No information is available","publisher-contact":"For more information about the accessibility of this product, please contact the publisher: ","title":"Accessibility summary"},"additional-accessibility-information":{"aria":{"compact":"ARIA roles included","descriptive":"Content is enhanced with ARIA roles to optimize organization and facilitate navigation"},"audio-descriptions":"Audio descriptions","braille":"Braille","color-not-sole-means-of-conveying-information":"Color is not the sole means of conveying information","dyslexia-readability":"Dyslexia readability","full-ruby-annotations":"Full ruby annotations","high-contrast-between-foreground-and-background-audio":"High contrast between foreground and background audio","high-contrast-between-text-and-background":"High contrast between foreground text and background","large-print":"Large print","page-breaks":{"compact":"Page breaks included","descriptive":"Page breaks included from the original print source"},"ruby-annotations":"Some Ruby annotations","sign-language":"Sign language","tactile-graphics":{"compact":"Tactile graphics included","descriptive":"Tactile graphics have been integrated to facilitate access to visual elements for blind people"},"tactile-objects":"Tactile 3D objects","text-to-speech-hinting":"Text-to-speech hinting provided","title":"Additional accessibility information","ultra-high-contrast-between-text-and-background":"Ultra high contrast between text and background","visible-page-numbering":"Visible page numbering","without-background-sounds":"Without background sounds"},"conformance":{"a":{"compact":"This publication meets minimum accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level A standard"},"aa":{"compact":"This publication meets accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AA standard"},"aaa":{"compact":"This publication exceeds accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AAA standard"},"certifier":"The publication was certified by ","certifier-credentials":"The certifier's credential is ","details":{"certification-info":"The publication was certified on ","certifier-report":"For more information refer to the certifier's report","claim":"This publication claims to meet","epub-accessibility-1-0":"EPUB Accessibility 1.0","epub-accessibility-1-1":"EPUB Accessibility 1.1","level-a":"Level A","level-aa":"Level AA","level-aaa":"Level AAA","wcag-2-0":{"compact":"WCAG 2.0","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.0"},"wcag-2-1":{"compact":"WCAG 2.1","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.1"},"wcag-2-2":{"compact":"WCAG 2.2","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.2"}},"details-title":"Detailed conformance information","no":"No information is available","title":"Conformance","unknown-standard":"Conformance to accepted standards for accessibility of this publication cannot be determined"},"hazards":{"flashing":{"compact":"Flashing content","descriptive":"The publication contains flashing content that can cause photosensitive seizures"},"flashing-none":{"compact":"No flashing hazards","descriptive":"The publication does not contain flashing content that can cause photosensitive seizures"},"flashing-unknown":{"compact":"Flashing hazards not known","descriptive":"The presence of flashing content that can cause photosensitive seizures could not be determined"},"motion":{"compact":"Motion simulation","descriptive":"The publication contains motion simulations that can cause motion sickness"},"motion-none":{"compact":"No motion simulation hazards","descriptive":"The publication does not contain motion simulations that can cause motion sickness"},"motion-unknown":{"compact":"Motion simulation hazards not known","descriptive":"The presence of motion simulations that can cause motion sickness could not be determined"},"no-metadata":"No information is available","none":{"compact":"No hazards","descriptive":"The publication contains no hazards"},"sound":{"compact":"Sounds","descriptive":"The publication contains sounds that can cause sensitivity issues"},"sound-none":{"compact":"No sound hazards","descriptive":"The publication does not contain sounds that can cause sensitivity issues"},"sound-unknown":{"compact":"Sound hazards not known","descriptive":"The presence of sounds that can cause sensitivity issues could not be determined"},"title":"Hazards","unknown":"The presence of hazards is unknown"},"legal-considerations":{"exempt":{"compact":"Claims an accessibility exemption in some jurisdictions","descriptive":"This publication claims an accessibility exemption in some jurisdictions"},"no-metadata":"No information is available","title":"Legal considerations"},"navigation":{"index":{"compact":"Index","descriptive":"Index with links to referenced entries"},"no-metadata":"No information is available","page-navigation":{"compact":"Go to page","descriptive":"Page list to go to pages from the print source version"},"structural":{"compact":"Headings","descriptive":"Elements such as headings, tables, etc for structured navigation"},"title":"Navigation","toc":{"compact":"Table of contents","descriptive":"Table of contents to all chapters of the text via links"}},"rich-content":{"accessible-chemistry-as-latex":{"compact":"Chemical formulas in LaTeX","descriptive":"Chemical formulas in accessible format (LaTeX)"},"accessible-chemistry-as-mathml":{"compact":"Chemical formulas in MathML","descriptive":"Chemical formulas in accessible format (MathML)"},"accessible-math-as-latex":{"compact":"Math as LaTeX","descriptive":"Math formulas in accessible format (LaTeX)"},"accessible-math-described":"Text descriptions of math are provided","closed-captions":{"compact":"Videos have closed captions","descriptive":"Videos included in publications have closed captions"},"extended-descriptions":"Information-rich images are described by extended descriptions","math-as-mathml":{"compact":"Math as MathML","descriptive":"Math formulas in accessible format (MathML)"},"open-captions":{"compact":"Videos have open captions","descriptive":"Videos included in publications have open captions"},"title":"Rich content","transcript":"Transcript(s) provided","unknown":"No information is available"},"ways-of-reading":{"nonvisual-reading":{"alt-text":{"compact":"Has alternative text","descriptive":"Has alternative text descriptions for images"},"no-metadata":"No information about nonvisual reading is available","none":{"compact":"Not readable in read aloud or dynamic braille","descriptive":"The content is not readable as read aloud speech or dynamic braille"},"not-fully":{"compact":"Not fully readable in read aloud or dynamic braille","descriptive":"Not all of the content will be readable as read aloud speech or dynamic braille"},"readable":{"compact":"Readable in read aloud or dynamic braille","descriptive":"All content can be read as read aloud speech or dynamic braille"}},"prerecorded-audio":{"complementary":{"compact":"Prerecorded audio clips","descriptive":"Prerecorded audio clips are embedded in the content"},"no-metadata":"No information about prerecorded audio is available","only":{"compact":"Prerecorded audio only","descriptive":"Audiobook with no text alternative"},"synchronized":{"compact":"Prerecorded audio synchronized with text","descriptive":"All the content is available as prerecorded audio synchronized with text"}},"title":"Ways of reading","visual-adjustments":{"modifiable":{"compact":"Appearance can be modified","descriptive":"Appearance of the text and page layout can be modified according to the capabilities of the reading system (font family and font size, spaces between paragraphs, sentences, words, and letters, as well as color of background and text)"},"unknown":"No information about appearance modifiability is available","unmodifiable":{"compact":"Appearance cannot be modified","descriptive":"Text and page layout cannot be modified as the reading experience is close to a print version, but reading systems can still provide zooming options"}}}}},"altIdentifier_one":"alternate identifier","altIdentifier_other":"alternate identifiers","artist_one":"artist","artist_other":"artists","author_one":"author","author_other":"authors","collection_one":"editorial collection","collection_other":"editorial collections","colorist_one":"colorist","colorist_other":"colorists","contributor_one":"contributor","contributor_other":"contributors","description":"description","duration":"duration","editor_one":"editor","editor_other":"editors","identifier_one":"identifier","identifier_other":"identifiers","illustrator_one":"illustrator","illustrator_other":"illustrators","imprint_one":"imprint","imprint_other":"imprints","inker_one":"inker","inker_other":"inkers","language_one":"language","language_other":"languages","letterer_one":"letterer","letterer_other":"letterers","modified":"modification date","narrator_one":"narrator","narrator_other":"narrators","numberOfPages":"print length","penciler_one":"penciler","penciler_other":"pencilers","published":"publication date","publisher_one":"publisher","publisher_other":"publishers","series_one":"series","series_other":"series","subject_one":"subject","subject_other":"subjects","subtitle":"subtitle","title":"title","translator_one":"translator","translator_other":"translators"}}`)},et={fr:()=>Promise.resolve().then(()=>Ii),ar:()=>Promise.resolve().then(()=>zi),da:()=>Promise.resolve().then(()=>Oi),it:()=>Promise.resolve().then(()=>Ri),pt_PT:()=>Promise.resolve().then(()=>Di),sv:()=>Promise.resolve().then(()=>Mi)},tt=Xt?.publication?.metadata?.accessibility?.["display-guide"]||{};class q{constructor(){this.currentLocaleCode="en",this.locale=tt,this.loadedLocales={},this.loadedLocales.en=tt}static getInstance(){return q.instance||(q.instance=new q),q.instance}async loadLocale(e){if(!Qe.includes(e))return console.warn(`Locale '${e}' is not enabled`),!1;if(e in this.loadedLocales)return!0;try{if(!(e in et))return console.warn(`Locale file not found for: ${e}`),!1;const n=(await et[e]()).default?.publication?.metadata?.accessibility?.["display-guide"];return n?(this.loadedLocales[e]=n,!0):(console.warn(`No accessibility strings found in locale ${e}`),!1)}catch(t){return console.warn(`Failed to load locale ${e}:`,t),!1}}registerLocale(e,t){if(!e||typeof e!="string")throw new Error("Locale code must be a non-empty string");this.loadedLocales[e]=t}async setLocale(e){return e in this.loadedLocales||await this.loadLocale(e),e in this.loadedLocales?(this.locale=this.loadedLocales[e],this.currentLocaleCode=e,!0):(console.warn(`Locale '${e}' is not available`),!1)}getCurrentLocale(){return this.currentLocaleCode}getAvailableLocales(){return Qe}getNestedValue(e,t){const i=t.split(".");let n=e;for(const o of i){if(n==null)return;n=n[o]}return n}getString(e){let t=this.getNestedValue(this.locale,e);return t===void 0&&this.currentLocaleCode!=="en"&&(t=this.getNestedValue(this.loadedLocales.en,e)),t!==void 0?typeof t=="string"?{compact:t,descriptive:t}:t:(console.warn(`Missing localization for key: ${e}`),{compact:"",descriptive:""})}}q.getInstance();class we{constructor(e){this.algorithm=e.algorithm,this.compression=e.compression,this.originalLength=e.originalLength,this.profile=e.profile,this.scheme=e.scheme}static deserialize(e){if(e&&e.algorithm)return new we({algorithm:e.algorithm,compression:e.compression,originalLength:e.originalLength,profile:e.profile,scheme:e.scheme})}serialize(){const e={algorithm:this.algorithm};return this.compression!==void 0&&(e.compression=this.compression),this.originalLength!==void 0&&(e.originalLength=this.originalLength),this.profile!==void 0&&(e.profile=this.profile),this.scheme!==void 0&&(e.scheme=this.scheme),e}}class N{constructor(e){this.otherProperties=e}get page(){return this.otherProperties.page}static deserialize(e){if(e)return new N(e)}serialize(){return this.otherProperties}add(e){const t=Object.assign({},this.otherProperties);for(const i in e)t[i]=e[i];return new N(t)}}Object.defineProperty(N.prototype,"encryption",{get:function(){return we.deserialize(this.otherProperties.encrypted)}});function Yt(r){return r&&Array.isArray(r)?r:void 0}function it(r){return r&&typeof r=="string"?[r]:Yt(r)}function nt(r){return typeof r=="string"?new Date(r):void 0}function se(r){return isNaN(r)?void 0:r}function I(r){return se(r)!==void 0&&Math.sign(r)>=0?r:void 0}function Kt(r){const e=new Array;return r.forEach(t=>e.push(t)),e}class l{constructor(e){let t,i,n=e.mediaType.replace(/\s/g,"").split(";");const o=n[0].split("/");if(o.length===2){if(t=o[0].toLowerCase().trim(),i=o[1].toLowerCase().trim(),t.length===0||i.length===0)throw new Error("Invalid media type")}else throw new Error("Invalid media type");const s={};for(let m=1;m<n.length;m++){const y=n[m].split("=");if(y.length===2){const g=y[0].toLocaleLowerCase(),p=g==="charset"?y[1].toUpperCase():y[1];s[g]=p}}const a={},u=Object.keys(s);u.sort((m,y)=>m.localeCompare(y)),u.forEach(m=>a[m]=s[m]);let d="";for(const m in a){const y=a[m];d+=`;${m}=${y}`}const h=`${t}/${i}${d}`,f=a.encoding;this.string=h,this.type=t,this.subtype=i,this.parameters=a,this.encoding=f,this.name=e.name,this.fileExtension=e.fileExtension}static parse(e){return new l(e)}get structuredSyntaxSuffix(){const e=this.subtype.split("+");return e.length>1?`+${e[e.length-1]}`:void 0}get charset(){return this.parameters.charset}contains(e){const t=typeof e=="string"?l.parse({mediaType:e}):e;if(!((this.type==="*"||this.type===t.type)&&(this.subtype==="*"||this.subtype===t.subtype)))return!1;const i=new Set(Object.entries(this.parameters).map(([o,s])=>`${o}=${s}`)),n=new Set(Object.entries(t.parameters).map(([o,s])=>`${o}=${s}`));for(const o of Array.from(i.values()))if(!n.has(o))return!1;return!0}matches(e){const t=typeof e=="string"?l.parse({mediaType:e}):e;return this.contains(t)||t.contains(this)}matchesAny(...e){for(const t of e)if(this.matches(t))return!0;return!1}equals(e){return this.string===e.string}get isZIP(){return this.matchesAny(l.ZIP,l.LCP_PROTECTED_AUDIOBOOK,l.LCP_PROTECTED_PDF)||this.structuredSyntaxSuffix==="+zip"}get isJSON(){return this.matchesAny(l.JSON)||this.structuredSyntaxSuffix==="+json"}get isOPDS(){return this.matchesAny(l.OPDS1,l.OPDS1_ENTRY,l.OPDS2,l.OPDS2_PUBLICATION,l.OPDS_AUTHENTICATION)||this.structuredSyntaxSuffix==="+json"}get isHTML(){return this.matchesAny(l.HTML,l.XHTML)}get isBitmap(){return this.matchesAny(l.BMP,l.GIF,l.JPEG,l.PNG,l.TIFF,l.WEBP)}get isAudio(){return this.type==="audio"}get isVideo(){return this.type==="video"}get isRWPM(){return this.matchesAny(l.READIUM_AUDIOBOOK_MANIFEST,l.DIVINA_MANIFEST,l.READIUM_WEBPUB_MANIFEST)}get isPublication(){return this.matchesAny(l.READIUM_AUDIOBOOK,l.READIUM_AUDIOBOOK_MANIFEST,l.CBZ,l.DIVINA,l.DIVINA_MANIFEST,l.EPUB,l.LCP_PROTECTED_AUDIOBOOK,l.LCP_PROTECTED_PDF,l.LPF,l.PDF,l.W3C_WPUB_MANIFEST,l.READIUM_WEBPUB,l.READIUM_WEBPUB_MANIFEST,l.ZAB)}static get AAC(){return l.parse({mediaType:"audio/aac",fileExtension:"aac"})}static get ACSM(){return l.parse({mediaType:"application/vnd.adobe.adept+xml",name:"Adobe Content Server Message",fileExtension:"acsm"})}static get AIFF(){return l.parse({mediaType:"audio/aiff",fileExtension:"aiff"})}static get AVI(){return l.parse({mediaType:"video/x-msvideo",fileExtension:"avi"})}static get BINARY(){return l.parse({mediaType:"application/octet-stream"})}static get BMP(){return l.parse({mediaType:"image/bmp",fileExtension:"bmp"})}static get CBZ(){return l.parse({mediaType:"application/vnd.comicbook+zip",name:"Comic Book Archive",fileExtension:"cbz"})}static get CSS(){return l.parse({mediaType:"text/css",fileExtension:"css"})}static get DIVINA(){return l.parse({mediaType:"application/divina+zip",name:"Digital Visual Narratives",fileExtension:"divina"})}static get DIVINA_MANIFEST(){return l.parse({mediaType:"application/divina+json",name:"Digital Visual Narratives",fileExtension:"json"})}static get EPUB(){return l.parse({mediaType:"application/epub+zip",name:"EPUB",fileExtension:"epub"})}static get GIF(){return l.parse({mediaType:"image/gif",fileExtension:"gif"})}static get GZ(){return l.parse({mediaType:"application/gzip",fileExtension:"gz"})}static get HTML(){return l.parse({mediaType:"text/html",fileExtension:"html"})}static get JAVASCRIPT(){return l.parse({mediaType:"text/javascript",fileExtension:"js"})}static get JPEG(){return l.parse({mediaType:"image/jpeg",fileExtension:"jpeg"})}static get JSON(){return l.parse({mediaType:"application/json"})}static get LCP_LICENSE_DOCUMENT(){return l.parse({mediaType:"application/vnd.readium.lcp.license.v1.0+json",name:"LCP License",fileExtension:"lcpl"})}static get LCP_PROTECTED_AUDIOBOOK(){return l.parse({mediaType:"application/audiobook+lcp",name:"LCP Protected Audiobook",fileExtension:"lcpa"})}static get LCP_PROTECTED_PDF(){return l.parse({mediaType:"application/pdf+lcp",name:"LCP Protected PDF",fileExtension:"lcpdf"})}static get LCP_STATUS_DOCUMENT(){return l.parse({mediaType:"application/vnd.readium.license.status.v1.0+json"})}static get LPF(){return l.parse({mediaType:"application/lpf+zip",fileExtension:"lpf"})}static get MP3(){return l.parse({mediaType:"audio/mpeg",fileExtension:"mp3"})}static get MPEG(){return l.parse({mediaType:"video/mpeg",fileExtension:"mpeg"})}static get NCX(){return l.parse({mediaType:"application/x-dtbncx+xml",fileExtension:"ncx"})}static get OGG(){return l.parse({mediaType:"audio/ogg",fileExtension:"oga"})}static get OGV(){return l.parse({mediaType:"video/ogg",fileExtension:"ogv"})}static get OPDS1(){return l.parse({mediaType:"application/atom+xml;profile=opds-catalog"})}static get OPDS1_ENTRY(){return l.parse({mediaType:"application/atom+xml;type=entry;profile=opds-catalog"})}static get OPDS2(){return l.parse({mediaType:"application/opds+json"})}static get OPDS2_PUBLICATION(){return l.parse({mediaType:"application/opds-publication+json"})}static get OPDS_AUTHENTICATION(){return l.parse({mediaType:"application/opds-authentication+json"})}static get OPUS(){return l.parse({mediaType:"audio/opus",fileExtension:"opus"})}static get OTF(){return l.parse({mediaType:"font/otf",fileExtension:"otf"})}static get PDF(){return l.parse({mediaType:"application/pdf",name:"PDF",fileExtension:"pdf"})}static get PNG(){return l.parse({mediaType:"image/png",fileExtension:"png"})}static get READIUM_AUDIOBOOK(){return l.parse({mediaType:"application/audiobook+zip",name:"Readium Audiobook",fileExtension:"audiobook"})}static get READIUM_AUDIOBOOK_MANIFEST(){return l.parse({mediaType:"application/audiobook+json",name:"Readium Audiobook",fileExtension:"json"})}static get READIUM_CONTENT_DOCUMENT(){return l.parse({mediaType:"application/vnd.readium.content+json",name:"Readium Content Document",fileExtension:"json"})}static get READIUM_GUIDED_NAVIGATION_DOCUMENT(){return l.parse({mediaType:"application/guided-navigation+json",name:"Readium Guided Navigation Document",fileExtension:"json"})}static get READIUM_POSITION_LIST(){return l.parse({mediaType:"application/vnd.readium.position-list+json",name:"Readium Position List",fileExtension:"json"})}static get READIUM_WEBPUB(){return l.parse({mediaType:"application/webpub+zip",name:"Readium Web Publication",fileExtension:"webpub"})}static get READIUM_WEBPUB_MANIFEST(){return l.parse({mediaType:"application/webpub+json",name:"Readium Web Publication",fileExtension:"json"})}static get SMIL(){return l.parse({mediaType:"application/smil+xml",fileExtension:"smil"})}static get SVG(){return l.parse({mediaType:"image/svg+xml",fileExtension:"svg"})}static get TEXT(){return l.parse({mediaType:"text/plain",fileExtension:"txt"})}static get TIFF(){return l.parse({mediaType:"image/tiff",fileExtension:"tiff"})}static get TTF(){return l.parse({mediaType:"font/ttf",fileExtension:"ttf"})}static get W3C_WPUB_MANIFEST(){return l.parse({mediaType:"application/x.readium.w3c.wpub+json",name:"Web Publication",fileExtension:"json"})}static get WAV(){return l.parse({mediaType:"audio/wav",fileExtension:"wav"})}static get WEBM_AUDIO(){return l.parse({mediaType:"audio/webm",fileExtension:"webm"})}static get WEBM_VIDEO(){return l.parse({mediaType:"video/webm",fileExtension:"webm"})}static get WEBP(){return l.parse({mediaType:"image/webp",fileExtension:"webp"})}static get WOFF(){return l.parse({mediaType:"font/woff",fileExtension:"woff"})}static get WOFF2(){return l.parse({mediaType:"font/woff2",fileExtension:"woff2"})}static get XHTML(){return l.parse({mediaType:"application/xhtml+xml",fileExtension:"xhtml"})}static get XML(){return l.parse({mediaType:"application/xml",fileExtension:"xml"})}static get ZAB(){return l.parse({mediaType:"application/x.readium.zab+zip",name:"Zipped Audio Book",fileExtension:"zab"})}static get ZIP(){return l.parse({mediaType:"application/zip",fileExtension:"zip"})}}class ot{constructor(e){this.uri=e,this.parameters=this.getParameters(e)}getParameters(e){const t=/\{\??([^}]+)\}/g,i=e.match(t);return i?new Set(i.join(",").replace(t,"$1").split(",").map(n=>n.trim())):new Set}expand(e){const t=n=>n.split(",").map(o=>{const s=e[o];return s?encodeURIComponent(s):""}).join(","),i=n=>"?"+n.split(",").map(o=>{const s=o.split("=")[0],a=e[s];return a?`${s}=${encodeURIComponent(a)}`:""}).join("&");return this.uri.replace(/\{(\??)([^}]+)\}/g,(...n)=>n[1]?i(n[2]):t(n[2]))}}class E{constructor(e){this.fragments=e.fragments?e.fragments:new Array,this.progression=e.progression,this.totalProgression=e.totalProgression,this.position=e.position,this.otherLocations=e.otherLocations}static deserialize(e){if(!e)return;const t=se(e.progression),i=se(e.totalProgression),n=se(e.position),o=new Map,s=new Set(["fragment","fragments","progression","totalProgression","position"]);return Object.entries(e).forEach(([a,u])=>{s.has(a)||o.set(a,u)}),new E({fragments:it(e.fragments||e.fragment),progression:t!==void 0&&t>=0&&t<=1?t:void 0,totalProgression:i!==void 0&&i>=0&&i<=1?i:void 0,position:n!==void 0&&n>0?n:void 0,otherLocations:o.size===0?void 0:o})}serialize(){const e={};return this.fragments&&(e.fragments=this.fragments),this.progression!==void 0&&(e.progression=this.progression),this.totalProgression!==void 0&&(e.totalProgression=this.totalProgression),this.position!==void 0&&(e.position=this.position),this.otherLocations&&this.otherLocations.forEach((t,i)=>e[i]=t),e}}class B{constructor(e){this.after=e.after,this.before=e.before,this.highlight=e.highlight}static deserialize(e){if(e)return new B({after:e.after,before:e.before,highlight:e.highlight})}serialize(){const e={};return this.after!==void 0&&(e.after=this.after),this.before!==void 0&&(e.before=this.before),this.highlight!==void 0&&(e.highlight=this.highlight),e}}class D{constructor(e){this.href=e.href,this.type=e.type,this.title=e.title,this.locations=e.locations?e.locations:new E({}),this.text=e.text}static deserialize(e){if(e&&e.href&&e.type)return new D({href:e.href,type:e.type,title:e.title,locations:E.deserialize(e.locations),text:B.deserialize(e.text)})}serialize(){const e={href:this.href,type:this.type};return this.title!==void 0&&(e.title=this.title),this.locations&&(e.locations=this.locations.serialize()),this.text&&(e.text=this.text.serialize()),e}copyWithLocations(e){return new D({href:this.href,type:this.type,title:this.title,text:this.text,locations:new E({...this.locations,...e})})}}class ${constructor(e){this.href=e.href,this.templated=e.templated,this.type=e.type,this.title=e.title,this.rels=e.rels,this.properties=e.properties,this.height=e.height,this.width=e.width,this.size=e.size,this.duration=e.duration,this.bitrate=e.bitrate,this.languages=e.languages,this.alternates=e.alternates,this.children=e.children}static deserialize(e){if(!(!e||typeof e.href!="string"))return new $({href:e.href,templated:e.templated,type:e.type,title:e.title,rels:e.rel?Array.isArray(e.rel)?new Set(e.rel):new Set([e.rel]):void 0,properties:N.deserialize(e.properties),height:I(e.height),width:I(e.width),size:I(e.size),duration:I(e.duration),bitrate:I(e.bitrate),languages:it(e.language),alternates:ae.deserialize(e.alternate),children:ae.deserialize(e.children)})}serialize(){const e={href:this.href};return this.templated!==void 0&&(e.templated=this.templated),this.type!==void 0&&(e.type=this.type),this.title!==void 0&&(e.title=this.title),this.rels&&(e.rel=Kt(this.rels)),this.properties&&(e.properties=this.properties.serialize()),this.height!==void 0&&(e.height=this.height),this.width!==void 0&&(e.width=this.width),this.size!==void 0&&(e.size=this.size),this.duration!==void 0&&(e.duration=this.duration),this.bitrate!==void 0&&(e.bitrate=this.bitrate),this.languages&&(e.language=this.languages),this.alternates&&(e.alternate=this.alternates.serialize()),this.children&&(e.children=this.children.serialize()),e}get mediaType(){return this.type!==void 0?l.parse({mediaType:this.type}):l.BINARY}toURL(e){const t=this.href.replace(/^(\/)/,"");if(t.length===0)return;let i=e||"/";return i.startsWith("/")&&(i="file://"+i),new URL(t,i).href.replace(/^(file:\/\/)/,"")}get templateParameters(){return this.templated?new ot(this.href).parameters:new Set}expandTemplate(e){return new $({href:new ot(this.href).expand(e),templated:!1})}addProperties(e){const t=$.deserialize(this.serialize());return t.properties=t.properties?t.properties?.add(e):new N(e),t}get locator(){let e=this.href.split("#");return new D({href:e.length>0&&e[0]!==void 0?e[0]:this.href,type:this.type??"",title:this.title,locations:new E({fragments:e.length>1&&e[1]!==void 0?[e[1]]:[]})})}}class ae{constructor(e){this.items=e}static deserialize(e){if(e&&Array.isArray(e))return new ae(e.map(t=>$.deserialize(t)).filter(t=>t!==void 0))}serialize(){return this.items.map(e=>e.serialize())}findWithRel(e){const t=i=>i.rels&&i.rels.has(e);return this.items.find(t)}filterByRel(e){const t=i=>i.rels&&i.rels.has(e);return this.items.filter(t)}findWithHref(e){const t=i=>i.href===e;return this.items.find(t)}findIndexWithHref(e){const t=i=>i.href===e;return this.items.findIndex(t)}findWithMediaType(e){const t=i=>i.mediaType.matches(e);return this.items.find(t)}filterByMediaType(e){const t=i=>i.mediaType.matches(e);return this.items.filter(t)}filterByMediaTypes(e){const t=i=>{for(const n of e)if(i.mediaType.matches(n))return!0;return!1};return this.items.filter(t)}everyIsAudio(){const e=t=>t.mediaType.isAudio;return this.items.length>0&&this.items.every(e)}everyIsBitmap(){const e=t=>t.mediaType.isBitmap;return this.items.length>0&&this.items.every(e)}everyIsHTML(){const e=t=>t.mediaType.isHTML;return this.items.length>0&&this.items.every(e)}everyIsVideo(){const e=t=>t.mediaType.isVideo;return this.items.length>0&&this.items.every(e)}everyMatchesMediaType(e){return Array.isArray(e)?this.items.length>0&&this.items.every(t=>{for(const i of e)return t.mediaType.matches(i);return!1}):this.items.length>0&&this.items.every(t=>t.mediaType.matches(e))}filterLinksHasType(){return this.items.filter(e=>e.type)}}N.prototype.getContains=function(){return new Set(this.otherProperties.contains||[])};class le{constructor(e){this.cssSelector=e.cssSelector,this.textNodeIndex=e.textNodeIndex,this.charOffset=e.charOffset}static deserialize(e){if(!(e&&e.cssSelector))return;let t=I(e.textNodeIndex);if(t===void 0)return;let i=I(e.charOffset);return i===void 0&&(i=I(e.offset)),new le({cssSelector:e.cssSelector,textNodeIndex:t,charOffset:i})}serialize(){const e={cssSelector:this.cssSelector,textNodeIndex:this.textNodeIndex};return this.charOffset!==void 0&&(e.charOffset=this.charOffset),e}}class ke{constructor(e){this.start=e.start,this.end=e.end}static deserialize(e){if(!e)return;let t=le.deserialize(e.start);if(t)return new ke({start:t,end:le.deserialize(e.end)})}serialize(){const e={start:this.start.serialize()};return this.end&&(e.end=this.end.serialize()),e}}E.prototype.getCssSelector=function(){return this.otherLocations?.get("cssSelector")},E.prototype.getPartialCfi=function(){return this.otherLocations?.get("partialCfi")},E.prototype.getDomRange=function(){return ke.deserialize(this.otherLocations?.get("domRange"))},E.prototype.fragmentParameters=function(){return new Map(this.fragments.map(r=>r.startsWith("#")?r.slice(1):r).join("&").split("&").filter(r=>!r.startsWith("#")).map(r=>r.split("=")).filter(r=>r.length===2).map(r=>[r[0].trim().toLowerCase(),r[1].trim()]))},E.prototype.htmlId=function(){if(!this.fragments.length)return;let r=this.fragments.find(e=>e.length&&!e.includes("="));if(!r){const e=this.fragmentParameters();e.has("id")?r=e.get("id"):e.has("name")&&(r=e.get("name"))}return r?.startsWith("#")?r.slice(1):r},E.prototype.page=function(){const r=parseInt(this.fragmentParameters().get("page"));if(!isNaN(r)&&r>=0)return r},E.prototype.time=function(){const r=parseInt(this.fragmentParameters().get("t"));if(!isNaN(r))return r},E.prototype.space=function(){const r=this.fragmentParameters();if(!r.has("xywh"))return;const e=r.get("xywh").split(",").map(t=>parseInt(t));if(e.length===4&&!e.some(isNaN))return e},E.prototype.text=function(){const r=this.fragmentParameters();console.log(r)};class Se{constructor(e){this.currency=e.currency,this.value=e.value}static deserialize(e){if(!e)return;let t=e.currency;if(!(t&&typeof t=="string"&&t.length>0))return;let i=I(e.value);if(i!==void 0)return new Se({currency:t,value:i})}serialize(){return{currency:this.currency,value:this.value}}}class J{constructor(e){this.type=e.type,this.children=e.children}static deserialize(e){if(e&&e.type)return new J({type:e.type,children:J.deserializeArray(e.children)})}static deserializeArray(e){if(Array.isArray(e))return e.map(t=>J.deserialize(t)).filter(t=>t!==void 0)}serialize(){const e={type:this.type};return this.children&&(e.children=this.children.map(t=>t.serialize())),e}}class Ee{constructor(e){this.total=e.total,this.position=e.position}static deserialize(e){if(e)return new Ee({total:I(e.total),position:I(e.position)})}serialize(){const e={};return this.total!==void 0&&(e.total=this.total),this.position!==void 0&&(e.position=this.position),e}}class Ce{constructor(e){this.total=e.total,this.available=e.available}static deserialize(e){if(e)return new Ce({total:I(e.total),available:I(e.available)})}serialize(){const e={};return this.total!==void 0&&(e.total=this.total),this.available!==void 0&&(e.available=this.available),e}}class xe{constructor(e){this.state=e.state,this.since=e.since,this.until=e.until}static deserialize(e){if(e&&e.state)return new xe({state:e.state,since:nt(e.since),until:nt(e.until)})}serialize(){const e={state:this.state};return this.since!==void 0&&(e.since=this.since.toISOString()),this.until!==void 0&&(e.until=this.until.toISOString()),e}}N.prototype.getNumberOfItems=function(){return I(this.otherProperties.numberOfItems)},N.prototype.getPrice=function(){return Se.deserialize(this.otherProperties.price)},N.prototype.getIndirectAcquisitions=function(){const r=this.otherProperties.indirectAcquisition;if(r&&Array.isArray(r))return r.map(e=>J.deserialize(e)).filter(e=>e!==void 0)},N.prototype.getHolds=function(){return Ee.deserialize(this.otherProperties.holds)},N.prototype.getCopies=function(){return Ce.deserialize(this.otherProperties.copies)},N.prototype.getAvailability=function(){return xe.deserialize(this.otherProperties.availability)},N.prototype.getAuthenticate=function(){return $.deserialize(this.otherProperties.authenticate)};const Jt="CssSelectorGenerator";function rt(r="unknown problem",...e){console.warn(`${Jt}: ${r}`,...e)}function Zt(r){return r instanceof RegExp}function Qt(r){return r.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".+")}function ei(r){const e=r.map(t=>{if(Zt(t))return i=>t.test(i);if(typeof t=="function")return i=>{const n=t(i);return typeof n!="boolean"?(rt("pattern matcher function invalid","Provided pattern matching function does not return boolean. It's result will be ignored.",t),!1):n};if(typeof t=="string"){const i=new RegExp("^"+Qt(t)+"$");return n=>i.test(n)}return rt("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",t),()=>!1});return t=>e.some(i=>i(t))}ei(["class","id","ng-*"]);class G{}function st(r){return r.split("").reverse().join("")}function ti(r,e,t){const i=st(e);return t.map(n=>{const o=Math.max(0,n.end-e.length-n.errors),s=st(r.slice(o,n.end));return{start:lt(s,i,n.errors).reduce((u,d)=>n.end-d.end<u?n.end-d.end:u,n.end),end:n.end,errors:n.errors}})}function Pe(r){return(r|-r)>>31&1}function at(r,e,t,i){let n=r.P[t],o=r.M[t];const s=i>>>31,a=e[t]|s,u=a|o,d=(a&n)+n^n|a;let h=o|~(d|n),f=n&d;const m=Pe(h&r.lastRowMask[t])-Pe(f&r.lastRowMask[t]);return h<<=1,f<<=1,f|=s,h|=Pe(i)-s,n=f|~(u|h),o=h&u,r.P[t]=n,r.M[t]=o,m}function lt(r,e,t){if(e.length===0)return[];t=Math.min(t,e.length);const i=[],n=32,o=Math.ceil(e.length/n)-1,s={P:new Uint32Array(o+1),M:new Uint32Array(o+1),lastRowMask:new Uint32Array(o+1)};s.lastRowMask.fill(1<<31),s.lastRowMask[o]=1<<(e.length-1)%n;const a=new Uint32Array(o+1),u=new Map,d=[];for(let m=0;m<256;m++)d.push(a);for(let m=0;m<e.length;m+=1){const y=e.charCodeAt(m);if(u.has(y))continue;const g=new Uint32Array(o+1);u.set(y,g),y<d.length&&(d[y]=g);for(let p=0;p<=o;p+=1){g[p]=0;for(let v=0;v<n;v+=1){const x=p*n+v;if(x>=e.length)continue;e.charCodeAt(x)===y&&(g[p]|=1<<v)}}}let h=Math.max(0,Math.ceil(t/n)-1);const f=new Uint32Array(o+1);for(let m=0;m<=h;m+=1)f[m]=(m+1)*n;f[o]=e.length;for(let m=0;m<=h;m+=1)s.P[m]=-1,s.M[m]=0;for(let m=0;m<r.length;m+=1){const y=r.charCodeAt(m);let g;y<d.length?g=d[y]:(g=u.get(y),typeof g>"u"&&(g=a));let p=0;for(let v=0;v<=h;v+=1)p=at(s,g,v,p),f[v]+=p;if(f[h]-p<=t&&h<o&&(g[h+1]&1||p<0)){h+=1,s.P[h]=-1,s.M[h]=0;let v;if(h===o){const x=e.length%n;v=x===0?n:x}else v=n;f[h]=f[h-1]+v-p+at(s,g,h,p)}else for(;h>0&&f[h]>=t+n;)h-=1;h===o&&f[h]<=t&&(f[h]<t&&i.splice(0,i.length),i.push({start:-1,end:m+1,errors:f[h]}),t=f[h])}return i}function ii(r,e,t){const i=lt(r,e,t);return ti(r,e,i)}function ct(r,e,t){let i=0;const n=[];for(;i!==-1;)i=r.indexOf(e,i),i!==-1&&(n.push({start:i,end:i+e.length,errors:0}),i+=1);return n.length>0?n:ii(r,e,t)}function dt(r,e){return e.length===0||r.length===0?0:1-ct(r,e,e.length)[0].errors/e.length}function ni(r,e,t={}){if(e.length===0)return null;const i=Math.min(256,e.length/2),n=ct(r,e,i);if(n.length===0)return null;const o=a=>{const m=1-a.errors/e.length,y=t.prefix?dt(r.slice(Math.max(0,a.start-t.prefix.length),a.start),t.prefix):1,g=t.suffix?dt(r.slice(a.end,a.end+t.suffix.length),t.suffix):1;let p=1;return typeof t.hint=="number"&&(p=1-Math.abs(a.start-t.hint)/r.length),(50*m+20*y+20*g+2*p)/92},s=n.map(a=>({start:a.start,end:a.end,score:o(a)}));return s.sort((a,u)=>u.score-a.score),s[0]}function Te(r,e,t){const i=t===1?e:e-1;if(r.charAt(i).trim()!=="")return e;let n,o;if(t===2?(n=r.substring(0,e),o=n.trimEnd()):(n=r.substring(e),o=n.trimStart()),!o.length)return-1;const s=n.length-o.length;return t===2?e-s:e+s}function ut(r,e){const t=r.commonAncestorContainer.ownerDocument.createNodeIterator(r.commonAncestorContainer,NodeFilter.SHOW_TEXT),i=e===1?r.startContainer:r.endContainer,n=e===1?r.endContainer:r.startContainer;let o=t.nextNode();for(;o&&o!==i;)o=t.nextNode();e===2&&(o=t.previousNode());let s=-1;const a=()=>{if(o=e===1?t.nextNode():t.previousNode(),o){const u=o.textContent,d=e===1?0:u.length;s=Te(u,d,e)}};for(;o&&s===-1&&o!==n;)a();if(o&&s>=0)return{node:o,offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function oi(r){if(!r.toString().trim().length)throw new RangeError("Range contains no non-whitespace text");if(r.startContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range startContainer is not a text node");if(r.endContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range endContainer is not a text node");const e=r.cloneRange();let t=!1,i=!1;const n={start:Te(r.startContainer.textContent,r.startOffset,1),end:Te(r.endContainer.textContent,r.endOffset,2)};if(n.start>=0&&(e.setStart(r.startContainer,n.start),t=!0),n.end>0&&(e.setEnd(r.endContainer,n.end),i=!0),t&&i)return e;if(!t){const{node:o,offset:s}=ut(e,1);o&&s>=0&&e.setStart(o,s)}if(!i){const{node:o,offset:s}=ut(e,2);o&&s>0&&e.setEnd(o,s)}return e}function ht(r){switch(r.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return r.textContent?.length??0;default:return 0}}function pt(r){let e=r.previousSibling,t=0;for(;e;)t+=ht(e),e=e.previousSibling;return t}function mt(r,...e){let t=e.shift();const i=r.ownerDocument.createNodeIterator(r,NodeFilter.SHOW_TEXT),n=[];let o=i.nextNode(),s,a=0;for(;t!==void 0&&o;)s=o,a+s.data.length>t?(n.push({node:s,offset:t-a}),t=e.shift()):(o=i.nextNode(),a+=s.data.length);for(;t!==void 0&&s&&a===t;)n.push({node:s,offset:s.data.length}),t=e.shift();if(t!==void 0)throw new RangeError("Offset exceeds text length");return n}class O{constructor(e,t){if(t<0)throw new Error("Offset is invalid");this.element=e,this.offset=t}relativeTo(e){if(!e.contains(this.element))throw new Error("Parent is not an ancestor of current element");let t=this.element,i=this.offset;for(;t!==e;)i+=pt(t),t=t.parentElement;return new O(t,i)}resolve(e={}){try{return mt(this.element,this.offset)[0]}catch(t){if(this.offset===0&&e.direction!==void 0){const i=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);i.currentNode=this.element;const n=e.direction===1,o=n?i.nextNode():i.previousNode();if(!o)throw t;return{node:o,offset:n?0:o.data.length}}else throw t}}static fromCharOffset(e,t){switch(e.nodeType){case Node.TEXT_NODE:return O.fromPoint(e,t);case Node.ELEMENT_NODE:return new O(e,t);default:throw new Error("Node is not an element or text node")}}static fromPoint(e,t){switch(e.nodeType){case Node.TEXT_NODE:{if(t<0||t>e.data.length)throw new Error("Text node offset is out of range");if(!e.parentElement)throw new Error("Text node has no parent");const i=pt(e)+t;return new O(e.parentElement,i)}case Node.ELEMENT_NODE:{if(t<0||t>e.childNodes.length)throw new Error("Child node offset is out of range");let i=0;for(let n=0;n<t;n++)i+=ht(e.childNodes[n]);return new O(e,i)}default:throw new Error("Point is not in an element or text node")}}}class U{constructor(e,t){this.start=e,this.end=t}relativeTo(e){return new U(this.start.relativeTo(e),this.end.relativeTo(e))}toRange(){let e,t;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[e,t]=mt(this.start.element,this.start.offset,this.end.offset):(e=this.start.resolve({direction:1}),t=this.end.resolve({direction:2}));const i=new Range;return i.setStart(e.node,e.offset),i.setEnd(t.node,t.offset),i}static fromRange(e){const t=O.fromPoint(e.startContainer,e.startOffset),i=O.fromPoint(e.endContainer,e.endOffset);return new U(t,i)}static fromOffsets(e,t,i){return new U(new O(e,t),new O(e,i))}static trimmedRange(e){return oi(U.fromRange(e).toRange())}}class ce{constructor(e,t,i){this.root=e,this.start=t,this.end=i}static fromRange(e,t){const i=U.fromRange(t).relativeTo(e);return new ce(e,i.start.offset,i.end.offset)}static fromSelector(e,t){return new ce(e,t.start,t.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){return U.fromOffsets(this.root,this.start,this.end).toRange()}}class de{constructor(e,t,i={}){this.root=e,this.exact=t,this.context=i}static fromRange(e,t){const i=e.textContent,n=U.fromRange(t).relativeTo(e),o=n.start.offset,s=n.end.offset,a=32;return new de(e,i.slice(o,s),{prefix:i.slice(Math.max(0,o-a),o),suffix:i.slice(s,Math.min(i.length,s+a))})}static fromSelector(e,t){const{prefix:i,suffix:n}=t;return new de(e,t.exact,{prefix:i,suffix:n})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(e={}){return this.toPositionAnchor(e).toRange()}toPositionAnchor(e={}){const t=this.root.textContent,i=ni(t,this.exact,{...this.context,hint:e.hint});if(!i)throw new Error("Quote not found");return new ce(this.root,i.start,i.end)}}function ri(r){const e=r.tagName.toUpperCase();return e==="IMG"||e==="VIDEO"||e==="AUDIO"||e==="IFRAME"||e==="OBJECT"||e==="EMBED"||e==="CANVAS"}function ue(r,e){try{const t=e.locations,i=e.text;if(i&&i.highlight){let n;t&&t.getCssSelector()&&(n=r.querySelector(t.getCssSelector())),n||(n=r.body);const o=new de(n,i.highlight,{prefix:i.before,suffix:i.after});try{return o.toRange()}catch{return console.warn("Quote not found:",o),null}}if(t){let n=null;if(!n&&t.getCssSelector()&&(n=r.querySelector(t.getCssSelector())),!n&&t.fragments){for(const o of t.fragments)if(n=r.getElementById(o),n)break}if(n){const o=r.createRange();return n.childNodes.length===0||ri(n)?(o.selectNode(n),o):(o.setStartBefore(n),o.setEndAfter(n),o)}}}catch(t){console.error(t)}return null}function si(r,e){let t=r.getClientRects();t.length||r.commonAncestorContainer.nodeType===Node.ELEMENT_NODE&&(t=r.commonAncestorContainer.getClientRects());const i=1,n=[];for(const d of t)n.push({bottom:d.bottom,height:d.height,left:d.left,right:d.right,top:d.top,width:d.width});const o=gt(n,i),s=li(o,i),a=ft(s),u=4;for(let d=a.length-1;d>=0;d--){const h=a[d];if(!(h.width*h.height>u))if(a.length>1)a.splice(d,1);else break}return a}function gt(r,e,t){for(let i=0;i<r.length;i++)for(let n=i+1;n<r.length;n++){const o=r[i],s=r[n];if(o===s)continue;const a=z(o.top,s.top,e)&&z(o.bottom,s.bottom,e),u=z(o.left,s.left,e)&&z(o.right,s.right,e);if(a&&!u&&vt(o,s,e)){const f=r.filter(y=>y!==o&&y!==s),m=ai(o,s);return f.push(m),gt(f,e)}}return r}function ai(r,e){const t=Math.min(r.left,e.left),i=Math.max(r.right,e.right),n=Math.min(r.top,e.top),o=Math.max(r.bottom,e.bottom);return{bottom:o,height:o-n,left:t,right:i,top:n,width:i-t}}function li(r,e){const t=new Set(r);for(const i of r){if(!(i.width>1&&i.height>1)){t.delete(i);continue}for(const o of r)if(i!==o&&t.has(o)&&ci(o,i,e)){t.delete(i);break}}return Array.from(t)}function ci(r,e,t){return he(r,e.left,e.top,t)&&he(r,e.right,e.top,t)&&he(r,e.left,e.bottom,t)&&he(r,e.right,e.bottom,t)}function he(r,e,t,i){return(r.left<e||z(r.left,e,i))&&(r.right>e||z(r.right,e,i))&&(r.top<t||z(r.top,t,i))&&(r.bottom>t||z(r.bottom,t,i))}function ft(r){for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){const i=r[e],n=r[t];if(i!==n&&vt(i,n,-1)){let o=[],s;const a=bt(i,n);if(a.length===1)o=a,s=i;else{const d=bt(n,i);a.length<d.length?(o=a,s=i):(o=d,s=n)}const u=r.filter(d=>d!==s);return Array.prototype.push.apply(u,o),ft(u)}}return r}function bt(r,e){const t=di(e,r);if(t.height===0||t.width===0)return[r];const i=[];{const n={bottom:r.bottom,height:0,left:r.left,right:t.left,top:r.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&i.push(n)}{const n={bottom:t.top,height:0,left:t.left,right:t.right,top:r.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&i.push(n)}{const n={bottom:r.bottom,height:0,left:t.left,right:t.right,top:t.bottom,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&i.push(n)}{const n={bottom:r.bottom,height:0,left:t.right,right:r.right,top:r.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&i.push(n)}return i}function di(r,e){const t=Math.max(r.left,e.left),i=Math.min(r.right,e.right),n=Math.max(r.top,e.top),o=Math.min(r.bottom,e.bottom);return{bottom:o,height:Math.max(0,o-n),left:t,right:i,top:n,width:Math.max(0,i-t)}}function vt(r,e,t){return(r.left<e.right||t>=0&&z(r.left,e.right,t))&&(e.left<r.right||t>=0&&z(e.left,r.right,t))&&(r.top<e.bottom||t>=0&&z(r.top,e.bottom,t))&&(e.top<r.bottom||t>=0&&z(e.top,r.bottom,t))}function z(r,e,t){return Math.abs(r-e)<=t}const Le=typeof window.CSSTransformValue<"u";function _e(r){const e={},t=r.document.documentElement.style;for(const i in r.document.documentElement.style)Object.hasOwn(t,i)&&!Number.isNaN(Number.parseInt(i))&&(e[t[i]]=t.getPropertyValue(t[i]));return e}function yt(r,e){const t=_e(r);Object.keys(t).forEach(i=>{e.hasOwnProperty(i)||pe(r,i)}),Object.entries(e).forEach(([i,n])=>{t[i]!==n&&Z(r,i,n)})}function Ne(r,e){return r.document.documentElement.style.getPropertyValue(e)}function Z(r,e,t){r.document.documentElement.style.setProperty(e,t)}function pe(r,e){r.document.documentElement.style.removeProperty(e)}let me=null,Ie=null,Q=0;const j={r:255,g:255,b:255,a:1},X=new Map,ui=()=>{if(!me)if(typeof OffscreenCanvas<"u")me=new OffscreenCanvas(5,5),Ie=me.getContext("2d",{willReadFrequently:!0,desynchronized:!0});else{const r=document.createElement("canvas");r.width=5,r.height=5,me=r,Ie=r.getContext("2d",{willReadFrequently:!0,desynchronized:!0})}return Ie},hi=r=>{if(!r)return!0;const e=r.trim().toLowerCase();return e.startsWith("var(")||["transparent","currentcolor","inherit","initial","revert","unset","revert-layer"].includes(e)?!0:["linear-gradient","radial-gradient","conic-gradient","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient"].some(n=>e.includes(n))},ge=(r,e)=>{console.warn(`[Decorator] Could not parse color: "${r}". ${e} Falling back to ${JSON.stringify(j)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`)},ze=(r,e=null)=>{const t=e?`${r}|${e}`:r,i=X.get(t);if(i!==void 0)return i??j;if(hi(r))return ge(r,"Unsupported color format or special value."),X.set(t,null),j;const n=ui();if(!n)return ge(r,"Could not get canvas context."),X.set(t,null),j;try{Q===0&&n.clearRect(0,0,5,5);const o=Q%5,s=Math.floor(Q/5);n.clearRect(o,s,1,1),e&&(n.fillStyle=e,n.fillRect(o,s,1,1)),n.fillStyle=r,n.fillRect(o,s,1,1);const a=n.getImageData(o,s,1,1);Q=(Q+1)%25;const[u,d,h,f]=a.data;if(f===0)return ge(r,"Fully transparent color."),X.set(t,null),j;const m={r:u,g:d,b:h,a:f/255};return X.set(t,m),m}catch(o){return ge(r,`Error: ${o instanceof Error?o.message:String(o)}`),X.set(t,null),j}},Oe=r=>{const e=r/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)},At=r=>{const e=Oe(r.r),t=Oe(r.g),i=Oe(r.b);return .2126*e+.7152*t+.0722*i},wt=(r,e)=>{const t=typeof r=="string"?ze(r):r,i=typeof e=="string"?ze(e):e,n=At(t),o=At(i),s=Math.max(n,o),a=Math.min(n,o);return(s+.05)/(a+.05)},Re=(r,e=null)=>{const t=ze(r,e),i=wt(t,{r:255,g:255,b:255,a:1}),n=wt(t,{r:0,g:0,b:0,a:1});return i>n},pi=(r,e=null)=>Re(r,e)?"white":"black",kt="#FFFF00";var St=(r=>(r.Wrap="wrap",r.Viewport="viewport",r.Bounds="bounds",r.Page="page",r))(St||{}),Et=(r=>(r.Boxes="boxes",r.Bounds="bounds",r))(Et||{});const mi=()=>"Highlight"in window,Ct=["IMG","IMAGE","AUDIO","VIDEO","SVG"];class gi{constructor(e,t,i,n){this.wnd=e,this.comms=t,this.id=i,this.name=n,this.items=[],this.lastItemId=0,this.container=void 0,this.activateable=!1,this.experimentalHighlights=!1,this.currentRender=0,mi()&&(this.experimentalHighlights=!0,this.notTextFlag=new Map)}get activeable(){return this.activateable}set activeable(e){this.activateable=e}add(e){const t=`${this.id}-${this.lastItemId++}`,i=ue(this.wnd.document,e.locator);if(!i){this.comms.log("Can't locate DOM range for decoration",e);return}const n=i.commonAncestorContainer;n.nodeType!==Node.TEXT_NODE&&this.experimentalHighlights&&(Ct.includes(n.nodeName.toUpperCase())&&this.notTextFlag?.set(t,!0),i.cloneContents().querySelector(Ct.join(", ").toLowerCase())&&this.notTextFlag?.set(t,!0),(n.textContent?.trim()||"").length===0&&this.notTextFlag?.set(t,!0));const o={decoration:e,id:t,range:i};this.items.push(o),this.layout(o),this.renderLayout([o])}remove(e){const t=this.items.findIndex(n=>n.decoration.id===e);if(t<0)return;const i=this.items[t];this.items.splice(t,1),i.clickableElements=void 0,i.container&&(i.container.remove(),i.container=void 0),this.experimentalHighlights&&!this.notTextFlag?.has(i.id)&&this.wnd.CSS.highlights.get(this.id)?.delete(i.range),this.notTextFlag?.delete(i.id)}update(e){this.remove(e.id),this.add(e)}clear(){this.clearContainer(),this.items.length=0,this.notTextFlag?.clear()}requestLayout(){this.wnd.cancelAnimationFrame(this.currentRender),this.clearContainer(),this.items.forEach(e=>this.layout(e)),this.renderLayout(this.items)}experimentalLayout(e){const[t,i]=this.requireContainer(!0);i.add(e.range);const n=Ne(this.wnd,"--USER__backgroundColor")||this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"),o=e.decoration?.style?.tint??kt;t.innerHTML=`
1
+ (function(A,K){typeof exports=="object"&&typeof module<"u"?K(exports):typeof define=="function"&&define.amd?define(["exports"],K):(A=typeof globalThis<"u"?globalThis:A||self,K(A["navigator-html-injectables"]={}))})(this,(function(A){"use strict";const K=Math.pow(2,32),Ve=()=>Math.round(Math.random()*K).toString(36),qe=()=>`${Math.round(performance.now())}-${Ve()}-${Ve()}`,V=1;class $e{constructor(e){this.destination=null,this.registrar=new Map,this.origin="",this.channelId="",this.receiver=this.receive.bind(this),this.preLog=[],this.wnd=e,e.addEventListener("message",this.receiver)}receive(e){if(e.source===null)throw Error("Event source is null");if(typeof e.data!="object")return;const t=e.data;if(!(!("_readium"in t)||!t._readium||t._readium<=0)){if(t.key==="_ping"){if(!this.destination){if(this.destination=e.source,this.origin=e.origin,this.channelId=t._channel,t._readium!==V){t._readium>V?this.send("error",`received comms version ${t._readium} higher than ${V}`):this.send("error",`received comms version ${t._readium} lower than ${V}`),this.destination=null,this.origin="",this.channelId="";return}this.send("_pong",void 0),this.preLog.forEach(i=>this.send("log",i)),this.preLog=[]}return}else if(this.channelId){if(t._channel!==this.channelId||e.origin!==this.origin)return}else return;this.handle(t)}}handle(e){const t=this.registrar.get(e.key);if(!t||t.length===0){e.strict&&this.send("_unhandled",e);return}t.forEach(i=>i.cb(e.data,n=>{this.send("_ack",n,e.id)}))}register(e,t,i){Array.isArray(e)||(e=[e]),e.forEach(n=>{const o=this.registrar.get(n);if(o&&o.length>=0){if(o.find(a=>a.module===t))throw new Error(`Trying to register another callback for combination of event ${n} and module ${t}`);o.push({cb:i,module:t}),this.registrar.set(n,o)}else this.registrar.set(n,[{cb:i,module:t}])})}unregister(e,t){Array.isArray(e)||(e=[e]),e.forEach(i=>{const n=this.registrar.get(i);!n||n.length===0||n.splice(n.findIndex(o=>o.module===t),1)})}unregisterAll(e){this.registrar.forEach((t,i)=>this.registrar.set(i,t.filter(n=>n.module!==e)))}log(...e){this.destination?this.send("log",e):this.preLog.push(e)}get ready(){return!!this.destination}destroy(){this.destination=null,this.channelId="",this.preLog=[],this.registrar.clear(),this.wnd.removeEventListener("message",this.receiver)}send(e,t,i=void 0,n=[]){if(!this.destination)throw Error("Attempted to send comms message before destination has been initialized");const o={_readium:V,_channel:this.channelId,id:i??qe(),key:e,data:t};try{this.destination.postMessage(o,{targetOrigin:this.origin,transfer:n})}catch(s){if(n.length>0)throw s;this.destination.postMessage(o,this.origin,n)}}}const b=class b{constructor(e){this.uri=e}static deserialize(e){if(!(!e||typeof e!="string"))return new b(e)}serialize(){return this.uri}get isWCAGLevelA(){return this===b.EPUB_A11Y_10_WCAG_20_A||this===b.EPUB_A11Y_11_WCAG_20_A||this===b.EPUB_A11Y_11_WCAG_21_A||this===b.EPUB_A11Y_11_WCAG_22_A}get isWCAGLevelAA(){return this===b.EPUB_A11Y_10_WCAG_20_AA||this===b.EPUB_A11Y_11_WCAG_20_AA||this===b.EPUB_A11Y_11_WCAG_21_AA||this===b.EPUB_A11Y_11_WCAG_22_AA}get isWCAGLevelAAA(){return this===b.EPUB_A11Y_10_WCAG_20_AAA||this===b.EPUB_A11Y_11_WCAG_20_AAA||this===b.EPUB_A11Y_11_WCAG_21_AAA||this===b.EPUB_A11Y_11_WCAG_22_AAA}};b.EPUB_A11Y_10_WCAG_20_A=new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"),b.EPUB_A11Y_10_WCAG_20_AA=new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"),b.EPUB_A11Y_10_WCAG_20_AAA=new b("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"),b.EPUB_A11Y_11_WCAG_20_A=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"),b.EPUB_A11Y_11_WCAG_20_AA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"),b.EPUB_A11Y_11_WCAG_20_AAA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"),b.EPUB_A11Y_11_WCAG_21_A=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"),b.EPUB_A11Y_11_WCAG_21_AA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"),b.EPUB_A11Y_11_WCAG_21_AAA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"),b.EPUB_A11Y_11_WCAG_22_A=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"),b.EPUB_A11Y_11_WCAG_22_AA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"),b.EPUB_A11Y_11_WCAG_22_AAA=new b("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");let je=b;const w=class w{constructor(e){this.value=e}static deserialize(e){if(!(!e||typeof e!="string"))return new w(e)}serialize(){return this.value}};w.AUDITORY=new w("auditory"),w.CHART_ON_VISUAL=new w("chartOnVisual"),w.CHEM_ON_VISUAL=new w("chemOnVisual"),w.COLOR_DEPENDENT=new w("colorDependent"),w.DIAGRAM_ON_VISUAL=new w("diagramOnVisual"),w.MATH_ON_VISUAL=new w("mathOnVisual"),w.MUSIC_ON_VISUAL=new w("musicOnVisual"),w.TACTILE=new w("tactile"),w.TEXT_ON_VISUAL=new w("textOnVisual"),w.TEXTUAL=new w("textual"),w.VISUAL=new w("visual");let Xe=w;const P=class P{constructor(e){if(typeof e=="string"){if(!P.VALID_MODES.has(e.toLowerCase()))return;this.value=e.toLowerCase()}else{const t=e.filter(i=>P.VALID_MODES.has(i.toLowerCase()));if(t.length===0)return;this.value=Array.from(new Set(t))}}static deserialize(e){if(!e)return;if(typeof e=="string")return new P(e);if(!Array.isArray(e))return;const t=e.filter(i=>i?P.VALID_MODES.has(i.toLowerCase()):!1);if(t.length!==0)return new P(t)}serialize(){return this.value}};P.VALID_MODES=new Set(["auditory","tactile","textual","visual"]),P.AUDITORY=new P("auditory"),P.TACTILE=new P("tactile"),P.TEXTUAL=new P("textual"),P.VISUAL=new P("visual");let Ye=P;const c=class c{constructor(e){this.value=e}static deserialize(e){if(!(!e||typeof e!="string"))return new c(e)}serialize(){return this.value}};c.NONE=new c("none"),c.ANNOTATIONS=new c("annotations"),c.ARIA=new c("ARIA"),c.INDEX=new c("index"),c.PAGE_BREAK_MARKERS=new c("pageBreakMarkers"),c.PAGE_NAVIGATION=new c("pageNavigation"),c.PRINT_PAGE_NUMBERS=new c("printPageNumbers"),c.READING_ORDER=new c("readingOrder"),c.STRUCTURAL_NAVIGATION=new c("structuralNavigation"),c.TABLE_OF_CONTENTS=new c("tableOfContents"),c.TAGGED_PDF=new c("taggedPDF"),c.ALTERNATIVE_TEXT=new c("alternativeText"),c.AUDIO_DESCRIPTION=new c("audioDescription"),c.CAPTIONS=new c("captions"),c.CLOSED_CAPTIONS=new c("closedCaptions"),c.DESCRIBED_MATH=new c("describedMath"),c.LONG_DESCRIPTION=new c("longDescription"),c.OPEN_CAPTIONS=new c("openCaptions"),c.SIGN_LANGUAGE=new c("signLanguage"),c.TRANSCRIPT=new c("transcript"),c.DISPLAY_TRANSFORMABILITY=new c("displayTransformability"),c.SYNCHRONIZED_AUDIO_TEXT=new c("synchronizedAudioText"),c.TIMING_CONTROL=new c("timingControl"),c.UNLOCKED=new c("unlocked"),c.CHEM_ML=new c("ChemML"),c.LATEX=new c("latex"),c.LATEX_CHEMISTRY=new c("latex-chemistry"),c.MATH_ML=new c("MathML"),c.MATH_ML_CHEMISTRY=new c("MathML-chemistry"),c.TTS_MARKUP=new c("ttsMarkup"),c.HIGH_CONTRAST_AUDIO=new c("highContrastAudio"),c.HIGH_CONTRAST_DISPLAY=new c("highContrastDisplay"),c.LARGE_PRINT=new c("largePrint"),c.BRAILLE=new c("braille"),c.TACTILE_GRAPHIC=new c("tactileGraphic"),c.TACTILE_OBJECT=new c("tactileObject"),c.FULL_RUBY_ANNOTATIONS=new c("fullRubyAnnotations"),c.HORIZONTAL_WRITING=new c("horizontalWriting"),c.RUBY_ANNOTATIONS=new c("rubyAnnotations"),c.VERTICAL_WRITING=new c("verticalWriting"),c.WITH_ADDITIONAL_WORD_SEGMENTATION=new c("withAdditionalWordSegmentation"),c.WITHOUT_ADDITIONAL_WORD_SEGMENTATION=new c("withoutAdditionalWordSegmentation");let Ke=c;const k=class k{constructor(e){this.value=e}static deserialize(e){if(!(!e||typeof e!="string"))return new k(e)}serialize(){return this.value}};k.FLASHING=new k("flashing"),k.NO_FLASHING_HAZARD=new k("noFlashingHazard"),k.UNKNOWN_FLASHING_HAZARD=new k("unknownFlashingHazard"),k.MOTION_SIMULATION=new k("motionSimulation"),k.NO_MOTION_SIMULATION_HAZARD=new k("noMotionSimulationHazard"),k.UNKNOWN_MOTION_SIMULATION_HAZARD=new k("unknownMotionSimulationHazard"),k.SOUND=new k("sound"),k.NO_SOUND_HAZARD=new k("noSoundHazard"),k.UNKNOWN_SOUND_HAZARD=new k("unknownSoundHazard"),k.UNKNOWN=new k("unknown"),k.NONE=new k("none");let Je=k;const S=class S{constructor(e){this.value=e}static deserialize(e){if(!(!e||typeof e!="string"))return new S(e)}serialize(){return this.value}};S.NONE=new S("none"),S.DOCUMENTED=new S("documented"),S.LEGAL=new S("legal"),S.TEMPORARY=new S("temporary"),S.TECHNICAL=new S("technical"),S.EAA_DISPROPORTIONATE_BURDEN=new S("eaa-disproportionate-burden"),S.EAA_FUNDAMENTAL_ALTERATION=new S("eaa-fundamental-alteration"),S.EAA_MICROENTERPRISE=new S("eaa-microenterprise"),S.EAA_TECHNICAL_IMPOSSIBILITY=new S("eaa-technical-impossibility"),S.EAA_TEMPORARY=new S("eaa-temporary");let Ze=S;const Qe=["en","ar","da","fr","it","pt_PT","sv"],Xt={publication:JSON.parse(`{"format":{"audiobook":"Audiobook","audiobookJSON":"Audiobook Manifest","cbz":"Comic Book Archive","divina":"Divina Publication","divinaJSON":"Divina Publication Manifest","epub":"EPUB","lcpa":"LCP Protected Audiobook","lcpdf":"LCP Protected PDF","lcpl":"LCP License Document","pdf":"PDF","rwp":"Readium Web Publication","rwpm":"Readium Web Publication Manifest","zab":"Audiobook Archive","zip":"ZIP Archive"},"kind":{"audiobook_one":"audiobook","audiobook_other":"audiobooks","book_one":"book","book_other":"books","comic_one":"comic","comic_other":"comics","document_one":"document","document_other":"documents"},"metadata":{"accessibility":{"display-guide":{"accessibility-summary":{"no-metadata":"No information is available","publisher-contact":"For more information about the accessibility of this product, please contact the publisher: ","title":"Accessibility summary"},"additional-accessibility-information":{"aria":{"compact":"ARIA roles included","descriptive":"Content is enhanced with ARIA roles to optimize organization and facilitate navigation"},"audio-descriptions":"Audio descriptions","braille":"Braille","color-not-sole-means-of-conveying-information":"Color is not the sole means of conveying information","dyslexia-readability":"Dyslexia readability","full-ruby-annotations":"Full ruby annotations","high-contrast-between-foreground-and-background-audio":"High contrast between foreground and background audio","high-contrast-between-text-and-background":"High contrast between foreground text and background","large-print":"Large print","page-breaks":{"compact":"Page breaks included","descriptive":"Page breaks included from the original print source"},"ruby-annotations":"Some Ruby annotations","sign-language":"Sign language","tactile-graphics":{"compact":"Tactile graphics included","descriptive":"Tactile graphics have been integrated to facilitate access to visual elements for blind people"},"tactile-objects":"Tactile 3D objects","text-to-speech-hinting":"Text-to-speech hinting provided","title":"Additional accessibility information","ultra-high-contrast-between-text-and-background":"Ultra high contrast between text and background","visible-page-numbering":"Visible page numbering","without-background-sounds":"Without background sounds"},"conformance":{"a":{"compact":"This publication meets minimum accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level A standard"},"aa":{"compact":"This publication meets accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AA standard"},"aaa":{"compact":"This publication exceeds accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AAA standard"},"certifier":"The publication was certified by ","certifier-credentials":"The certifier's credential is ","details":{"certification-info":"The publication was certified on ","certifier-report":"For more information refer to the certifier's report","claim":"This publication claims to meet","epub-accessibility-1-0":"EPUB Accessibility 1.0","epub-accessibility-1-1":"EPUB Accessibility 1.1","level-a":"Level A","level-aa":"Level AA","level-aaa":"Level AAA","wcag-2-0":{"compact":"WCAG 2.0","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.0"},"wcag-2-1":{"compact":"WCAG 2.1","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.1"},"wcag-2-2":{"compact":"WCAG 2.2","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.2"}},"details-title":"Detailed conformance information","no":"No information is available","title":"Conformance","unknown-standard":"Conformance to accepted standards for accessibility of this publication cannot be determined"},"hazards":{"flashing":{"compact":"Flashing content","descriptive":"The publication contains flashing content that can cause photosensitive seizures"},"flashing-none":{"compact":"No flashing hazards","descriptive":"The publication does not contain flashing content that can cause photosensitive seizures"},"flashing-unknown":{"compact":"Flashing hazards not known","descriptive":"The presence of flashing content that can cause photosensitive seizures could not be determined"},"motion":{"compact":"Motion simulation","descriptive":"The publication contains motion simulations that can cause motion sickness"},"motion-none":{"compact":"No motion simulation hazards","descriptive":"The publication does not contain motion simulations that can cause motion sickness"},"motion-unknown":{"compact":"Motion simulation hazards not known","descriptive":"The presence of motion simulations that can cause motion sickness could not be determined"},"no-metadata":"No information is available","none":{"compact":"No hazards","descriptive":"The publication contains no hazards"},"sound":{"compact":"Sounds","descriptive":"The publication contains sounds that can cause sensitivity issues"},"sound-none":{"compact":"No sound hazards","descriptive":"The publication does not contain sounds that can cause sensitivity issues"},"sound-unknown":{"compact":"Sound hazards not known","descriptive":"The presence of sounds that can cause sensitivity issues could not be determined"},"title":"Hazards","unknown":"The presence of hazards is unknown"},"legal-considerations":{"exempt":{"compact":"Claims an accessibility exemption in some jurisdictions","descriptive":"This publication claims an accessibility exemption in some jurisdictions"},"no-metadata":"No information is available","title":"Legal considerations"},"navigation":{"index":{"compact":"Index","descriptive":"Index with links to referenced entries"},"no-metadata":"No information is available","page-navigation":{"compact":"Go to page","descriptive":"Page list to go to pages from the print source version"},"structural":{"compact":"Headings","descriptive":"Elements such as headings, tables, etc for structured navigation"},"title":"Navigation","toc":{"compact":"Table of contents","descriptive":"Table of contents to all chapters of the text via links"}},"rich-content":{"accessible-chemistry-as-latex":{"compact":"Chemical formulas in LaTeX","descriptive":"Chemical formulas in accessible format (LaTeX)"},"accessible-chemistry-as-mathml":{"compact":"Chemical formulas in MathML","descriptive":"Chemical formulas in accessible format (MathML)"},"accessible-math-as-latex":{"compact":"Math as LaTeX","descriptive":"Math formulas in accessible format (LaTeX)"},"accessible-math-described":"Text descriptions of math are provided","closed-captions":{"compact":"Videos have closed captions","descriptive":"Videos included in publications have closed captions"},"extended-descriptions":"Information-rich images are described by extended descriptions","math-as-mathml":{"compact":"Math as MathML","descriptive":"Math formulas in accessible format (MathML)"},"open-captions":{"compact":"Videos have open captions","descriptive":"Videos included in publications have open captions"},"title":"Rich content","transcript":"Transcript(s) provided","unknown":"No information is available"},"ways-of-reading":{"nonvisual-reading":{"alt-text":{"compact":"Has alternative text","descriptive":"Has alternative text descriptions for images"},"no-metadata":"No information about nonvisual reading is available","none":{"compact":"Not readable in read aloud or dynamic braille","descriptive":"The content is not readable as read aloud speech or dynamic braille"},"not-fully":{"compact":"Not fully readable in read aloud or dynamic braille","descriptive":"Not all of the content will be readable as read aloud speech or dynamic braille"},"readable":{"compact":"Readable in read aloud or dynamic braille","descriptive":"All content can be read as read aloud speech or dynamic braille"}},"prerecorded-audio":{"complementary":{"compact":"Prerecorded audio clips","descriptive":"Prerecorded audio clips are embedded in the content"},"no-metadata":"No information about prerecorded audio is available","only":{"compact":"Prerecorded audio only","descriptive":"Audiobook with no text alternative"},"synchronized":{"compact":"Prerecorded audio synchronized with text","descriptive":"All the content is available as prerecorded audio synchronized with text"}},"title":"Ways of reading","visual-adjustments":{"modifiable":{"compact":"Appearance can be modified","descriptive":"Appearance of the text and page layout can be modified according to the capabilities of the reading system (font family and font size, spaces between paragraphs, sentences, words, and letters, as well as color of background and text)"},"unknown":"No information about appearance modifiability is available","unmodifiable":{"compact":"Appearance cannot be modified","descriptive":"Text and page layout cannot be modified as the reading experience is close to a print version, but reading systems can still provide zooming options"}}}}},"altIdentifier_one":"alternate identifier","altIdentifier_other":"alternate identifiers","artist_one":"artist","artist_other":"artists","author_one":"author","author_other":"authors","collection_one":"editorial collection","collection_other":"editorial collections","colorist_one":"colorist","colorist_other":"colorists","contributor_one":"contributor","contributor_other":"contributors","description":"description","duration":"duration","editor_one":"editor","editor_other":"editors","identifier_one":"identifier","identifier_other":"identifiers","illustrator_one":"illustrator","illustrator_other":"illustrators","imprint_one":"imprint","imprint_other":"imprints","inker_one":"inker","inker_other":"inkers","language_one":"language","language_other":"languages","letterer_one":"letterer","letterer_other":"letterers","modified":"modification date","narrator_one":"narrator","narrator_other":"narrators","numberOfPages":"print length","penciler_one":"penciler","penciler_other":"pencilers","published":"publication date","publisher_one":"publisher","publisher_other":"publishers","series_one":"series","series_other":"series","subject_one":"subject","subject_other":"subjects","subtitle":"subtitle","title":"title","translator_one":"translator","translator_other":"translators"}}`)},et={fr:()=>Promise.resolve().then(()=>Ii),ar:()=>Promise.resolve().then(()=>zi),da:()=>Promise.resolve().then(()=>Oi),it:()=>Promise.resolve().then(()=>Ri),pt_PT:()=>Promise.resolve().then(()=>Di),sv:()=>Promise.resolve().then(()=>Mi)},tt=Xt?.publication?.metadata?.accessibility?.["display-guide"]||{};class q{constructor(){this.currentLocaleCode="en",this.locale=tt,this.loadedLocales={},this.loadedLocales.en=tt}static getInstance(){return q.instance||(q.instance=new q),q.instance}async loadLocale(e){if(!Qe.includes(e))return console.warn(`Locale '${e}' is not enabled`),!1;if(e in this.loadedLocales)return!0;try{if(!(e in et))return console.warn(`Locale file not found for: ${e}`),!1;const n=(await et[e]()).default?.publication?.metadata?.accessibility?.["display-guide"];return n?(this.loadedLocales[e]=n,!0):(console.warn(`No accessibility strings found in locale ${e}`),!1)}catch(t){return console.warn(`Failed to load locale ${e}:`,t),!1}}registerLocale(e,t){if(!e||typeof e!="string")throw new Error("Locale code must be a non-empty string");this.loadedLocales[e]=t}async setLocale(e){return e in this.loadedLocales||await this.loadLocale(e),e in this.loadedLocales?(this.locale=this.loadedLocales[e],this.currentLocaleCode=e,!0):(console.warn(`Locale '${e}' is not available`),!1)}getCurrentLocale(){return this.currentLocaleCode}getAvailableLocales(){return Qe}getNestedValue(e,t){const i=t.split(".");let n=e;for(const o of i){if(n==null)return;n=n[o]}return n}getString(e){let t=this.getNestedValue(this.locale,e);return t===void 0&&this.currentLocaleCode!=="en"&&(t=this.getNestedValue(this.loadedLocales.en,e)),t!==void 0?typeof t=="string"?{compact:t,descriptive:t}:t:(console.warn(`Missing localization for key: ${e}`),{compact:"",descriptive:""})}}q.getInstance();class we{constructor(e){this.algorithm=e.algorithm,this.compression=e.compression,this.originalLength=e.originalLength,this.profile=e.profile,this.scheme=e.scheme}static deserialize(e){if(e&&e.algorithm)return new we({algorithm:e.algorithm,compression:e.compression,originalLength:e.originalLength,profile:e.profile,scheme:e.scheme})}serialize(){const e={algorithm:this.algorithm};return this.compression!==void 0&&(e.compression=this.compression),this.originalLength!==void 0&&(e.originalLength=this.originalLength),this.profile!==void 0&&(e.profile=this.profile),this.scheme!==void 0&&(e.scheme=this.scheme),e}}class N{constructor(e){this.otherProperties=e}get page(){return this.otherProperties.page}static deserialize(e){if(e)return new N(e)}serialize(){return this.otherProperties}add(e){const t=Object.assign({},this.otherProperties);for(const i in e)t[i]=e[i];return new N(t)}}Object.defineProperty(N.prototype,"encryption",{get:function(){return we.deserialize(this.otherProperties.encrypted)}});function Yt(r){return r&&Array.isArray(r)?r:void 0}function it(r){return r&&typeof r=="string"?[r]:Yt(r)}function nt(r){return typeof r=="string"?new Date(r):void 0}function se(r){return isNaN(r)?void 0:r}function I(r){return se(r)!==void 0&&Math.sign(r)>=0?r:void 0}function Kt(r){const e=new Array;return r.forEach(t=>e.push(t)),e}class l{constructor(e){let t,i,n=e.mediaType.replace(/\s/g,"").split(";");const o=n[0].split("/");if(o.length===2){if(t=o[0].toLowerCase().trim(),i=o[1].toLowerCase().trim(),t.length===0||i.length===0)throw new Error("Invalid media type")}else throw new Error("Invalid media type");const s={};for(let m=1;m<n.length;m++){const y=n[m].split("=");if(y.length===2){const g=y[0].toLocaleLowerCase(),p=g==="charset"?y[1].toUpperCase():y[1];s[g]=p}}const a={},u=Object.keys(s);u.sort((m,y)=>m.localeCompare(y)),u.forEach(m=>a[m]=s[m]);let d="";for(const m in a){const y=a[m];d+=`;${m}=${y}`}const h=`${t}/${i}${d}`,f=a.encoding;this.string=h,this.type=t,this.subtype=i,this.parameters=a,this.encoding=f,this.name=e.name,this.fileExtension=e.fileExtension}static parse(e){return new l(e)}get structuredSyntaxSuffix(){const e=this.subtype.split("+");return e.length>1?`+${e[e.length-1]}`:void 0}get charset(){return this.parameters.charset}contains(e){const t=typeof e=="string"?l.parse({mediaType:e}):e;if(!((this.type==="*"||this.type===t.type)&&(this.subtype==="*"||this.subtype===t.subtype)))return!1;const i=new Set(Object.entries(this.parameters).map(([o,s])=>`${o}=${s}`)),n=new Set(Object.entries(t.parameters).map(([o,s])=>`${o}=${s}`));for(const o of Array.from(i.values()))if(!n.has(o))return!1;return!0}matches(e){const t=typeof e=="string"?l.parse({mediaType:e}):e;return this.contains(t)||t.contains(this)}matchesAny(...e){for(const t of e)if(this.matches(t))return!0;return!1}equals(e){return this.string===e.string}get isZIP(){return this.matchesAny(l.ZIP,l.LCP_PROTECTED_AUDIOBOOK,l.LCP_PROTECTED_PDF)||this.structuredSyntaxSuffix==="+zip"}get isJSON(){return this.matchesAny(l.JSON)||this.structuredSyntaxSuffix==="+json"}get isOPDS(){return this.matchesAny(l.OPDS1,l.OPDS1_ENTRY,l.OPDS2,l.OPDS2_PUBLICATION,l.OPDS_AUTHENTICATION)||this.structuredSyntaxSuffix==="+json"}get isHTML(){return this.matchesAny(l.HTML,l.XHTML)}get isBitmap(){return this.matchesAny(l.BMP,l.GIF,l.JPEG,l.PNG,l.TIFF,l.WEBP)}get isAudio(){return this.type==="audio"}get isVideo(){return this.type==="video"}get isRWPM(){return this.matchesAny(l.READIUM_AUDIOBOOK_MANIFEST,l.DIVINA_MANIFEST,l.READIUM_WEBPUB_MANIFEST)}get isPublication(){return this.matchesAny(l.READIUM_AUDIOBOOK,l.READIUM_AUDIOBOOK_MANIFEST,l.CBZ,l.DIVINA,l.DIVINA_MANIFEST,l.EPUB,l.LCP_PROTECTED_AUDIOBOOK,l.LCP_PROTECTED_PDF,l.LPF,l.PDF,l.W3C_WPUB_MANIFEST,l.READIUM_WEBPUB,l.READIUM_WEBPUB_MANIFEST,l.ZAB)}static get AAC(){return l.parse({mediaType:"audio/aac",fileExtension:"aac"})}static get ACSM(){return l.parse({mediaType:"application/vnd.adobe.adept+xml",name:"Adobe Content Server Message",fileExtension:"acsm"})}static get AIFF(){return l.parse({mediaType:"audio/aiff",fileExtension:"aiff"})}static get AVI(){return l.parse({mediaType:"video/x-msvideo",fileExtension:"avi"})}static get BINARY(){return l.parse({mediaType:"application/octet-stream"})}static get BMP(){return l.parse({mediaType:"image/bmp",fileExtension:"bmp"})}static get CBZ(){return l.parse({mediaType:"application/vnd.comicbook+zip",name:"Comic Book Archive",fileExtension:"cbz"})}static get CSS(){return l.parse({mediaType:"text/css",fileExtension:"css"})}static get DIVINA(){return l.parse({mediaType:"application/divina+zip",name:"Digital Visual Narratives",fileExtension:"divina"})}static get DIVINA_MANIFEST(){return l.parse({mediaType:"application/divina+json",name:"Digital Visual Narratives",fileExtension:"json"})}static get EPUB(){return l.parse({mediaType:"application/epub+zip",name:"EPUB",fileExtension:"epub"})}static get GIF(){return l.parse({mediaType:"image/gif",fileExtension:"gif"})}static get GZ(){return l.parse({mediaType:"application/gzip",fileExtension:"gz"})}static get HTML(){return l.parse({mediaType:"text/html",fileExtension:"html"})}static get JAVASCRIPT(){return l.parse({mediaType:"text/javascript",fileExtension:"js"})}static get JPEG(){return l.parse({mediaType:"image/jpeg",fileExtension:"jpeg"})}static get JSON(){return l.parse({mediaType:"application/json"})}static get LCP_LICENSE_DOCUMENT(){return l.parse({mediaType:"application/vnd.readium.lcp.license.v1.0+json",name:"LCP License",fileExtension:"lcpl"})}static get LCP_PROTECTED_AUDIOBOOK(){return l.parse({mediaType:"application/audiobook+lcp",name:"LCP Protected Audiobook",fileExtension:"lcpa"})}static get LCP_PROTECTED_PDF(){return l.parse({mediaType:"application/pdf+lcp",name:"LCP Protected PDF",fileExtension:"lcpdf"})}static get LCP_STATUS_DOCUMENT(){return l.parse({mediaType:"application/vnd.readium.license.status.v1.0+json"})}static get LPF(){return l.parse({mediaType:"application/lpf+zip",fileExtension:"lpf"})}static get MP3(){return l.parse({mediaType:"audio/mpeg",fileExtension:"mp3"})}static get MPEG(){return l.parse({mediaType:"video/mpeg",fileExtension:"mpeg"})}static get NCX(){return l.parse({mediaType:"application/x-dtbncx+xml",fileExtension:"ncx"})}static get OGG(){return l.parse({mediaType:"audio/ogg",fileExtension:"oga"})}static get OGV(){return l.parse({mediaType:"video/ogg",fileExtension:"ogv"})}static get OPDS1(){return l.parse({mediaType:"application/atom+xml;profile=opds-catalog"})}static get OPDS1_ENTRY(){return l.parse({mediaType:"application/atom+xml;type=entry;profile=opds-catalog"})}static get OPDS2(){return l.parse({mediaType:"application/opds+json"})}static get OPDS2_PUBLICATION(){return l.parse({mediaType:"application/opds-publication+json"})}static get OPDS_AUTHENTICATION(){return l.parse({mediaType:"application/opds-authentication+json"})}static get OPUS(){return l.parse({mediaType:"audio/opus",fileExtension:"opus"})}static get OTF(){return l.parse({mediaType:"font/otf",fileExtension:"otf"})}static get PDF(){return l.parse({mediaType:"application/pdf",name:"PDF",fileExtension:"pdf"})}static get PNG(){return l.parse({mediaType:"image/png",fileExtension:"png"})}static get READIUM_AUDIOBOOK(){return l.parse({mediaType:"application/audiobook+zip",name:"Readium Audiobook",fileExtension:"audiobook"})}static get READIUM_AUDIOBOOK_MANIFEST(){return l.parse({mediaType:"application/audiobook+json",name:"Readium Audiobook",fileExtension:"json"})}static get READIUM_CONTENT_DOCUMENT(){return l.parse({mediaType:"application/vnd.readium.content+json",name:"Readium Content Document",fileExtension:"json"})}static get READIUM_GUIDED_NAVIGATION_DOCUMENT(){return l.parse({mediaType:"application/guided-navigation+json",name:"Readium Guided Navigation Document",fileExtension:"json"})}static get READIUM_POSITION_LIST(){return l.parse({mediaType:"application/vnd.readium.position-list+json",name:"Readium Position List",fileExtension:"json"})}static get READIUM_WEBPUB(){return l.parse({mediaType:"application/webpub+zip",name:"Readium Web Publication",fileExtension:"webpub"})}static get READIUM_WEBPUB_MANIFEST(){return l.parse({mediaType:"application/webpub+json",name:"Readium Web Publication",fileExtension:"json"})}static get SMIL(){return l.parse({mediaType:"application/smil+xml",fileExtension:"smil"})}static get SVG(){return l.parse({mediaType:"image/svg+xml",fileExtension:"svg"})}static get TEXT(){return l.parse({mediaType:"text/plain",fileExtension:"txt"})}static get TIFF(){return l.parse({mediaType:"image/tiff",fileExtension:"tiff"})}static get TTF(){return l.parse({mediaType:"font/ttf",fileExtension:"ttf"})}static get W3C_WPUB_MANIFEST(){return l.parse({mediaType:"application/x.readium.w3c.wpub+json",name:"Web Publication",fileExtension:"json"})}static get WAV(){return l.parse({mediaType:"audio/wav",fileExtension:"wav"})}static get WEBM_AUDIO(){return l.parse({mediaType:"audio/webm",fileExtension:"webm"})}static get WEBM_VIDEO(){return l.parse({mediaType:"video/webm",fileExtension:"webm"})}static get WEBP(){return l.parse({mediaType:"image/webp",fileExtension:"webp"})}static get WOFF(){return l.parse({mediaType:"font/woff",fileExtension:"woff"})}static get WOFF2(){return l.parse({mediaType:"font/woff2",fileExtension:"woff2"})}static get XHTML(){return l.parse({mediaType:"application/xhtml+xml",fileExtension:"xhtml"})}static get XML(){return l.parse({mediaType:"application/xml",fileExtension:"xml"})}static get ZAB(){return l.parse({mediaType:"application/x.readium.zab+zip",name:"Zipped Audio Book",fileExtension:"zab"})}static get ZIP(){return l.parse({mediaType:"application/zip",fileExtension:"zip"})}}class ot{constructor(e){this.uri=e,this.parameters=this.getParameters(e)}getParameters(e){const t=/\{\??([^}]+)\}/g,i=e.match(t);return i?new Set(i.join(",").replace(t,"$1").split(",").map(n=>n.trim())):new Set}expand(e){const t=n=>n.split(",").map(o=>{const s=e[o];return s?encodeURIComponent(s):""}).join(","),i=n=>"?"+n.split(",").map(o=>{const s=o.split("=")[0],a=e[s];return a?`${s}=${encodeURIComponent(a)}`:""}).join("&");return this.uri.replace(/\{(\??)([^}]+)\}/g,(...n)=>n[1]?i(n[2]):t(n[2]))}}class E{constructor(e){this.fragments=e.fragments?e.fragments:new Array,this.progression=e.progression,this.totalProgression=e.totalProgression,this.position=e.position,this.otherLocations=e.otherLocations}static deserialize(e){if(!e)return;const t=se(e.progression),i=se(e.totalProgression),n=se(e.position),o=new Map,s=new Set(["fragment","fragments","progression","totalProgression","position"]);return Object.entries(e).forEach(([a,u])=>{s.has(a)||o.set(a,u)}),new E({fragments:it(e.fragments||e.fragment),progression:t!==void 0&&t>=0&&t<=1?t:void 0,totalProgression:i!==void 0&&i>=0&&i<=1?i:void 0,position:n!==void 0&&n>0?n:void 0,otherLocations:o.size===0?void 0:o})}serialize(){const e={};return this.fragments&&(e.fragments=this.fragments),this.progression!==void 0&&(e.progression=this.progression),this.totalProgression!==void 0&&(e.totalProgression=this.totalProgression),this.position!==void 0&&(e.position=this.position),this.otherLocations&&this.otherLocations.forEach((t,i)=>e[i]=t),e}}class B{constructor(e){this.after=e.after,this.before=e.before,this.highlight=e.highlight}static deserialize(e){if(e)return new B({after:e.after,before:e.before,highlight:e.highlight})}serialize(){const e={};return this.after!==void 0&&(e.after=this.after),this.before!==void 0&&(e.before=this.before),this.highlight!==void 0&&(e.highlight=this.highlight),e}}class D{constructor(e){this.href=e.href,this.type=e.type,this.title=e.title,this.locations=e.locations?e.locations:new E({}),this.text=e.text}static deserialize(e){if(e&&e.href&&e.type)return new D({href:e.href,type:e.type,title:e.title,locations:E.deserialize(e.locations),text:B.deserialize(e.text)})}serialize(){const e={href:this.href,type:this.type};return this.title!==void 0&&(e.title=this.title),this.locations&&(e.locations=this.locations.serialize()),this.text&&(e.text=this.text.serialize()),e}copyWithLocations(e){return new D({href:this.href,type:this.type,title:this.title,text:this.text,locations:new E({...this.locations,...e})})}}class ${constructor(e){this.href=e.href,this.templated=e.templated,this.type=e.type,this.title=e.title,this.rels=e.rels,this.properties=e.properties,this.height=e.height,this.width=e.width,this.size=e.size,this.duration=e.duration,this.bitrate=e.bitrate,this.languages=e.languages,this.alternates=e.alternates,this.children=e.children}static deserialize(e){if(!(!e||typeof e.href!="string"))return new $({href:e.href,templated:e.templated,type:e.type,title:e.title,rels:e.rel?Array.isArray(e.rel)?new Set(e.rel):new Set([e.rel]):void 0,properties:N.deserialize(e.properties),height:I(e.height),width:I(e.width),size:I(e.size),duration:I(e.duration),bitrate:I(e.bitrate),languages:it(e.language),alternates:ae.deserialize(e.alternate),children:ae.deserialize(e.children)})}serialize(){const e={href:this.href};return this.templated!==void 0&&(e.templated=this.templated),this.type!==void 0&&(e.type=this.type),this.title!==void 0&&(e.title=this.title),this.rels&&(e.rel=Kt(this.rels)),this.properties&&(e.properties=this.properties.serialize()),this.height!==void 0&&(e.height=this.height),this.width!==void 0&&(e.width=this.width),this.size!==void 0&&(e.size=this.size),this.duration!==void 0&&(e.duration=this.duration),this.bitrate!==void 0&&(e.bitrate=this.bitrate),this.languages&&(e.language=this.languages),this.alternates&&(e.alternate=this.alternates.serialize()),this.children&&(e.children=this.children.serialize()),e}get mediaType(){return this.type!==void 0?l.parse({mediaType:this.type}):l.BINARY}toURL(e){const t=this.href.replace(/^(\/)/,"");if(t.length===0)return;let i=e||"/";return i.startsWith("/")&&(i="file://"+i),new URL(t,i).href.replace(/^(file:\/\/)/,"")}get templateParameters(){return this.templated?new ot(this.href).parameters:new Set}expandTemplate(e){return new $({href:new ot(this.href).expand(e),templated:!1})}addProperties(e){const t=$.deserialize(this.serialize());return t.properties=t.properties?t.properties?.add(e):new N(e),t}get locator(){let e=this.href.split("#");return new D({href:e.length>0&&e[0]!==void 0?e[0]:this.href,type:this.type??"",title:this.title,locations:new E({fragments:e.length>1&&e[1]!==void 0?[e[1]]:[]})})}}class ae{constructor(e){this.items=e}static deserialize(e){if(e&&Array.isArray(e))return new ae(e.map(t=>$.deserialize(t)).filter(t=>t!==void 0))}serialize(){return this.items.map(e=>e.serialize())}findWithRel(e){const t=i=>i.rels&&i.rels.has(e);return this.items.find(t)}filterByRel(e){const t=i=>i.rels&&i.rels.has(e);return this.items.filter(t)}findWithHref(e){const t=i=>i.href===e;return this.items.find(t)}findIndexWithHref(e){const t=i=>i.href===e;return this.items.findIndex(t)}findWithMediaType(e){const t=i=>i.mediaType.matches(e);return this.items.find(t)}filterByMediaType(e){const t=i=>i.mediaType.matches(e);return this.items.filter(t)}filterByMediaTypes(e){const t=i=>{for(const n of e)if(i.mediaType.matches(n))return!0;return!1};return this.items.filter(t)}everyIsAudio(){const e=t=>t.mediaType.isAudio;return this.items.length>0&&this.items.every(e)}everyIsBitmap(){const e=t=>t.mediaType.isBitmap;return this.items.length>0&&this.items.every(e)}everyIsHTML(){const e=t=>t.mediaType.isHTML;return this.items.length>0&&this.items.every(e)}everyIsVideo(){const e=t=>t.mediaType.isVideo;return this.items.length>0&&this.items.every(e)}everyMatchesMediaType(e){return Array.isArray(e)?this.items.length>0&&this.items.every(t=>{for(const i of e)return t.mediaType.matches(i);return!1}):this.items.length>0&&this.items.every(t=>t.mediaType.matches(e))}filterLinksHasType(){return this.items.filter(e=>e.type)}}N.prototype.getContains=function(){return new Set(this.otherProperties.contains||[])};class le{constructor(e){this.cssSelector=e.cssSelector,this.textNodeIndex=e.textNodeIndex,this.charOffset=e.charOffset}static deserialize(e){if(!(e&&e.cssSelector))return;let t=I(e.textNodeIndex);if(t===void 0)return;let i=I(e.charOffset);return i===void 0&&(i=I(e.offset)),new le({cssSelector:e.cssSelector,textNodeIndex:t,charOffset:i})}serialize(){const e={cssSelector:this.cssSelector,textNodeIndex:this.textNodeIndex};return this.charOffset!==void 0&&(e.charOffset=this.charOffset),e}}class ke{constructor(e){this.start=e.start,this.end=e.end}static deserialize(e){if(!e)return;let t=le.deserialize(e.start);if(t)return new ke({start:t,end:le.deserialize(e.end)})}serialize(){const e={start:this.start.serialize()};return this.end&&(e.end=this.end.serialize()),e}}E.prototype.getCssSelector=function(){return this.otherLocations?.get("cssSelector")},E.prototype.getPartialCfi=function(){return this.otherLocations?.get("partialCfi")},E.prototype.getDomRange=function(){return ke.deserialize(this.otherLocations?.get("domRange"))},E.prototype.fragmentParameters=function(){return new Map(this.fragments.map(r=>r.startsWith("#")?r.slice(1):r).join("&").split("&").filter(r=>!r.startsWith("#")).map(r=>r.split("=")).filter(r=>r.length===2).map(r=>[r[0].trim().toLowerCase(),r[1].trim()]))},E.prototype.htmlId=function(){if(!this.fragments.length)return;let r=this.fragments.find(e=>e.length&&!e.includes("="));if(!r){const e=this.fragmentParameters();e.has("id")?r=e.get("id"):e.has("name")&&(r=e.get("name"))}return r?.startsWith("#")?r.slice(1):r},E.prototype.page=function(){const r=parseInt(this.fragmentParameters().get("page"));if(!isNaN(r)&&r>=0)return r},E.prototype.time=function(){const r=parseInt(this.fragmentParameters().get("t"));if(!isNaN(r))return r},E.prototype.space=function(){const r=this.fragmentParameters();if(!r.has("xywh"))return;const e=r.get("xywh").split(",").map(t=>parseInt(t));if(e.length===4&&!e.some(isNaN))return e},E.prototype.text=function(){const r=this.fragmentParameters();console.log(r)};class Se{constructor(e){this.currency=e.currency,this.value=e.value}static deserialize(e){if(!e)return;let t=e.currency;if(!(t&&typeof t=="string"&&t.length>0))return;let i=I(e.value);if(i!==void 0)return new Se({currency:t,value:i})}serialize(){return{currency:this.currency,value:this.value}}}class J{constructor(e){this.type=e.type,this.children=e.children}static deserialize(e){if(e&&e.type)return new J({type:e.type,children:J.deserializeArray(e.children)})}static deserializeArray(e){if(Array.isArray(e))return e.map(t=>J.deserialize(t)).filter(t=>t!==void 0)}serialize(){const e={type:this.type};return this.children&&(e.children=this.children.map(t=>t.serialize())),e}}class Ee{constructor(e){this.total=e.total,this.position=e.position}static deserialize(e){if(e)return new Ee({total:I(e.total),position:I(e.position)})}serialize(){const e={};return this.total!==void 0&&(e.total=this.total),this.position!==void 0&&(e.position=this.position),e}}class Ce{constructor(e){this.total=e.total,this.available=e.available}static deserialize(e){if(e)return new Ce({total:I(e.total),available:I(e.available)})}serialize(){const e={};return this.total!==void 0&&(e.total=this.total),this.available!==void 0&&(e.available=this.available),e}}class xe{constructor(e){this.state=e.state,this.since=e.since,this.until=e.until}static deserialize(e){if(e&&e.state)return new xe({state:e.state,since:nt(e.since),until:nt(e.until)})}serialize(){const e={state:this.state};return this.since!==void 0&&(e.since=this.since.toISOString()),this.until!==void 0&&(e.until=this.until.toISOString()),e}}N.prototype.getNumberOfItems=function(){return I(this.otherProperties.numberOfItems)},N.prototype.getPrice=function(){return Se.deserialize(this.otherProperties.price)},N.prototype.getIndirectAcquisitions=function(){const r=this.otherProperties.indirectAcquisition;if(r&&Array.isArray(r))return r.map(e=>J.deserialize(e)).filter(e=>e!==void 0)},N.prototype.getHolds=function(){return Ee.deserialize(this.otherProperties.holds)},N.prototype.getCopies=function(){return Ce.deserialize(this.otherProperties.copies)},N.prototype.getAvailability=function(){return xe.deserialize(this.otherProperties.availability)},N.prototype.getAuthenticate=function(){return $.deserialize(this.otherProperties.authenticate)};const Jt="CssSelectorGenerator";function rt(r="unknown problem",...e){console.warn(`${Jt}: ${r}`,...e)}function Zt(r){return r instanceof RegExp}function Qt(r){return r.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".+")}function ei(r){const e=r.map(t=>{if(Zt(t))return i=>t.test(i);if(typeof t=="function")return i=>{const n=t(i);return typeof n!="boolean"?(rt("pattern matcher function invalid","Provided pattern matching function does not return boolean. It's result will be ignored.",t),!1):n};if(typeof t=="string"){const i=new RegExp("^"+Qt(t)+"$");return n=>i.test(n)}return rt("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",t),()=>!1});return t=>e.some(i=>i(t))}ei(["class","id","ng-*"]);class G{}function st(r){return r.split("").reverse().join("")}function ti(r,e,t){const i=st(e);return t.map(n=>{const o=Math.max(0,n.end-e.length-n.errors),s=st(r.slice(o,n.end));return{start:lt(s,i,n.errors).reduce((u,d)=>n.end-d.end<u?n.end-d.end:u,n.end),end:n.end,errors:n.errors}})}function Pe(r){return(r|-r)>>31&1}function at(r,e,t,i){let n=r.P[t],o=r.M[t];const s=i>>>31,a=e[t]|s,u=a|o,d=(a&n)+n^n|a;let h=o|~(d|n),f=n&d;const m=Pe(h&r.lastRowMask[t])-Pe(f&r.lastRowMask[t]);return h<<=1,f<<=1,f|=s,h|=Pe(i)-s,n=f|~(u|h),o=h&u,r.P[t]=n,r.M[t]=o,m}function lt(r,e,t){if(e.length===0)return[];t=Math.min(t,e.length);const i=[],n=32,o=Math.ceil(e.length/n)-1,s={P:new Uint32Array(o+1),M:new Uint32Array(o+1),lastRowMask:new Uint32Array(o+1)};s.lastRowMask.fill(1<<31),s.lastRowMask[o]=1<<(e.length-1)%n;const a=new Uint32Array(o+1),u=new Map,d=[];for(let m=0;m<256;m++)d.push(a);for(let m=0;m<e.length;m+=1){const y=e.charCodeAt(m);if(u.has(y))continue;const g=new Uint32Array(o+1);u.set(y,g),y<d.length&&(d[y]=g);for(let p=0;p<=o;p+=1){g[p]=0;for(let v=0;v<n;v+=1){const x=p*n+v;if(x>=e.length)continue;e.charCodeAt(x)===y&&(g[p]|=1<<v)}}}let h=Math.max(0,Math.ceil(t/n)-1);const f=new Uint32Array(o+1);for(let m=0;m<=h;m+=1)f[m]=(m+1)*n;f[o]=e.length;for(let m=0;m<=h;m+=1)s.P[m]=-1,s.M[m]=0;for(let m=0;m<r.length;m+=1){const y=r.charCodeAt(m);let g;y<d.length?g=d[y]:(g=u.get(y),typeof g>"u"&&(g=a));let p=0;for(let v=0;v<=h;v+=1)p=at(s,g,v,p),f[v]+=p;if(f[h]-p<=t&&h<o&&(g[h+1]&1||p<0)){h+=1,s.P[h]=-1,s.M[h]=0;let v;if(h===o){const x=e.length%n;v=x===0?n:x}else v=n;f[h]=f[h-1]+v-p+at(s,g,h,p)}else for(;h>0&&f[h]>=t+n;)h-=1;h===o&&f[h]<=t&&(f[h]<t&&i.splice(0,i.length),i.push({start:-1,end:m+1,errors:f[h]}),t=f[h])}return i}function ii(r,e,t){const i=lt(r,e,t);return ti(r,e,i)}function ct(r,e,t){let i=0;const n=[];for(;i!==-1;)i=r.indexOf(e,i),i!==-1&&(n.push({start:i,end:i+e.length,errors:0}),i+=1);return n.length>0?n:ii(r,e,t)}function dt(r,e){return e.length===0||r.length===0?0:1-ct(r,e,e.length)[0].errors/e.length}function ni(r,e,t={}){if(e.length===0)return null;const i=Math.min(256,e.length/2),n=ct(r,e,i);if(n.length===0)return null;const o=a=>{const m=1-a.errors/e.length,y=t.prefix?dt(r.slice(Math.max(0,a.start-t.prefix.length),a.start),t.prefix):1,g=t.suffix?dt(r.slice(a.end,a.end+t.suffix.length),t.suffix):1;let p=1;return typeof t.hint=="number"&&(p=1-Math.abs(a.start-t.hint)/r.length),(50*m+20*y+20*g+2*p)/92},s=n.map(a=>({start:a.start,end:a.end,score:o(a)}));return s.sort((a,u)=>u.score-a.score),s[0]}function Te(r,e,t){const i=t===1?e:e-1;if(r.charAt(i).trim()!=="")return e;let n,o;if(t===2?(n=r.substring(0,e),o=n.trimEnd()):(n=r.substring(e),o=n.trimStart()),!o.length)return-1;const s=n.length-o.length;return t===2?e-s:e+s}function ut(r,e){const t=r.commonAncestorContainer.ownerDocument.createNodeIterator(r.commonAncestorContainer,NodeFilter.SHOW_TEXT),i=e===1?r.startContainer:r.endContainer,n=e===1?r.endContainer:r.startContainer;let o=t.nextNode();for(;o&&o!==i;)o=t.nextNode();e===2&&(o=t.previousNode());let s=-1;const a=()=>{if(o=e===1?t.nextNode():t.previousNode(),o){const u=o.textContent,d=e===1?0:u.length;s=Te(u,d,e)}};for(;o&&s===-1&&o!==n;)a();if(o&&s>=0)return{node:o,offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function oi(r){if(!r.toString().trim().length)throw new RangeError("Range contains no non-whitespace text");if(r.startContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range startContainer is not a text node");if(r.endContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range endContainer is not a text node");const e=r.cloneRange();let t=!1,i=!1;const n={start:Te(r.startContainer.textContent,r.startOffset,1),end:Te(r.endContainer.textContent,r.endOffset,2)};if(n.start>=0&&(e.setStart(r.startContainer,n.start),t=!0),n.end>0&&(e.setEnd(r.endContainer,n.end),i=!0),t&&i)return e;if(!t){const{node:o,offset:s}=ut(e,1);o&&s>=0&&e.setStart(o,s)}if(!i){const{node:o,offset:s}=ut(e,2);o&&s>0&&e.setEnd(o,s)}return e}function ht(r){switch(r.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return r.textContent?.length??0;default:return 0}}function pt(r){let e=r.previousSibling,t=0;for(;e;)t+=ht(e),e=e.previousSibling;return t}function mt(r,...e){let t=e.shift();const i=r.ownerDocument.createNodeIterator(r,NodeFilter.SHOW_TEXT),n=[];let o=i.nextNode(),s,a=0;for(;t!==void 0&&o;)s=o,a+s.data.length>t?(n.push({node:s,offset:t-a}),t=e.shift()):(o=i.nextNode(),a+=s.data.length);for(;t!==void 0&&s&&a===t;)n.push({node:s,offset:s.data.length}),t=e.shift();if(t!==void 0)throw new RangeError("Offset exceeds text length");return n}class O{constructor(e,t){if(t<0)throw new Error("Offset is invalid");this.element=e,this.offset=t}relativeTo(e){if(!e.contains(this.element))throw new Error("Parent is not an ancestor of current element");let t=this.element,i=this.offset;for(;t!==e;)i+=pt(t),t=t.parentElement;return new O(t,i)}resolve(e={}){try{return mt(this.element,this.offset)[0]}catch(t){if(this.offset===0&&e.direction!==void 0){const i=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);i.currentNode=this.element;const n=e.direction===1,o=n?i.nextNode():i.previousNode();if(!o)throw t;return{node:o,offset:n?0:o.data.length}}else throw t}}static fromCharOffset(e,t){switch(e.nodeType){case Node.TEXT_NODE:return O.fromPoint(e,t);case Node.ELEMENT_NODE:return new O(e,t);default:throw new Error("Node is not an element or text node")}}static fromPoint(e,t){switch(e.nodeType){case Node.TEXT_NODE:{if(t<0||t>e.data.length)throw new Error("Text node offset is out of range");if(!e.parentElement)throw new Error("Text node has no parent");const i=pt(e)+t;return new O(e.parentElement,i)}case Node.ELEMENT_NODE:{if(t<0||t>e.childNodes.length)throw new Error("Child node offset is out of range");let i=0;for(let n=0;n<t;n++)i+=ht(e.childNodes[n]);return new O(e,i)}default:throw new Error("Point is not in an element or text node")}}}class U{constructor(e,t){this.start=e,this.end=t}relativeTo(e){return new U(this.start.relativeTo(e),this.end.relativeTo(e))}toRange(){let e,t;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[e,t]=mt(this.start.element,this.start.offset,this.end.offset):(e=this.start.resolve({direction:1}),t=this.end.resolve({direction:2}));const i=new Range;return i.setStart(e.node,e.offset),i.setEnd(t.node,t.offset),i}static fromRange(e){const t=O.fromPoint(e.startContainer,e.startOffset),i=O.fromPoint(e.endContainer,e.endOffset);return new U(t,i)}static fromOffsets(e,t,i){return new U(new O(e,t),new O(e,i))}static trimmedRange(e){return oi(U.fromRange(e).toRange())}}class ce{constructor(e,t,i){this.root=e,this.start=t,this.end=i}static fromRange(e,t){const i=U.fromRange(t).relativeTo(e);return new ce(e,i.start.offset,i.end.offset)}static fromSelector(e,t){return new ce(e,t.start,t.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){return U.fromOffsets(this.root,this.start,this.end).toRange()}}class de{constructor(e,t,i={}){this.root=e,this.exact=t,this.context=i}static fromRange(e,t){const i=e.textContent,n=U.fromRange(t).relativeTo(e),o=n.start.offset,s=n.end.offset,a=32;return new de(e,i.slice(o,s),{prefix:i.slice(Math.max(0,o-a),o),suffix:i.slice(s,Math.min(i.length,s+a))})}static fromSelector(e,t){const{prefix:i,suffix:n}=t;return new de(e,t.exact,{prefix:i,suffix:n})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(e={}){return this.toPositionAnchor(e).toRange()}toPositionAnchor(e={}){const t=this.root.textContent,i=ni(t,this.exact,{...this.context,hint:e.hint});if(!i)throw new Error("Quote not found");return new ce(this.root,i.start,i.end)}}function ri(r){const e=r.tagName.toUpperCase();return e==="IMG"||e==="VIDEO"||e==="AUDIO"||e==="IFRAME"||e==="OBJECT"||e==="EMBED"||e==="CANVAS"}function ue(r,e){try{const t=e.locations,i=e.text;if(i&&i.highlight){let n;t&&t.getCssSelector()&&(n=r.querySelector(t.getCssSelector())),n||(n=r.body);const o=new de(n,i.highlight,{prefix:i.before,suffix:i.after});try{return o.toRange()}catch{return console.warn("Quote not found:",o),null}}if(t){let n=null;if(!n&&t.getCssSelector()&&(n=r.querySelector(t.getCssSelector())),!n&&t.fragments){for(const o of t.fragments)if(n=r.getElementById(o),n)break}if(n){const o=r.createRange();return n.childNodes.length===0||ri(n)?(o.selectNode(n),o):(o.setStartBefore(n),o.setEndAfter(n),o)}}}catch(t){console.error(t)}return null}function si(r,e){let t=r.getClientRects();t.length||r.commonAncestorContainer.nodeType===Node.ELEMENT_NODE&&(t=r.commonAncestorContainer.getClientRects());const i=1,n=[];for(const d of t)n.push({bottom:d.bottom,height:d.height,left:d.left,right:d.right,top:d.top,width:d.width});const o=gt(n,i),s=li(o,i),a=ft(s),u=4;for(let d=a.length-1;d>=0;d--){const h=a[d];if(!(h.width*h.height>u))if(a.length>1)a.splice(d,1);else break}return a}function gt(r,e,t){for(let i=0;i<r.length;i++)for(let n=i+1;n<r.length;n++){const o=r[i],s=r[n];if(o===s)continue;const a=z(o.top,s.top,e)&&z(o.bottom,s.bottom,e),u=z(o.left,s.left,e)&&z(o.right,s.right,e);if(a&&!u&&vt(o,s,e)){const f=r.filter(y=>y!==o&&y!==s),m=ai(o,s);return f.push(m),gt(f,e)}}return r}function ai(r,e){const t=Math.min(r.left,e.left),i=Math.max(r.right,e.right),n=Math.min(r.top,e.top),o=Math.max(r.bottom,e.bottom);return{bottom:o,height:o-n,left:t,right:i,top:n,width:i-t}}function li(r,e){const t=new Set(r);for(const i of r){if(!(i.width>1&&i.height>1)){t.delete(i);continue}for(const o of r)if(i!==o&&t.has(o)&&ci(o,i,e)){t.delete(i);break}}return Array.from(t)}function ci(r,e,t){return he(r,e.left,e.top,t)&&he(r,e.right,e.top,t)&&he(r,e.left,e.bottom,t)&&he(r,e.right,e.bottom,t)}function he(r,e,t,i){return(r.left<e||z(r.left,e,i))&&(r.right>e||z(r.right,e,i))&&(r.top<t||z(r.top,t,i))&&(r.bottom>t||z(r.bottom,t,i))}function ft(r){for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){const i=r[e],n=r[t];if(i!==n&&vt(i,n,-1)){let o=[],s;const a=bt(i,n);if(a.length===1)o=a,s=i;else{const d=bt(n,i);a.length<d.length?(o=a,s=i):(o=d,s=n)}const u=r.filter(d=>d!==s);return Array.prototype.push.apply(u,o),ft(u)}}return r}function bt(r,e){const t=di(e,r);if(t.height===0||t.width===0)return[r];const i=[];{const n={bottom:r.bottom,height:0,left:r.left,right:t.left,top:r.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&i.push(n)}{const n={bottom:t.top,height:0,left:t.left,right:t.right,top:r.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&i.push(n)}{const n={bottom:r.bottom,height:0,left:t.left,right:t.right,top:t.bottom,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&i.push(n)}{const n={bottom:r.bottom,height:0,left:t.right,right:r.right,top:r.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&i.push(n)}return i}function di(r,e){const t=Math.max(r.left,e.left),i=Math.min(r.right,e.right),n=Math.max(r.top,e.top),o=Math.min(r.bottom,e.bottom);return{bottom:o,height:Math.max(0,o-n),left:t,right:i,top:n,width:Math.max(0,i-t)}}function vt(r,e,t){return(r.left<e.right||t>=0&&z(r.left,e.right,t))&&(e.left<r.right||t>=0&&z(e.left,r.right,t))&&(r.top<e.bottom||t>=0&&z(r.top,e.bottom,t))&&(e.top<r.bottom||t>=0&&z(e.top,r.bottom,t))}function z(r,e,t){return Math.abs(r-e)<=t}const Le=()=>typeof window.CSSTransformValue<"u";function _e(r){const e={},t=r.document.documentElement.style;for(const i in r.document.documentElement.style)Object.hasOwn(t,i)&&!Number.isNaN(Number.parseInt(i))&&(e[t[i]]=t.getPropertyValue(t[i]));return e}function yt(r,e){const t=_e(r);Object.keys(t).forEach(i=>{e.hasOwnProperty(i)||pe(r,i)}),Object.entries(e).forEach(([i,n])=>{t[i]!==n&&Z(r,i,n)})}function Ne(r,e){return r.document.documentElement.style.getPropertyValue(e)}function Z(r,e,t){r.document.documentElement.style.setProperty(e,t)}function pe(r,e){r.document.documentElement.style.removeProperty(e)}let me=null,Ie=null,Q=0;const j={r:255,g:255,b:255,a:1},X=new Map,ui=()=>{if(!me)if(typeof OffscreenCanvas<"u")me=new OffscreenCanvas(5,5),Ie=me.getContext("2d",{willReadFrequently:!0,desynchronized:!0});else{const r=document.createElement("canvas");r.width=5,r.height=5,me=r,Ie=r.getContext("2d",{willReadFrequently:!0,desynchronized:!0})}return Ie},hi=r=>{if(!r)return!0;const e=r.trim().toLowerCase();return e.startsWith("var(")||["transparent","currentcolor","inherit","initial","revert","unset","revert-layer"].includes(e)?!0:["linear-gradient","radial-gradient","conic-gradient","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient"].some(n=>e.includes(n))},ge=(r,e)=>{console.warn(`[Decorator] Could not parse color: "${r}". ${e} Falling back to ${JSON.stringify(j)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`)},ze=(r,e=null)=>{const t=e?`${r}|${e}`:r,i=X.get(t);if(i!==void 0)return i??j;if(hi(r))return ge(r,"Unsupported color format or special value."),X.set(t,null),j;const n=ui();if(!n)return ge(r,"Could not get canvas context."),X.set(t,null),j;try{Q===0&&n.clearRect(0,0,5,5);const o=Q%5,s=Math.floor(Q/5);n.clearRect(o,s,1,1),e&&(n.fillStyle=e,n.fillRect(o,s,1,1)),n.fillStyle=r,n.fillRect(o,s,1,1);const a=n.getImageData(o,s,1,1);Q=(Q+1)%25;const[u,d,h,f]=a.data;if(f===0)return ge(r,"Fully transparent color."),X.set(t,null),j;const m={r:u,g:d,b:h,a:f/255};return X.set(t,m),m}catch(o){return ge(r,`Error: ${o instanceof Error?o.message:String(o)}`),X.set(t,null),j}},Oe=r=>{const e=r/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)},At=r=>{const e=Oe(r.r),t=Oe(r.g),i=Oe(r.b);return .2126*e+.7152*t+.0722*i},wt=(r,e)=>{const t=typeof r=="string"?ze(r):r,i=typeof e=="string"?ze(e):e,n=At(t),o=At(i),s=Math.max(n,o),a=Math.min(n,o);return(s+.05)/(a+.05)},Re=(r,e=null)=>{const t=ze(r,e),i=wt(t,{r:255,g:255,b:255,a:1}),n=wt(t,{r:0,g:0,b:0,a:1});return i>n},pi=(r,e=null)=>Re(r,e)?"white":"black",kt="#FFFF00";var St=(r=>(r.Wrap="wrap",r.Viewport="viewport",r.Bounds="bounds",r.Page="page",r))(St||{}),Et=(r=>(r.Boxes="boxes",r.Bounds="bounds",r))(Et||{});const mi=()=>"Highlight"in window,Ct=["IMG","IMAGE","AUDIO","VIDEO","SVG"];class gi{constructor(e,t,i,n){this.wnd=e,this.comms=t,this.id=i,this.name=n,this.items=[],this.lastItemId=0,this.container=void 0,this.activateable=!1,this.experimentalHighlights=!1,this.currentRender=0,mi()&&(this.experimentalHighlights=!0,this.notTextFlag=new Map)}get activeable(){return this.activateable}set activeable(e){this.activateable=e}add(e){const t=`${this.id}-${this.lastItemId++}`,i=ue(this.wnd.document,e.locator);if(!i){this.comms.log("Can't locate DOM range for decoration",e);return}const n=i.commonAncestorContainer;n.nodeType!==Node.TEXT_NODE&&this.experimentalHighlights&&(Ct.includes(n.nodeName.toUpperCase())&&this.notTextFlag?.set(t,!0),i.cloneContents().querySelector(Ct.join(", ").toLowerCase())&&this.notTextFlag?.set(t,!0),(n.textContent?.trim()||"").length===0&&this.notTextFlag?.set(t,!0));const o={decoration:e,id:t,range:i};this.items.push(o),this.layout(o),this.renderLayout([o])}remove(e){const t=this.items.findIndex(n=>n.decoration.id===e);if(t<0)return;const i=this.items[t];this.items.splice(t,1),i.clickableElements=void 0,i.container&&(i.container.remove(),i.container=void 0),this.experimentalHighlights&&!this.notTextFlag?.has(i.id)&&this.wnd.CSS.highlights.get(this.id)?.delete(i.range),this.notTextFlag?.delete(i.id)}update(e){this.remove(e.id),this.add(e)}clear(){this.clearContainer(),this.items.length=0,this.notTextFlag?.clear()}requestLayout(){this.wnd.cancelAnimationFrame(this.currentRender),this.clearContainer(),this.items.forEach(e=>this.layout(e)),this.renderLayout(this.items)}experimentalLayout(e){const[t,i]=this.requireContainer(!0);i.add(e.range);const n=Ne(this.wnd,"--USER__backgroundColor")||this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"),o=e.decoration?.style?.tint??kt;t.innerHTML=`
2
2
  ::highlight(${this.id}) {
3
3
  color: ${pi(o,n)};
4
4
  background-color: ${o};
@@ -13,7 +13,7 @@
13
13
  html, body {
14
14
  touch-action: manipulation;
15
15
  user-select: ${this.protected?"none":"auto"};
16
- }`}mount(e,t){const i=e.document.createElement("style");return i.dataset.readium="true",i.id=xt,i.textContent=this.buildStyles(),e.document.head.appendChild(i),t.register("protect",ie.moduleName,(n,o)=>{this.protected=!0,i.textContent=this.buildStyles(),o(!0)}),t.register("unprotect",ie.moduleName,(n,o)=>{this.protected=!1,i.textContent=this.buildStyles(),o(!0)}),t.log("Snapper Mounted"),!0}unmount(e,t){return e.document.getElementById(xt)?.remove(),t.log("Snapper Unmounted"),!0}};ie.moduleName="snapper";let ee=ie;function H(r){return r.document.body.dir.toLowerCase()==="rtl"}function Pt(r){return parseInt(r.getComputedStyle(r.document.documentElement).getPropertyValue("column-count"))}function Tt(r){const e=getComputedStyle(r),t=parseFloat(e.paddingTop||"0"),i=parseFloat(e.paddingBottom||"0");return r.clientHeight-t-i}function Lt(r){const e=Pt(r);if(!e)return!1;const t=r.document.querySelectorAll("div[id^='readium-virtual-page']");for(const d of t)d.remove();const i=t.length,n=r.document.scrollingElement.scrollWidth,o=r.visualViewport.width,a=Math.round(n/o*e)%e,u=e===1||a===0?0:e-a;if(u>0)for(let d=0;d<u;d++){const h=r.document.createElement("div");h.setAttribute("id",`readium-virtual-page-${d}`),h.dataset.readium="true",CSS.supports("break-before","column")?h.style.breakBefore="column":(CSS.supports("break-inside","avoid-column")&&(h.style.breakInside="avoid-column"),h.style.height=Tt(r.document.documentElement)+"px"),h.innerHTML="&#8203;",r.document.body.appendChild(h)}return i!==u}function _t(r){const e=r.document.createElement("style");e.appendChild(r.document.createTextNode("*{}")),r.document.body.appendChild(e),r.document.body.removeChild(e)}function fi(r){return r<.5?2*r*r:-1+(4-2*r)*r}function C(r){const e=r.getSelection();e&&e.removeAllRanges()}const bi=["a","audio","button","canvas","details","input","label","option","select","submit","textarea","video"];function Nt(r){return bi.indexOf(r.nodeName.toLowerCase())!==-1||r.hasAttribute("contenteditable")&&r.getAttribute("contenteditable")?.toLowerCase()!=="false"?r:r.parentElement?Nt(r.parentElement):null}function De(r,e){const t=It(r,r.document.body,e),i=r._readium_cssSelectorGenerator.getCssSelector(t,{selectors:["tag","id","class","nthchild","nthoftype","attribute"]});return new D({href:"#",type:"application/xhtml+xml",locations:new E({otherLocations:new Map([["cssSelector",i]])}),text:new B({highlight:t.textContent||void 0})})}function It(r,e,t){for(var i=0;i<e.children.length;i++){const n=e.children[i];if(!Ai(n)&&vi(r,n,t))return yi(r,n)?n:It(r,n,t)}return e}function vi(r,e,t){if(e===document.body||e===document.documentElement)return!0;if(!document||!document.documentElement||!document.body)return!1;const i=e.getBoundingClientRect();return t?i.bottom>0&&i.top<r.innerHeight:i.right>0&&i.left<r.innerWidth}function yi(r,e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=r.innerHeight&&t.right<=r.innerWidth}function Ai(r){const e=getComputedStyle(r);if(e){const t=e.getPropertyValue("display");if(t!="block"&&t!="list-item"||e.getPropertyValue("opacity")==="0")return!0}return!1}const wi={maxVelocity:200,minVariance:.01,historySize:20,minDirectionChanges:.2,maxConsistentScrolls:15},zt={maxVelocity:200,minVariance:1e-5,historySize:100,minDirectionChanges:.1,maxConsistentScrolls:20},Ot={maxSelectionsPerSecond:500,minVariance:50,historySize:20},ki={enabled:!0,maxSelectionPercent:.1,minThreshold:100,absoluteMaxChars:5e3,historySize:20};class be{constructor(e={}){this.history=[],this.consistentScrollCount=0,this.options={...wi,...e}}analyze(e,t,i){if(i<=0)return!1;const n=Math.abs(t)/i,o=Date.now();if(this.history.push({timestamp:o,direction:e,velocity:n,distance:Math.abs(t)}),this.history=this.history.filter(p=>o-p.timestamp<2e3).slice(-(this.options.historySize||20)),this.history.length<3)return!1;if(n>this.options.maxVelocity)return this.resetAfterDetection(),!0;const s=this.history.map(p=>p.velocity),a=this.history.map(p=>p.distance),u=s.reduce((p,v)=>p+v,0)/s.length,d=a.reduce((p,v)=>p+v,0)/a.length,h=s.reduce((p,v)=>p+Math.pow(v-u,2),0)/s.length,f=a.reduce((p,v)=>p+Math.pow(v-d,2),0)/a.length;if(h<this.options.minVariance&&f<d*.1){if(this.consistentScrollCount++,this.consistentScrollCount>=(this.options.maxConsistentScrolls||10))return this.resetAfterDetection(),!0}else this.consistentScrollCount=Math.max(0,this.consistentScrollCount-1);let m=0,y=this.history[0].direction;for(let p=1;p<this.history.length;p++)this.history[p].direction!==y&&(m++,y=this.history[p].direction);return m/this.history.length>(this.options.minDirectionChanges||.3)?(this.resetAfterDetection(),!0):!1}resetAfterDetection(){this.history=this.history.slice(-3),this.consistentScrollCount=0}clear(){this.history=[],this.consistentScrollCount=0}}const Rt="readium-column-snapper-style",Si=200,T=class T extends ee{constructor(){super(...arguments),this.isSnapProtectionEnabled=!1,this.patternAnalyzer=null,this.lastTurnTime=0,this.shakeTimeout=0,this.snappingCancelled=!1,this.alreadyScrollLeft=0,this.overscroll=0,this.cachedScrollWidth=0,this.touchState=0,this.startingX=void 0,this.endingX=void 0,this.onTouchStarter=this.onTouchStart.bind(this),this.onTouchEnder=this.onTouchEnd.bind(this),this.onWidthChanger=this.onWidthChange.bind(this),this.onTouchMover=this.onTouchMove.bind(this)}doc(){return this.wnd.document.scrollingElement}scrollOffset(){return this.doc().scrollLeft>0?this.doc().scrollLeft:this.alreadyScrollLeft}snapOffset(e){const t=e+(H(this.wnd)?-1:1);return t-t%this.wnd.innerWidth}reportProgress(){const e=this.wnd.scrollX,t=this.cachedScrollWidth,i=Math.max(0,Math.min(1,e/t)),n=Math.max(0,Math.min(1,(e+this.wnd.innerWidth)/t));this.comms.send("progress",{start:i,end:n})}shake(){if(this.overscroll!==0||this.shakeTimeout!==0)return;const e=this.doc();e.classList.add(H(this.wnd)?"readium-bounce-l":"readium-bounce-r");const t=this.scrollOffset();this.shakeTimeout=this.wnd.setTimeout(()=>{e.classList.remove("readium-bounce-l"),e.classList.remove("readium-bounce-r"),this.shakeTimeout=0,this.doc().scrollLeft=t},150)}takeOverSnap(){this.snappingCancelled=!0,this.clearTouches();const e=this.doc();this.overscroll=e.style.transform?.length>12?parseFloat(e.style.transform.slice(12).split("px")[0]):0}snapCurrentOffset(e=!1,t=!1){const i=this.wnd.scrollX>0?this.wnd.scrollX:this.alreadyScrollLeft,n=this.doc(),o=this.dragOffset(),s=Pt(this.wnd),a=Math.min(Math.max(0,i),this.cachedScrollWidth),u=H(this.wnd)?-1:1,d=u*(this.wnd.innerWidth/3)*(u*o>0?2:1),h=this.snapOffset(a+d),f=h>this.scrollOffset()?"right":"left";if(this.checkSuspiciousSnap(f,Math.abs(h-this.scrollOffset())),e&&h!==this.scrollOffset()){this.snappingCancelled=!1;const m=(v,x,F,re)=>F>re?x:v+(x-v)*fi(F/re),y=Si*s;let g;const p=v=>{if(this.snappingCancelled)return;g||(g=v);const x=v-g,F=m(this.overscroll,0,x,y),re=m(i,h,x,y);n.scrollLeft=re,this.overscroll!==0&&(Le?n.attributeStyleMap.set("transform",new CSSTransformValue([new CSSTranslate(CSS.px(-F),CSS.px(0),CSS.px(0))])):n.style.transform=`translate3d(${-F}px, 0px, 0px)`),x<y?this.wnd.requestAnimationFrame(p):(this.clearTouches(),n.style.removeProperty("transform"),n.scrollLeft=h,t||this.reportProgress())};this.wnd.requestAnimationFrame(p)}else n.style.removeProperty("transform"),this.wnd.requestAnimationFrame(()=>{n.scrollLeft=h,this.clearTouches(),t||this.reportProgress()})}dragOffset(){return(this.startingX??0)-(this.endingX??0)}clearTouches(){this.startingX=void 0,this.endingX=void 0,this.overscroll=0}onTouchStart(e){switch(e.stopPropagation(),this.takeOverSnap(),e.touches.length){case 1:break;case 2:this.onTouchEnd(e);return;default:{this.onTouchEnd(e),this.comms.send("tap_more",e.touches.length);return}}this.startingX=e.touches[0].clientX,this.alreadyScrollLeft=this.doc().scrollLeft,this.touchState=1}onTouchEnd(e){if(this.touchState===2){const t=this.dragOffset(),i=this.scrollOffset();this.cachedScrollWidth<=this.wnd.innerWidth?(this.reportProgress(),t>5&&this.comms.send("no_more",void 0),t<-5&&this.comms.send("no_less",void 0)):i<5&&t<5?(this.alreadyScrollLeft=0,this.comms.send("no_less",void 0)):this.cachedScrollWidth-i-this.wnd.innerWidth<5&&t>5&&(this.alreadyScrollLeft=this.cachedScrollWidth,this.comms.send("no_more",void 0)),this.snapCurrentOffset(!0),this.comms.send("swipe",t)}this.touchState=0}onWidthChange(){this.cachedScrollWidth=this.doc().scrollWidth,this.comms.ready&&this.snapCurrentOffset()}onTouchMove(e){if(this.touchState===0)return;this.touchState===1&&(this.touchState=2,C(this.wnd)),this.endingX=e.touches[0].clientX;const t=this.dragOffset(),i=this.alreadyScrollLeft+t;i<0?(this.overscroll=i,Le?this.doc().attributeStyleMap.set("transform",new CSSTransformValue([new CSSTranslate(CSS.px(-i),CSS.px(0),CSS.px(0))])):this.doc().style.transform=`translate3d(${-i}px, 0px, 0px)`):i+this.wnd.innerWidth>this.cachedScrollWidth?(this.overscroll=i,Le?this.doc().attributeStyleMap.set("transform",new CSSTransformValue([new CSSTranslate(CSS.px(-i),CSS.px(0),CSS.px(0))])):this.doc().style.transform=`translate3d(${-i}px, 0px, 0px)`):(this.overscroll=0,this.doc().style.removeProperty("transform"),this.doc().scrollLeft=this.alreadyScrollLeft+t)}enableSnapProtection(){this.patternAnalyzer||(this.patternAnalyzer=new be({maxVelocity:this.wnd.innerWidth,minVariance:.1,historySize:5,maxConsistentScrolls:3,minDirectionChanges:.3}),this.isSnapProtectionEnabled=!0,this.comms?.log("Snap protection enabled"))}checkSuspiciousSnap(e,t){if(!this.isSnapProtectionEnabled||!this.patternAnalyzer)return;const i=Date.now(),n=i-(this.lastTurnTime||i);this.lastTurnTime=i,this.patternAnalyzer.analyze(e,t,n)&&this.comms?.send("content_protection",{type:"suspicious_snapping",timestamp:Date.now(),event:null})}mount(e,t){if(this.wnd=e,this.comms=t,!super.mount(e,t))return!1;e.navigator.epubReadingSystem&&(e.navigator.epubReadingSystem.layoutStyle="paginated");const i=e.document.createElement("style");i.dataset.readium="true",i.id=Rt,i.textContent=`
16
+ }`}mount(e,t){const i=e.document.createElement("style");return i.dataset.readium="true",i.id=xt,i.textContent=this.buildStyles(),e.document.head.appendChild(i),t.register("protect",ie.moduleName,(n,o)=>{this.protected=!0,i.textContent=this.buildStyles(),o(!0)}),t.register("unprotect",ie.moduleName,(n,o)=>{this.protected=!1,i.textContent=this.buildStyles(),o(!0)}),t.log("Snapper Mounted"),!0}unmount(e,t){return e.document.getElementById(xt)?.remove(),t.log("Snapper Unmounted"),!0}};ie.moduleName="snapper";let ee=ie;function H(r){return r.document.body.dir.toLowerCase()==="rtl"}function Pt(r){return parseInt(r.getComputedStyle(r.document.documentElement).getPropertyValue("column-count"))}function Tt(r){const e=getComputedStyle(r),t=parseFloat(e.paddingTop||"0"),i=parseFloat(e.paddingBottom||"0");return r.clientHeight-t-i}function Lt(r){const e=Pt(r);if(!e)return!1;const t=r.document.querySelectorAll("div[id^='readium-virtual-page']");for(const d of t)d.remove();const i=t.length,n=r.document.scrollingElement.scrollWidth,o=r.visualViewport.width,a=Math.round(n/o*e)%e,u=e===1||a===0?0:e-a;if(u>0)for(let d=0;d<u;d++){const h=r.document.createElement("div");h.setAttribute("id",`readium-virtual-page-${d}`),h.dataset.readium="true",CSS.supports("break-before","column")?h.style.breakBefore="column":(CSS.supports("break-inside","avoid-column")&&(h.style.breakInside="avoid-column"),h.style.height=Tt(r.document.documentElement)+"px"),h.innerHTML="&#8203;",r.document.body.appendChild(h)}return i!==u}function _t(r){const e=r.document.createElement("style");e.appendChild(r.document.createTextNode("*{}")),r.document.body.appendChild(e),r.document.body.removeChild(e)}function fi(r){return r<.5?2*r*r:-1+(4-2*r)*r}function C(r){const e=r.getSelection();e&&e.removeAllRanges()}const bi=["a","audio","button","canvas","details","input","label","option","select","submit","textarea","video"];function Nt(r){return bi.indexOf(r.nodeName.toLowerCase())!==-1||r.hasAttribute("contenteditable")&&r.getAttribute("contenteditable")?.toLowerCase()!=="false"?r:r.parentElement?Nt(r.parentElement):null}function De(r,e){const t=It(r,r.document.body,e),i=r._readium_cssSelectorGenerator.getCssSelector(t,{selectors:["tag","id","class","nthchild","nthoftype","attribute"]});return new D({href:"#",type:"application/xhtml+xml",locations:new E({otherLocations:new Map([["cssSelector",i]])}),text:new B({highlight:t.textContent||void 0})})}function It(r,e,t){for(var i=0;i<e.children.length;i++){const n=e.children[i];if(!Ai(n)&&vi(r,n,t))return yi(r,n)?n:It(r,n,t)}return e}function vi(r,e,t){if(e===document.body||e===document.documentElement)return!0;if(!document||!document.documentElement||!document.body)return!1;const i=e.getBoundingClientRect();return t?i.bottom>0&&i.top<r.innerHeight:i.right>0&&i.left<r.innerWidth}function yi(r,e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=r.innerHeight&&t.right<=r.innerWidth}function Ai(r){const e=getComputedStyle(r);if(e){const t=e.getPropertyValue("display");if(t!="block"&&t!="list-item"||e.getPropertyValue("opacity")==="0")return!0}return!1}const wi={maxVelocity:200,minVariance:.01,historySize:20,minDirectionChanges:.2,maxConsistentScrolls:15},zt={maxVelocity:200,minVariance:1e-5,historySize:100,minDirectionChanges:.1,maxConsistentScrolls:20},Ot={maxSelectionsPerSecond:500,minVariance:50,historySize:20},ki={enabled:!0,maxSelectionPercent:.1,minThreshold:100,absoluteMaxChars:5e3,historySize:20};class be{constructor(e={}){this.history=[],this.consistentScrollCount=0,this.options={...wi,...e}}analyze(e,t,i){if(i<=0)return!1;const n=Math.abs(t)/i,o=Date.now();if(this.history.push({timestamp:o,direction:e,velocity:n,distance:Math.abs(t)}),this.history=this.history.filter(p=>o-p.timestamp<2e3).slice(-(this.options.historySize||20)),this.history.length<3)return!1;if(n>this.options.maxVelocity)return this.resetAfterDetection(),!0;const s=this.history.map(p=>p.velocity),a=this.history.map(p=>p.distance),u=s.reduce((p,v)=>p+v,0)/s.length,d=a.reduce((p,v)=>p+v,0)/a.length,h=s.reduce((p,v)=>p+Math.pow(v-u,2),0)/s.length,f=a.reduce((p,v)=>p+Math.pow(v-d,2),0)/a.length;if(h<this.options.minVariance&&f<d*.1){if(this.consistentScrollCount++,this.consistentScrollCount>=(this.options.maxConsistentScrolls||10))return this.resetAfterDetection(),!0}else this.consistentScrollCount=Math.max(0,this.consistentScrollCount-1);let m=0,y=this.history[0].direction;for(let p=1;p<this.history.length;p++)this.history[p].direction!==y&&(m++,y=this.history[p].direction);return m/this.history.length>(this.options.minDirectionChanges||.3)?(this.resetAfterDetection(),!0):!1}resetAfterDetection(){this.history=this.history.slice(-3),this.consistentScrollCount=0}clear(){this.history=[],this.consistentScrollCount=0}}const Rt="readium-column-snapper-style",Si=200,T=class T extends ee{constructor(){super(...arguments),this.isSnapProtectionEnabled=!1,this.patternAnalyzer=null,this.lastTurnTime=0,this.shakeTimeout=0,this.snappingCancelled=!1,this.alreadyScrollLeft=0,this.overscroll=0,this.cachedScrollWidth=0,this.touchState=0,this.startingX=void 0,this.endingX=void 0,this.onTouchStarter=this.onTouchStart.bind(this),this.onTouchEnder=this.onTouchEnd.bind(this),this.onWidthChanger=this.onWidthChange.bind(this),this.onTouchMover=this.onTouchMove.bind(this)}doc(){return this.wnd.document.scrollingElement}scrollOffset(){return this.doc().scrollLeft>0?this.doc().scrollLeft:this.alreadyScrollLeft}snapOffset(e){const t=e+(H(this.wnd)?-1:1);return t-t%this.wnd.innerWidth}reportProgress(){const e=this.wnd.scrollX,t=this.cachedScrollWidth,i=Math.max(0,Math.min(1,e/t)),n=Math.max(0,Math.min(1,(e+this.wnd.innerWidth)/t));this.comms.send("progress",{start:i,end:n})}shake(){if(this.overscroll!==0||this.shakeTimeout!==0)return;const e=this.doc();e.classList.add(H(this.wnd)?"readium-bounce-l":"readium-bounce-r");const t=this.scrollOffset();this.shakeTimeout=this.wnd.setTimeout(()=>{e.classList.remove("readium-bounce-l"),e.classList.remove("readium-bounce-r"),this.shakeTimeout=0,this.doc().scrollLeft=t},150)}takeOverSnap(){this.snappingCancelled=!0,this.clearTouches();const e=this.doc();this.overscroll=e.style.transform?.length>12?parseFloat(e.style.transform.slice(12).split("px")[0]):0}snapCurrentOffset(e=!1,t=!1){const i=this.wnd.scrollX>0?this.wnd.scrollX:this.alreadyScrollLeft,n=this.doc(),o=this.dragOffset(),s=Pt(this.wnd),a=Math.min(Math.max(0,i),this.cachedScrollWidth),u=H(this.wnd)?-1:1,d=u*(this.wnd.innerWidth/3)*(u*o>0?2:1),h=this.snapOffset(a+d),f=h>this.scrollOffset()?"right":"left";if(this.checkSuspiciousSnap(f,Math.abs(h-this.scrollOffset())),e&&h!==this.scrollOffset()){this.snappingCancelled=!1;const m=(v,x,F,re)=>F>re?x:v+(x-v)*fi(F/re),y=Si*s;let g;const p=v=>{if(this.snappingCancelled)return;g||(g=v);const x=v-g,F=m(this.overscroll,0,x,y),re=m(i,h,x,y);n.scrollLeft=re,this.overscroll!==0&&(Le()?n.attributeStyleMap.set("transform",new CSSTransformValue([new CSSTranslate(CSS.px(-F),CSS.px(0),CSS.px(0))])):n.style.transform=`translate3d(${-F}px, 0px, 0px)`),x<y?this.wnd.requestAnimationFrame(p):(this.clearTouches(),n.style.removeProperty("transform"),n.scrollLeft=h,t||this.reportProgress())};this.wnd.requestAnimationFrame(p)}else n.style.removeProperty("transform"),this.wnd.requestAnimationFrame(()=>{n.scrollLeft=h,this.clearTouches(),t||this.reportProgress()})}dragOffset(){return(this.startingX??0)-(this.endingX??0)}clearTouches(){this.startingX=void 0,this.endingX=void 0,this.overscroll=0}onTouchStart(e){switch(e.stopPropagation(),this.takeOverSnap(),e.touches.length){case 1:break;case 2:this.onTouchEnd(e);return;default:{this.onTouchEnd(e),this.comms.send("tap_more",e.touches.length);return}}this.startingX=e.touches[0].clientX,this.alreadyScrollLeft=this.doc().scrollLeft,this.touchState=1}onTouchEnd(e){if(this.touchState===2){const t=this.dragOffset(),i=this.scrollOffset();this.cachedScrollWidth<=this.wnd.innerWidth?(this.reportProgress(),t>5&&this.comms.send("no_more",void 0),t<-5&&this.comms.send("no_less",void 0)):i<5&&t<5?(this.alreadyScrollLeft=0,this.comms.send("no_less",void 0)):this.cachedScrollWidth-i-this.wnd.innerWidth<5&&t>5&&(this.alreadyScrollLeft=this.cachedScrollWidth,this.comms.send("no_more",void 0)),this.snapCurrentOffset(!0),this.comms.send("swipe",t)}this.touchState=0}onWidthChange(){this.cachedScrollWidth=this.doc().scrollWidth,this.comms.ready&&this.snapCurrentOffset()}onTouchMove(e){if(this.touchState===0)return;this.touchState===1&&(this.touchState=2,C(this.wnd)),this.endingX=e.touches[0].clientX;const t=this.dragOffset(),i=this.alreadyScrollLeft+t;i<0?(this.overscroll=i,Le()?this.doc().attributeStyleMap.set("transform",new CSSTransformValue([new CSSTranslate(CSS.px(-i),CSS.px(0),CSS.px(0))])):this.doc().style.transform=`translate3d(${-i}px, 0px, 0px)`):i+this.wnd.innerWidth>this.cachedScrollWidth?(this.overscroll=i,Le()?this.doc().attributeStyleMap.set("transform",new CSSTransformValue([new CSSTranslate(CSS.px(-i),CSS.px(0),CSS.px(0))])):this.doc().style.transform=`translate3d(${-i}px, 0px, 0px)`):(this.overscroll=0,this.doc().style.removeProperty("transform"),this.doc().scrollLeft=this.alreadyScrollLeft+t)}enableSnapProtection(){this.patternAnalyzer||(this.patternAnalyzer=new be({maxVelocity:this.wnd.innerWidth,minVariance:.1,historySize:5,maxConsistentScrolls:3,minDirectionChanges:.3}),this.isSnapProtectionEnabled=!0,this.comms?.log("Snap protection enabled"))}checkSuspiciousSnap(e,t){if(!this.isSnapProtectionEnabled||!this.patternAnalyzer)return;const i=Date.now(),n=i-(this.lastTurnTime||i);this.lastTurnTime=i,this.patternAnalyzer.analyze(e,t,n)&&this.comms?.send("content_protection",{type:"suspicious_snapping",timestamp:Date.now(),event:null})}mount(e,t){if(this.wnd=e,this.comms=t,!super.mount(e,t))return!1;e.navigator.epubReadingSystem&&(e.navigator.epubReadingSystem.layoutStyle="paginated");const i=e.document.createElement("style");i.dataset.readium="true",i.id=Rt,i.textContent=`
17
17
  @keyframes readium-bounce-l-animation {
18
18
  0%, 100% {transform: translate3d(0, 0, 0);}
19
19
  50% {transform: translate3d(-50px, 0, 0);}
@@ -55,7 +55,7 @@
55
55
  body::-webkit-scrollbar {
56
56
  display: none; /* for Chrome, Safari, and Opera */
57
57
  }
58
- `,e.document.head.appendChild(i),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",L.moduleName,()=>{_t(this.wnd);const n=this.doc().scrollTop;n>1?this.doc().scrollTop=n-1:this.doc().scrollTop=n+1,this.doc().scrollTop=n}),t.register("go_progression",L.moduleName,(n,o)=>{const s=n;if(s<0||s>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*s,this.reportProgress(),C(this.wnd),o(!0)})}),t.register("go_id",L.moduleName,(n,o)=>{const s=e.document.getElementById(n);if(!s){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=s.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),C(this.wnd),o(!0)})}),t.register("go_text",L.moduleName,(n,o)=>{let s;Array.isArray(n)&&(n.length>1&&(s=n[1]),n=n[0]);const a=B.deserialize(n),u=ue(this.wnd.document,new D({href:e.location.href,type:"text/html",text:a,locations:s?new E({otherLocations:new Map([["cssSelector",s]])}):void 0}));if(!u){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=u.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),C(this.wnd),o(!0)})}),t.register("go_start",L.moduleName,(n,o)=>{if(this.doc().scrollTop===0)return o(!1);this.doc().scrollTop=0,this.reportProgress(),o(!0)}),t.register("go_end",L.moduleName,(n,o)=>{if(this.doc().scrollTop===this.doc().scrollHeight-this.doc().offsetHeight)return o(!1);this.doc().scrollTop=this.doc().scrollHeight-this.doc().offsetHeight,this.reportProgress(),o(!0)}),t.register("unfocus",L.moduleName,(n,o)=>{C(this.wnd),o(!0)}),t.register("scroll_protection",L.moduleName,(n,o)=>{this.enableScrollProtection(),o(!0)}),t.register(["go_next","go_prev"],L.moduleName,(n,o)=>o(!1)),t.register("focus",L.moduleName,(n,o)=>{this.reportProgress(),o(!0)}),t.register("first_visible_locator",L.moduleName,(n,o)=>{const s=De(e,!0);this.comms.send("first_visible_locator",s.serialize()),o(!0)}),t.log("ScrollSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(L.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),e.document.getElementById(Dt)?.remove(),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("ScrollSnapper Unmounted"),!0}};L.moduleName="scroll_snapper";let We=L;const _=class _ extends ee{constructor(){super(...arguments),this.patternAnalyzer=null,this.lastScrollTime=0,this.isScrollProtectionEnabled=!1,this.initialScrollHandled=!1,this.isScrolling=!1,this.lastScrollTop=0,this.isResizing=!1,this.resizeDebounce=null,this.handleScroll=e=>{if(this.comms.ready&&!this.isResizing){if(!this.initialScrollHandled){this.lastScrollTop=this.doc().scrollTop,this.initialScrollHandled=!0,this.reportProgress();return}this.isScrolling||(this.isScrolling=!0,this.wnd.requestAnimationFrame(()=>{this.reportProgress();const t=this.doc().scrollTop,i=t-this.lastScrollTop;if(this.lastScrollTop=t,this.isScrollProtectionEnabled&&Math.abs(i)>5){const n=Date.now(),o=n-(this.lastScrollTime||n);if(this.patternAnalyzer&&this.patternAnalyzer.analyze(i>0?"down":"up",Math.abs(i),o)){const a=e.target&&"tagName"in e.target?{tagName:e.target.tagName}:null;this.comms?.send("content_protection",{type:"suspicious_scrolling",timestamp:Date.now(),scrollDelta:i,scrollDirection:i>0?"down":"up",targetElement:a})}this.lastScrollTime=n}this.comms.send("scroll",i),this.isScrolling=!1}))}}}doc(){return this.wnd.document.scrollingElement}reportProgress(){if(!this.comms.ready)return;const e=Math.ceil(this.doc().scrollTop),t=this.doc().scrollHeight,i=this.wnd.innerHeight,n=Math.max(0,Math.min(1,e/t)),o=Math.max(0,Math.min(1,(e+i)/t));this.comms.send("progress",{start:n,end:o})}enableScrollProtection(){this.patternAnalyzer||(this.patternAnalyzer=new be(zt),this.isScrollProtectionEnabled=!0,this.comms?.log("Scroll protection enabled"))}mount(e,t){return this.wnd=e,this.comms=t,this.initialScrollHandled=!1,this.lastScrollTop=0,this.isResizing=!1,this.resizeDebounce&&(this.wnd.clearTimeout(this.resizeDebounce),this.resizeDebounce=null),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",_.moduleName,()=>{_t(this.wnd);const i=this.doc().scrollTop;i>1?this.doc().scrollTop=i-1:this.doc().scrollTop=i+1,this.doc().scrollTop=i}),t.register("go_progression",_.moduleName,(i,n)=>{const o=i;if(o<0||o>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),n(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*o,this.reportProgress(),C(this.wnd),n(!0)})}),t.register("go_id",_.moduleName,(i,n)=>{const o=e.document.getElementById(i);if(!o){n(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=o.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),C(this.wnd),n(!0)})}),t.register("go_text",_.moduleName,(i,n)=>{let o;Array.isArray(i)&&(i.length>1&&(o=i[1]),i=i[0]);const s=B.deserialize(i),a=ue(this.wnd.document,new D({href:e.location.href,type:"text/html",text:s,locations:o?new E({otherLocations:new Map([["cssSelector",o]])}):void 0}));if(!a){n(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),C(this.wnd),n(!0)})}),t.register("go_start",_.moduleName,(i,n)=>{if(this.doc().scrollTop===0)return n(!1);this.doc().scrollTop=0,this.reportProgress(),n(!0)}),t.register("go_end",_.moduleName,(i,n)=>{if(this.doc().scrollTop===this.doc().scrollHeight-this.doc().offsetHeight)return n(!1);this.doc().scrollTop=this.doc().scrollHeight-this.doc().offsetHeight,this.reportProgress(),n(!0)}),t.register("unfocus",_.moduleName,(i,n)=>{C(this.wnd),n(!0)}),t.register("scroll_protection",_.moduleName,(i,n)=>{this.enableScrollProtection(),n(!0)}),t.register(["go_next","go_prev"],_.moduleName,(i,n)=>n(!1)),t.register("focus",_.moduleName,(i,n)=>{this.reportProgress(),n(!0)}),t.register("first_visible_locator",_.moduleName,(i,n)=>{const o=De(e,!0);t.send("first_visible_locator",o.serialize()),n(!0)}),t.log("WebPubSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(_.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("WebPubSnapper Unmounted"),!0}};_.moduleName="webpub_snapper";let Ue=_;class Mt{constructor(e,t){this.window=e,this.copyHistory=[],this.lastSelectionLength=0,this.lastSelectionTime=0,this.options=t}cleanupOldHistory(e){this.copyHistory=this.copyHistory.filter(i=>e-i.timestamp<1e4),this.copyHistory.length>this.options.historySize&&(this.copyHistory=this.copyHistory.slice(-this.options.historySize))}isSuspiciousPattern(e){return this.copyHistory.length<3?!1:this.copyHistory.filter(n=>e-n.timestamp<2e3).length>=3?!0:this.copyHistory.slice().sort((n,o)=>n.timestamp-o.timestamp).every((n,o,s)=>o===0?!0:n.length>s[o-1].length*1.5)}shouldAllowCopy(e){if(!this.options.enabled)return!0;const t=this.window.getSelection();if(!t)return!0;const n=t.toString().length,o=this.window.document.body.innerText.length,s=Date.now();if(this.cleanupOldHistory(s),n<this.options.minThreshold)return this.copyHistory.push({timestamp:s,length:n,wasBlocked:!1}),!0;const u=s-this.lastSelectionTime<100&&n>this.lastSelectionLength*1.5,d=Math.min(o*this.options.maxSelectionPercent,this.options.absoluteMaxChars),h=this.isSuspiciousPattern(s),f=n>d||u||h;return this.copyHistory.push({timestamp:s,length:n,wasBlocked:f}),f?(e?.preventDefault(),!1):(this.lastSelectionLength=n,this.lastSelectionTime=s,!0)}destroy(){this.lastSelectionLength=0,this.lastSelectionTime=0,this.copyHistory=[],this.options.enabled=!1}}class Wt{constructor(e=Ot){this.options=e,this.events=[],this.selectionStartTime=0,this.lastSelectionTime=0,this.lastSelectionPosition=0,this.selectionPatterns=[],this.lastSelectedText=""}analyze(e){if(!e)return this.clear(),!1;const t=e.toString();if(t.length===0)return this.clear(),!1;if(e.type!=="Range"||!e.rangeCount)return!1;const i=Date.now();if(t.length<=50||t===this.lastSelectedText)return!1;if(this.selectionStartTime===0)return this.selectionStartTime=i,this.lastSelectedText=t,!1;if(i-this.selectionStartTime<500)return!1;i-this.lastSelectionTime>1e3&&(this.lastSelectionTime=i),this.selectionStartTime===0&&(this.selectionStartTime=i),this.lastSelectedText=t;const o=this.analyzeSelectionPattern(e,i);return this.cleanup(i),o}analyzeSelectionPattern(e,t){if(!e.rangeCount)return!1;const i=e.getRangeAt(0),n=i.toString(),o=(t-this.selectionStartTime)/1e3;if(n.length/Math.max(1,o)>this.options.maxSelectionsPerSecond)return!0;const a=i.startOffset,u=Math.abs(a-this.lastSelectionPosition);return this.selectionPatterns.push(u),this.selectionPatterns.length>this.options.historySize&&(this.selectionPatterns.shift(),this.calculateVariance(this.selectionPatterns)<this.options.minVariance)?!0:(this.lastSelectionPosition=a,!1)}calculateVariance(e){if(e.length===0)return 0;const t=e.reduce((i,n)=>i+n,0)/e.length;return e.reduce((i,n)=>i+Math.pow(n-t,2),0)/e.length}cleanup(e){this.events=this.events.filter(t=>e-t.timestamp<=1e3)}clear(){this.events=[],this.selectionStartTime=0,this.lastSelectionTime=0,this.lastSelectionPosition=0,this.selectionPatterns=[],this.lastSelectedText=""}}class Ut{match(e,t){for(const i of t){const n=e.keyCode===i.keyCode,o=i.ctrl===void 0||e.ctrlKey===i.ctrl,s=i.shift===void 0||e.shiftKey===i.shift,a=i.alt===void 0||e.altKey===i.alt,u=i.meta===void 0||e.metaKey===i.meta;if(n&&o&&s&&a&&u)return!0}return!1}createKeyHandler(e,t){return i=>{this.match(i,e)&&(i.preventDefault(),i.stopPropagation(),t(i))}}createActivityEvent(e,t,i,n){let o;if(n){const s=n.getSelection(),a=s?.toString()||"",d=(a&&s?.rangeCount?s.getRangeAt(0)?.getClientRects():null)?.[0];d&&a&&(o={text:a,x:d.x,y:d.y,width:d.width,height:d.height})}return{type:t,timestamp:Date.now(),key:e.key,code:e.code,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,targetFrameSrc:i,selectedText:o}}createKeyboardHandlers(e,t,i,n){const o=[];return t.forEach(s=>{o.push(...s.keyCombos.map(a=>({...a,handler:u=>{const d=s.type,h=this.createActivityEvent(u,d,e,n);i(h)}})))}),o}createUnifiedHandler(e,t,i,n){const o=this.createKeyboardHandlers(e,t,i,n);return s=>{for(const a of o)if(this.match(s,[a])){s.preventDefault(),s.stopPropagation(),a.handler(s);return}}}}const Y=class Y extends G{constructor(){super(...arguments),this.configApplied=!1,this.cleanupCallbacks=[],this.pointerMoved=!1,this.isContextMenuEnabled=!1,this.isDragAndDropEnabled=!1,this.isSelectionMonitoringEnabled=!1,this.isBulkCopyProtectionEnabled=!1,this.selectionAnalyzer=null,this.currentSelection=null,this.bulkCopyProtector=null,this.keyManager=new Ut,this.keyDownHandler=null,this.preventBulkCopy=e=>{if(!this.isBulkCopyProtectionEnabled||!this.bulkCopyProtector)return!0;if(!this.bulkCopyProtector.shouldAllowCopy(e)){e.preventDefault();const t=this.wnd.getSelection(),i=t?.toString()||"",o=(i?t?.getRangeAt(0)?.getClientRects():null)?.[0],s={type:"bulk_copy",timestamp:Date.now(),clipboardTypes:e.clipboardData?.types?[...e.clipboardData.types]:[],selectedText:o?{text:i,x:o.x,y:o.y,width:o.width,height:o.height}:void 0,selectionLength:i.length,targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",s),!1}return!0},this.handleSelection=e=>{if(!this.isSelectionMonitoringEnabled||!this.wnd||!this.selectionAnalyzer)return;const t=this.wnd.getSelection();if(t){if(this.currentSelection=t.toString(),this.selectionAnalyzer.analyze(t)&&this.currentSelection){const n=this.wnd.getSelection(),o=n?.toString()||"",a=(o&&n?.rangeCount?n.getRangeAt(0)?.getClientRects():null)?.[0],u={type:"suspicious_selection",timestamp:Date.now(),selectionLength:o.length,selectedText:{text:o,x:a?.x??0,y:a?.y??0,width:a?.width??0,height:a?.height??0},eventType:e?.type||"selectionchange",targetFrameSrc:this.wnd.location.href};this.comms?.send("content_protection",u)}}else this.currentSelection=null},this.onDragStart=e=>{if(this.isDragAndDropEnabled){e.preventDefault();const t={type:"drag_detected",timestamp:Date.now(),dataTransferTypes:e.dataTransfer?.types?[...e.dataTransfer.types]:[],targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",t),!1}else return!0},this.onDrop=e=>{if(this.isDragAndDropEnabled){e.preventDefault();const t=e.dataTransfer,i={type:"drop_detected",timestamp:Date.now(),dataTransferTypes:t?.types?[...t.types]:[],fileCount:t?.files?.length||0,targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",i),!1}else return!0},this.onContext=e=>{if(this.isContextMenuEnabled){e.preventDefault();const t=this.wnd.getSelection(),i=t?.toString()||"",o=(i&&t?.rangeCount?t.getRangeAt(0)?.getClientRects():null)?.[0],s={timestamp:Date.now(),clientX:e.clientX,clientY:e.clientY,...o&&{selectedText:{text:i,x:o.x,y:o.y,width:o.width,height:o.height}},targetFrameSrc:this.wnd.location.href};this.comms?.send("context_menu",s)}},this.onPointerUp=this.onPointUp.bind(this),this.onPointerMove=this.onPointMove.bind(this),this.onPointerDown=this.onPointDown.bind(this),this.onClicker=this.onClick.bind(this)}addContextMenuPrevention(){this.isContextMenuEnabled||!this.wnd||(this.wnd.document.addEventListener("contextmenu",this.onContext),this.isContextMenuEnabled=!0)}removeContextMenuPrevention(){!this.isContextMenuEnabled||!this.wnd||(this.wnd.document.removeEventListener("contextmenu",this.onContext),this.isContextMenuEnabled=!1)}addDragAndDropPrevention(){this.isDragAndDropEnabled||!this.wnd||(this.wnd.document.addEventListener("dragstart",this.onDragStart),this.wnd.document.addEventListener("drop",this.onDrop),this.isDragAndDropEnabled=!0)}removeDragAndDropPrevention(){!this.isDragAndDropEnabled||!this.wnd||(this.wnd.document.removeEventListener("dragstart",this.onDragStart),this.wnd.document.removeEventListener("drop",this.onDrop),this.isDragAndDropEnabled=!1)}enableKeyboardPeripherals(e=[]){this.disableKeyboardPeripherals();const t=i=>{this.comms?.send("keyboard_peripherals",i)};this.keyDownHandler=this.keyManager.createUnifiedHandler(this.wnd.location.href,e,t,this.wnd),this.wnd&&this.wnd.document.addEventListener("keydown",this.keyDownHandler,{capture:!0})}disableKeyboardPeripherals(){this.wnd&&this.keyDownHandler&&(this.wnd.document.removeEventListener("keydown",this.keyDownHandler,{capture:!0}),this.keyDownHandler=null)}addBulkCopyProtection(e={}){if(this.isBulkCopyProtectionEnabled||!this.wnd)return;const t=ki,i=e?{...t,...e}:t;this.bulkCopyProtector=new Mt(this.wnd,i),this.wnd.document.addEventListener("copy",this.preventBulkCopy,!0),this.wnd.document.addEventListener("cut",this.preventBulkCopy,!0),this.isBulkCopyProtectionEnabled=!0}removeBulkCopyProtection(){!this.isBulkCopyProtectionEnabled||!this.wnd||(this.wnd.document.removeEventListener("copy",this.preventBulkCopy,!0),this.wnd.document.removeEventListener("cut",this.preventBulkCopy,!0),this.bulkCopyProtector?.destroy(),this.bulkCopyProtector=null,this.isBulkCopyProtectionEnabled=!1)}addSelectionMonitoring(e){if(this.isSelectionMonitoringEnabled||!this.wnd)return;const t=e||Ot;this.selectionAnalyzer=new Wt(t),this.wnd.document.addEventListener("selectionchange",this.handleSelection),this.isSelectionMonitoringEnabled=!0}removeSelectionMonitoring(){!this.isSelectionMonitoringEnabled||!this.wnd||(this.wnd.document.removeEventListener("selectionchange",this.handleSelection),this.selectionAnalyzer?.clear(),this.selectionAnalyzer=null,this.isSelectionMonitoringEnabled=!1)}onPointUp(e){const t=this.wnd.getSelection();if(t&&t.toString()?.length>0){const n=t.getRangeAt(0)?.getClientRects();if(!n||n.length===0)return;const o=n[0],s={text:t.toString(),x:o.x,y:o.y,width:o.width,height:o.height,targetFrameSrc:this.wnd?.location?.href};this.comms.send("text_selected",s)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!t?.isCollapsed||!e.isPrimary)return;const i=this.wnd.devicePixelRatio;e.preventDefault(),this.comms.send(e.pointerType==="touch"?"tap":"click",{defaultPrevented:e.defaultPrevented,x:e.clientX*i,y:e.clientY*i,targetFrameSrc:this.wnd.location.href,targetElement:e.target.outerHTML,interactiveElement:Nt(e.target)?.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)}),this.pointerMoved=!1}onPointMove(e){if(e.movementY!==void 0&&e.movementX!==void 0){(Math.abs(e.movementX)>1||Math.abs(e.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onClick(e){if(e.preventDefault(),!e.isTrusted){const t=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:e.clientX,clientY:e.clientY});Object.defineProperty(t,"target",{writable:!1,value:e.target}),Object.defineProperty(t,"defaultPrevented",{writable:!1,value:e.defaultPrevented}),this.onPointUp(t)}}registerProtectionHandlers(){this.comms?.register("peripherals_protection",Y.moduleName,(e,t)=>{const i=e;if(!this.configApplied){if(this.configApplied=!0,i.monitorSelection){const n=typeof i.monitorSelection=="boolean"?void 0:i.monitorSelection;this.addSelectionMonitoring(n),this.comms?.log("Selection monitoring enabled")}typeof i.protectCopy=="object"?(this.addBulkCopyProtection({enabled:!0,...i.protectCopy}),this.comms?.log("Copy protection enabled (limited)")):i.protectCopy===!0&&(this.addBulkCopyProtection({enabled:!0,maxSelectionPercent:0,minThreshold:0,absoluteMaxChars:0}),this.comms?.log("Copy protection enabled")),i.disableContextMenu&&(this.addContextMenuPrevention(),this.comms?.log("Context menu protection enabled")),i.disableDragAndDrop&&(this.addDragAndDropPrevention(),this.comms?.log("Drag and drop protection enabled"))}t(!0)}),this.comms?.register("keyboard_peripherals",Y.moduleName,(e,t)=>{const i=e;i&&i.length>0&&(this.enableKeyboardPeripherals(i),this.comms?.log(`Keyboard peripherals enabled: ${i.map(n=>n.type).join(", ")}`)),t(!0)})}mount(e,t){return this.wnd=e,this.comms=t,this.registerProtectionHandlers(),e.document.addEventListener("pointerdown",this.onPointerDown),e.document.addEventListener("pointerup",this.onPointerUp),e.document.addEventListener("pointermove",this.onPointerMove),e.document.addEventListener("click",this.onClicker),t.log("Peripherals Mounted"),!0}unmount(e,t){return this.removeBulkCopyProtection(),this.removeSelectionMonitoring(),this.removeContextMenuPrevention(),this.removeDragAndDropPrevention(),this.disableKeyboardPeripherals(),this.cleanupCallbacks.forEach(i=>i()),this.cleanupCallbacks=[],e.document.removeEventListener("pointerdown",this.onPointerDown),e.document.removeEventListener("pointerup",this.onPointerUp),e.document.removeEventListener("pointermove",this.onPointerMove),e.document.removeEventListener("click",this.onClicker),t.unregisterAll(Y.moduleName),this.configApplied=!1,t.log("Peripherals Unmounted"),!0}};Y.moduleName="peripherals";let ve=Y;const ne=class ne extends G{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(e){this.comms?.send("error",{message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno})}unblock(e){for(e._readium_blockEvents=!1;e._readium_blockedEvents?.length>0;){const t=e._readium_blockedEvents.shift();switch(t[0]){case 0:Reflect.apply(t[1],t[2],t[3]);break;case 1:const i=t[1],n=t[2];e.removeEventListener(i.type,e._readium_eventBlocker,!0);const o=new Event(i.type,{bubbles:i.bubbles,cancelable:i.cancelable});n?n.dispatchEvent(o):e.dispatchEvent(o);break}}}onMediaPlayEvent(){this.mediaPlayingCount++,this.comms?.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){this.mediaPlayingCount>0&&this.mediaPlayingCount--,this.comms?.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(e){const t=e.document.querySelectorAll("audio,video");for(let i=0;i<t.length;i++)t[i].pause()}mount(e,t){this.comms=t,e.addEventListener("error",this.wndOnErr,!1),Reflect.defineProperty(e.navigator,"epubReadingSystem",{value:{name:"readium-ts-toolkit",version:"2.3.1-alpha.1",hasFeature:(n,o="")=>{switch(n){case"dom-manipulation":return!0;case"layout-changes":return!0;case"touch-events":return!0;case"mouse-events":return!0;case"keyboard-events":return!0;case"spine-scripting":return!0;case"embedded-web-content":return!0;default:return!1}}},writable:!1}),"getAnimations"in e.document&&e.document.getAnimations().forEach(n=>{n.cancel(),this.allAnimations.add(n)}),t.register("activate",ne.moduleName,(n,o)=>{this.allAnimations.forEach(s=>{s.cancel(),s.play()}),o(!0)}),t.register("unfocus",ne.moduleName,(n,o)=>{this.pauseAllMedia(e),this.allAnimations.forEach(s=>s.pause()),o(!0)});const i=e.document.querySelectorAll("audio,video");for(let n=0;n<i.length;n++){const o=i[n];o.addEventListener("play",this.onMediaPlayEvent,{passive:!0}),o.addEventListener("pause",this.onMediaPauseEvent,{passive:!0})}return t.log("Setup Mounted"),!0}unmount(e,t){return e.removeEventListener("error",this.wndOnErr),e.removeEventListener("play",this.onMediaPlayEvent),e.removeEventListener("pause",this.onMediaPauseEvent),this.allAnimations.forEach(i=>i.cancel()),this.allAnimations.clear(),t.log("Setup Unmounted"),!0}};ne.moduleName="setup";let ye=ne;const Bt="readium-viewport",M=class M extends ye{onViewportWidthChanged(e){const t=e.target;Z(t,"--RS__viewportWidth",`${t.innerWidth}px`)}mount(e,t){if(!super.mount(e,t))return!1;const i=e.document.createElement("meta");return i.dataset.readium="true",i.setAttribute("name","viewport"),i.setAttribute("id",Bt),i.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"),e.document.head.appendChild(i),e.addEventListener("orientationchange",this.onViewportWidthChanged),e.addEventListener("resize",this.onViewportWidthChanged),this.onViewportWidthChanged({target:e}),t.register("get_properties",M.moduleName,(n,o)=>{_e(e),o(!0)}),t.register("update_properties",M.moduleName,(n,o)=>{n["--RS__viewportWidth"]=`${e.innerWidth}px`,yt(e,n),o(!0)}),t.register("set_property",M.moduleName,(n,o)=>{const s=n;Z(e,s[0],s[1]),o(!0)}),t.register("remove_property",M.moduleName,(n,o)=>{pe(e,n),o(!0)}),t.register("activate",M.moduleName,(n,o)=>{this.unblock(e),o(!0)}),t.log("ReflowableSetup Mounted"),!0}unmount(e,t){return t.unregisterAll(M.moduleName),e.document.head.querySelector(`#${Bt}`)?.remove(),e.removeEventListener("orientationchange",this.onViewportWidthChanged),t.log("ReflowableSetup Unmounted"),super.unmount(e,t)}};M.moduleName="reflowable_setup";let Be=M;const Gt="readium-fixed-style",R=class R extends ye{mount(e,t){if(!super.mount(e,t))return!1;e.navigator.epubReadingSystem&&(e.navigator.epubReadingSystem.layoutStyle="paginated");const i=e.document.createElement("style");return i.id=Gt,i.dataset.readium="true",i.textContent=`
58
+ `,e.document.head.appendChild(i),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",L.moduleName,()=>{_t(this.wnd);const n=this.doc().scrollTop;n>1?this.doc().scrollTop=n-1:this.doc().scrollTop=n+1,this.doc().scrollTop=n}),t.register("go_progression",L.moduleName,(n,o)=>{const s=n;if(s<0||s>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*s,this.reportProgress(),C(this.wnd),o(!0)})}),t.register("go_id",L.moduleName,(n,o)=>{const s=e.document.getElementById(n);if(!s){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=s.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),C(this.wnd),o(!0)})}),t.register("go_text",L.moduleName,(n,o)=>{let s;Array.isArray(n)&&(n.length>1&&(s=n[1]),n=n[0]);const a=B.deserialize(n),u=ue(this.wnd.document,new D({href:e.location.href,type:"text/html",text:a,locations:s?new E({otherLocations:new Map([["cssSelector",s]])}):void 0}));if(!u){o(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=u.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),C(this.wnd),o(!0)})}),t.register("go_start",L.moduleName,(n,o)=>{if(this.doc().scrollTop===0)return o(!1);this.doc().scrollTop=0,this.reportProgress(),o(!0)}),t.register("go_end",L.moduleName,(n,o)=>{if(this.doc().scrollTop===this.doc().scrollHeight-this.doc().offsetHeight)return o(!1);this.doc().scrollTop=this.doc().scrollHeight-this.doc().offsetHeight,this.reportProgress(),o(!0)}),t.register("unfocus",L.moduleName,(n,o)=>{C(this.wnd),o(!0)}),t.register("scroll_protection",L.moduleName,(n,o)=>{this.enableScrollProtection(),o(!0)}),t.register(["go_next","go_prev"],L.moduleName,(n,o)=>o(!1)),t.register("focus",L.moduleName,(n,o)=>{this.reportProgress(),o(!0)}),t.register("first_visible_locator",L.moduleName,(n,o)=>{const s=De(e,!0);this.comms.send("first_visible_locator",s.serialize()),o(!0)}),t.log("ScrollSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(L.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),e.document.getElementById(Dt)?.remove(),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("ScrollSnapper Unmounted"),!0}};L.moduleName="scroll_snapper";let We=L;const _=class _ extends ee{constructor(){super(...arguments),this.patternAnalyzer=null,this.lastScrollTime=0,this.isScrollProtectionEnabled=!1,this.initialScrollHandled=!1,this.isScrolling=!1,this.lastScrollTop=0,this.isResizing=!1,this.resizeDebounce=null,this.handleScroll=e=>{if(this.comms.ready&&!this.isResizing){if(!this.initialScrollHandled){this.lastScrollTop=this.doc().scrollTop,this.initialScrollHandled=!0,this.reportProgress();return}this.isScrolling||(this.isScrolling=!0,this.wnd.requestAnimationFrame(()=>{this.reportProgress();const t=this.doc().scrollTop,i=t-this.lastScrollTop;if(this.lastScrollTop=t,this.isScrollProtectionEnabled&&Math.abs(i)>5){const n=Date.now(),o=n-(this.lastScrollTime||n);if(this.patternAnalyzer&&this.patternAnalyzer.analyze(i>0?"down":"up",Math.abs(i),o)){const a=e.target&&"tagName"in e.target?{tagName:e.target.tagName}:null;this.comms?.send("content_protection",{type:"suspicious_scrolling",timestamp:Date.now(),scrollDelta:i,scrollDirection:i>0?"down":"up",targetElement:a})}this.lastScrollTime=n}this.comms.send("scroll",i),this.isScrolling=!1}))}}}doc(){return this.wnd.document.scrollingElement}reportProgress(){if(!this.comms.ready)return;const e=Math.ceil(this.doc().scrollTop),t=this.doc().scrollHeight,i=this.wnd.innerHeight,n=Math.max(0,Math.min(1,e/t)),o=Math.max(0,Math.min(1,(e+i)/t));this.comms.send("progress",{start:n,end:o})}enableScrollProtection(){this.patternAnalyzer||(this.patternAnalyzer=new be(zt),this.isScrollProtectionEnabled=!0,this.comms?.log("Scroll protection enabled"))}mount(e,t){return this.wnd=e,this.comms=t,this.initialScrollHandled=!1,this.lastScrollTop=0,this.isResizing=!1,this.resizeDebounce&&(this.wnd.clearTimeout(this.resizeDebounce),this.resizeDebounce=null),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounce&&this.wnd.clearTimeout(this.resizeDebounce),this.isResizing=!0,this.resizeDebounce=this.wnd.setTimeout(()=>{this.isResizing=!1,this.resizeDebounce=null,this.reportProgress()},50)}),this.resizeObserver.observe(e.document.body),e.addEventListener("scroll",this.handleScroll,{passive:!0}),t.register("force_webkit_recalc",_.moduleName,()=>{_t(this.wnd);const i=this.doc().scrollTop;i>1?this.doc().scrollTop=i-1:this.doc().scrollTop=i+1,this.doc().scrollTop=i}),t.register("go_progression",_.moduleName,(i,n)=>{const o=i;if(o<0||o>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),n(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*o,this.reportProgress(),C(this.wnd),n(!0)})}),t.register("go_id",_.moduleName,(i,n)=>{const o=e.document.getElementById(i);if(!o){n(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=o.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),C(this.wnd),n(!0)})}),t.register("go_text",_.moduleName,(i,n)=>{let o;Array.isArray(i)&&(i.length>1&&(o=i[1]),i=i[0]);const s=B.deserialize(i),a=ue(this.wnd.document,new D({href:e.location.href,type:"text/html",text:s,locations:o?new E({otherLocations:new Map([["cssSelector",o]])}):void 0}));if(!a){n(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+e.scrollY-e.innerHeight/2,this.reportProgress(),C(this.wnd),n(!0)})}),t.register("go_start",_.moduleName,(i,n)=>{if(this.doc().scrollTop===0)return n(!1);this.doc().scrollTop=0,this.reportProgress(),n(!0)}),t.register("go_end",_.moduleName,(i,n)=>{if(this.doc().scrollTop===this.doc().scrollHeight-this.doc().offsetHeight)return n(!1);this.doc().scrollTop=this.doc().scrollHeight-this.doc().offsetHeight,this.reportProgress(),n(!0)}),t.register("unfocus",_.moduleName,(i,n)=>{C(this.wnd),n(!0)}),t.register("scroll_protection",_.moduleName,(i,n)=>{this.enableScrollProtection(),n(!0)}),t.register(["go_next","go_prev"],_.moduleName,(i,n)=>n(!1)),t.register("focus",_.moduleName,(i,n)=>{this.reportProgress(),n(!0)}),t.register("first_visible_locator",_.moduleName,(i,n)=>{const o=De(e,!0);t.send("first_visible_locator",o.serialize()),n(!0)}),t.log("WebPubSnapper Mounted"),!0}unmount(e,t){return t.unregisterAll(_.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&e.removeEventListener("scroll",this.handleScroll),this.patternAnalyzer&&(this.patternAnalyzer.clear(),this.patternAnalyzer=null,this.isScrollProtectionEnabled=!1),t.log("WebPubSnapper Unmounted"),!0}};_.moduleName="webpub_snapper";let Ue=_;class Mt{constructor(e,t){this.window=e,this.copyHistory=[],this.lastSelectionLength=0,this.lastSelectionTime=0,this.options=t}cleanupOldHistory(e){this.copyHistory=this.copyHistory.filter(i=>e-i.timestamp<1e4),this.copyHistory.length>this.options.historySize&&(this.copyHistory=this.copyHistory.slice(-this.options.historySize))}isSuspiciousPattern(e){return this.copyHistory.length<3?!1:this.copyHistory.filter(n=>e-n.timestamp<2e3).length>=3?!0:this.copyHistory.slice().sort((n,o)=>n.timestamp-o.timestamp).every((n,o,s)=>o===0?!0:n.length>s[o-1].length*1.5)}shouldAllowCopy(e){if(!this.options.enabled)return!0;const t=this.window.getSelection();if(!t)return!0;const n=t.toString().length,o=this.window.document.body.innerText.length,s=Date.now();if(this.cleanupOldHistory(s),n<this.options.minThreshold)return this.copyHistory.push({timestamp:s,length:n,wasBlocked:!1}),!0;const u=s-this.lastSelectionTime<100&&n>this.lastSelectionLength*1.5,d=Math.min(o*this.options.maxSelectionPercent,this.options.absoluteMaxChars),h=this.isSuspiciousPattern(s),f=n>d||u||h;return this.copyHistory.push({timestamp:s,length:n,wasBlocked:f}),f?(e?.preventDefault(),!1):(this.lastSelectionLength=n,this.lastSelectionTime=s,!0)}destroy(){this.lastSelectionLength=0,this.lastSelectionTime=0,this.copyHistory=[],this.options.enabled=!1}}class Wt{constructor(e=Ot){this.options=e,this.events=[],this.selectionStartTime=0,this.lastSelectionTime=0,this.lastSelectionPosition=0,this.selectionPatterns=[],this.lastSelectedText=""}analyze(e){if(!e)return this.clear(),!1;const t=e.toString();if(t.length===0)return this.clear(),!1;if(e.type!=="Range"||!e.rangeCount)return!1;const i=Date.now();if(t.length<=50||t===this.lastSelectedText)return!1;if(this.selectionStartTime===0)return this.selectionStartTime=i,this.lastSelectedText=t,!1;if(i-this.selectionStartTime<500)return!1;i-this.lastSelectionTime>1e3&&(this.lastSelectionTime=i),this.selectionStartTime===0&&(this.selectionStartTime=i),this.lastSelectedText=t;const o=this.analyzeSelectionPattern(e,i);return this.cleanup(i),o}analyzeSelectionPattern(e,t){if(!e.rangeCount)return!1;const i=e.getRangeAt(0),n=i.toString(),o=(t-this.selectionStartTime)/1e3;if(n.length/Math.max(1,o)>this.options.maxSelectionsPerSecond)return!0;const a=i.startOffset,u=Math.abs(a-this.lastSelectionPosition);return this.selectionPatterns.push(u),this.selectionPatterns.length>this.options.historySize&&(this.selectionPatterns.shift(),this.calculateVariance(this.selectionPatterns)<this.options.minVariance)?!0:(this.lastSelectionPosition=a,!1)}calculateVariance(e){if(e.length===0)return 0;const t=e.reduce((i,n)=>i+n,0)/e.length;return e.reduce((i,n)=>i+Math.pow(n-t,2),0)/e.length}cleanup(e){this.events=this.events.filter(t=>e-t.timestamp<=1e3)}clear(){this.events=[],this.selectionStartTime=0,this.lastSelectionTime=0,this.lastSelectionPosition=0,this.selectionPatterns=[],this.lastSelectedText=""}}class Ut{match(e,t){for(const i of t){const n=e.keyCode===i.keyCode,o=i.ctrl===void 0||e.ctrlKey===i.ctrl,s=i.shift===void 0||e.shiftKey===i.shift,a=i.alt===void 0||e.altKey===i.alt,u=i.meta===void 0||e.metaKey===i.meta;if(n&&o&&s&&a&&u)return!0}return!1}createKeyHandler(e,t){return i=>{this.match(i,e)&&(i.preventDefault(),i.stopPropagation(),t(i))}}createActivityEvent(e,t,i,n){let o;if(n){const s=n.getSelection(),a=s?.toString()||"",d=(a&&s?.rangeCount?s.getRangeAt(0)?.getClientRects():null)?.[0];d&&a&&(o={text:a,x:d.x,y:d.y,width:d.width,height:d.height})}return{type:t,timestamp:Date.now(),key:e.key,code:e.code,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,targetFrameSrc:i,selectedText:o}}createKeyboardHandlers(e,t,i,n){const o=[];return t.forEach(s=>{o.push(...s.keyCombos.map(a=>({...a,handler:u=>{const d=s.type,h=this.createActivityEvent(u,d,e,n);i(h)}})))}),o}createUnifiedHandler(e,t,i,n){const o=this.createKeyboardHandlers(e,t,i,n);return s=>{for(const a of o)if(this.match(s,[a])){s.preventDefault(),s.stopPropagation(),a.handler(s);return}}}}const Y=class Y extends G{constructor(){super(...arguments),this.configApplied=!1,this.cleanupCallbacks=[],this.pointerMoved=!1,this.isContextMenuEnabled=!1,this.isDragAndDropEnabled=!1,this.isSelectionMonitoringEnabled=!1,this.isBulkCopyProtectionEnabled=!1,this.selectionAnalyzer=null,this.currentSelection=null,this.bulkCopyProtector=null,this.keyManager=new Ut,this.keyDownHandler=null,this.preventBulkCopy=e=>{if(!this.isBulkCopyProtectionEnabled||!this.bulkCopyProtector)return!0;if(!this.bulkCopyProtector.shouldAllowCopy(e)){e.preventDefault();const t=this.wnd.getSelection(),i=t?.toString()||"",o=(i?t?.getRangeAt(0)?.getClientRects():null)?.[0],s={type:"bulk_copy",timestamp:Date.now(),clipboardTypes:e.clipboardData?.types?[...e.clipboardData.types]:[],selectedText:o?{text:i,x:o.x,y:o.y,width:o.width,height:o.height}:void 0,selectionLength:i.length,targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",s),!1}return!0},this.handleSelection=e=>{if(!this.isSelectionMonitoringEnabled||!this.wnd||!this.selectionAnalyzer)return;const t=this.wnd.getSelection();if(t){if(this.currentSelection=t.toString(),this.selectionAnalyzer.analyze(t)&&this.currentSelection){const n=this.wnd.getSelection(),o=n?.toString()||"",a=(o&&n?.rangeCount?n.getRangeAt(0)?.getClientRects():null)?.[0],u={type:"suspicious_selection",timestamp:Date.now(),selectionLength:o.length,selectedText:{text:o,x:a?.x??0,y:a?.y??0,width:a?.width??0,height:a?.height??0},eventType:e?.type||"selectionchange",targetFrameSrc:this.wnd.location.href};this.comms?.send("content_protection",u)}}else this.currentSelection=null},this.onDragStart=e=>{if(this.isDragAndDropEnabled){e.preventDefault();const t={type:"drag_detected",timestamp:Date.now(),dataTransferTypes:e.dataTransfer?.types?[...e.dataTransfer.types]:[],targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",t),!1}else return!0},this.onDrop=e=>{if(this.isDragAndDropEnabled){e.preventDefault();const t=e.dataTransfer,i={type:"drop_detected",timestamp:Date.now(),dataTransferTypes:t?.types?[...t.types]:[],fileCount:t?.files?.length||0,targetFrameSrc:this.wnd.location.href};return this.comms?.send("content_protection",i),!1}else return!0},this.onContext=e=>{if(this.isContextMenuEnabled){e.preventDefault();const t=this.wnd.getSelection(),i=t?.toString()||"",o=(i&&t?.rangeCount?t.getRangeAt(0)?.getClientRects():null)?.[0],s={timestamp:Date.now(),clientX:e.clientX,clientY:e.clientY,...o&&{selectedText:{text:i,x:o.x,y:o.y,width:o.width,height:o.height}},targetFrameSrc:this.wnd.location.href};this.comms?.send("context_menu",s)}},this.onPointerUp=this.onPointUp.bind(this),this.onPointerMove=this.onPointMove.bind(this),this.onPointerDown=this.onPointDown.bind(this),this.onClicker=this.onClick.bind(this)}addContextMenuPrevention(){this.isContextMenuEnabled||!this.wnd||(this.wnd.document.addEventListener("contextmenu",this.onContext),this.isContextMenuEnabled=!0)}removeContextMenuPrevention(){!this.isContextMenuEnabled||!this.wnd||(this.wnd.document.removeEventListener("contextmenu",this.onContext),this.isContextMenuEnabled=!1)}addDragAndDropPrevention(){this.isDragAndDropEnabled||!this.wnd||(this.wnd.document.addEventListener("dragstart",this.onDragStart),this.wnd.document.addEventListener("drop",this.onDrop),this.isDragAndDropEnabled=!0)}removeDragAndDropPrevention(){!this.isDragAndDropEnabled||!this.wnd||(this.wnd.document.removeEventListener("dragstart",this.onDragStart),this.wnd.document.removeEventListener("drop",this.onDrop),this.isDragAndDropEnabled=!1)}enableKeyboardPeripherals(e=[]){this.disableKeyboardPeripherals();const t=i=>{this.comms?.send("keyboard_peripherals",i)};this.keyDownHandler=this.keyManager.createUnifiedHandler(this.wnd.location.href,e,t,this.wnd),this.wnd&&this.wnd.document.addEventListener("keydown",this.keyDownHandler,{capture:!0})}disableKeyboardPeripherals(){this.wnd&&this.keyDownHandler&&(this.wnd.document.removeEventListener("keydown",this.keyDownHandler,{capture:!0}),this.keyDownHandler=null)}addBulkCopyProtection(e={}){if(this.isBulkCopyProtectionEnabled||!this.wnd)return;const t=ki,i=e?{...t,...e}:t;this.bulkCopyProtector=new Mt(this.wnd,i),this.wnd.document.addEventListener("copy",this.preventBulkCopy,!0),this.wnd.document.addEventListener("cut",this.preventBulkCopy,!0),this.isBulkCopyProtectionEnabled=!0}removeBulkCopyProtection(){!this.isBulkCopyProtectionEnabled||!this.wnd||(this.wnd.document.removeEventListener("copy",this.preventBulkCopy,!0),this.wnd.document.removeEventListener("cut",this.preventBulkCopy,!0),this.bulkCopyProtector?.destroy(),this.bulkCopyProtector=null,this.isBulkCopyProtectionEnabled=!1)}addSelectionMonitoring(e){if(this.isSelectionMonitoringEnabled||!this.wnd)return;const t=e||Ot;this.selectionAnalyzer=new Wt(t),this.wnd.document.addEventListener("selectionchange",this.handleSelection),this.isSelectionMonitoringEnabled=!0}removeSelectionMonitoring(){!this.isSelectionMonitoringEnabled||!this.wnd||(this.wnd.document.removeEventListener("selectionchange",this.handleSelection),this.selectionAnalyzer?.clear(),this.selectionAnalyzer=null,this.isSelectionMonitoringEnabled=!1)}onPointUp(e){const t=this.wnd.getSelection();if(t&&t.toString()?.length>0){const n=t.getRangeAt(0)?.getClientRects();if(!n||n.length===0)return;const o=n[0],s={text:t.toString(),x:o.x,y:o.y,width:o.width,height:o.height,targetFrameSrc:this.wnd?.location?.href};this.comms.send("text_selected",s)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!t?.isCollapsed||!e.isPrimary)return;const i=this.wnd.devicePixelRatio;e.preventDefault(),this.comms.send(e.pointerType==="touch"?"tap":"click",{defaultPrevented:e.defaultPrevented,x:e.clientX*i,y:e.clientY*i,targetFrameSrc:this.wnd.location.href,targetElement:e.target.outerHTML,interactiveElement:Nt(e.target)?.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)}),this.pointerMoved=!1}onPointMove(e){if(e.movementY!==void 0&&e.movementX!==void 0){(Math.abs(e.movementX)>1||Math.abs(e.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onClick(e){if(e.preventDefault(),!e.isTrusted){const t=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:e.clientX,clientY:e.clientY});Object.defineProperty(t,"target",{writable:!1,value:e.target}),Object.defineProperty(t,"defaultPrevented",{writable:!1,value:e.defaultPrevented}),this.onPointUp(t)}}registerProtectionHandlers(){this.comms?.register("peripherals_protection",Y.moduleName,(e,t)=>{const i=e;if(!this.configApplied){if(this.configApplied=!0,i.monitorSelection){const n=typeof i.monitorSelection=="boolean"?void 0:i.monitorSelection;this.addSelectionMonitoring(n),this.comms?.log("Selection monitoring enabled")}typeof i.protectCopy=="object"?(this.addBulkCopyProtection({enabled:!0,...i.protectCopy}),this.comms?.log("Copy protection enabled (limited)")):i.protectCopy===!0&&(this.addBulkCopyProtection({enabled:!0,maxSelectionPercent:0,minThreshold:0,absoluteMaxChars:0}),this.comms?.log("Copy protection enabled")),i.disableContextMenu&&(this.addContextMenuPrevention(),this.comms?.log("Context menu protection enabled")),i.disableDragAndDrop&&(this.addDragAndDropPrevention(),this.comms?.log("Drag and drop protection enabled"))}t(!0)}),this.comms?.register("keyboard_peripherals",Y.moduleName,(e,t)=>{const i=e;i&&i.length>0&&(this.enableKeyboardPeripherals(i),this.comms?.log(`Keyboard peripherals enabled: ${i.map(n=>n.type).join(", ")}`)),t(!0)})}mount(e,t){return this.wnd=e,this.comms=t,this.registerProtectionHandlers(),e.document.addEventListener("pointerdown",this.onPointerDown),e.document.addEventListener("pointerup",this.onPointerUp),e.document.addEventListener("pointermove",this.onPointerMove),e.document.addEventListener("click",this.onClicker),t.log("Peripherals Mounted"),!0}unmount(e,t){return this.removeBulkCopyProtection(),this.removeSelectionMonitoring(),this.removeContextMenuPrevention(),this.removeDragAndDropPrevention(),this.disableKeyboardPeripherals(),this.cleanupCallbacks.forEach(i=>i()),this.cleanupCallbacks=[],e.document.removeEventListener("pointerdown",this.onPointerDown),e.document.removeEventListener("pointerup",this.onPointerUp),e.document.removeEventListener("pointermove",this.onPointerMove),e.document.removeEventListener("click",this.onClicker),t.unregisterAll(Y.moduleName),this.configApplied=!1,t.log("Peripherals Unmounted"),!0}};Y.moduleName="peripherals";let ve=Y;const ne=class ne extends G{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(e){this.comms?.send("error",{message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno})}unblock(e){for(e._readium_blockEvents=!1;e._readium_blockedEvents?.length>0;){const t=e._readium_blockedEvents.shift();switch(t[0]){case 0:Reflect.apply(t[1],t[2],t[3]);break;case 1:const i=t[1],n=t[2];e.removeEventListener(i.type,e._readium_eventBlocker,!0);const o=new Event(i.type,{bubbles:i.bubbles,cancelable:i.cancelable});n?n.dispatchEvent(o):e.dispatchEvent(o);break}}}onMediaPlayEvent(){this.mediaPlayingCount++,this.comms?.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){this.mediaPlayingCount>0&&this.mediaPlayingCount--,this.comms?.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(e){const t=e.document.querySelectorAll("audio,video");for(let i=0;i<t.length;i++)t[i].pause()}mount(e,t){this.comms=t,e.addEventListener("error",this.wndOnErr,!1),Reflect.defineProperty(e.navigator,"epubReadingSystem",{value:{name:"readium-ts-toolkit",version:"2.3.1-alpha.2",hasFeature:(n,o="")=>{switch(n){case"dom-manipulation":return!0;case"layout-changes":return!0;case"touch-events":return!0;case"mouse-events":return!0;case"keyboard-events":return!0;case"spine-scripting":return!0;case"embedded-web-content":return!0;default:return!1}}},writable:!1}),"getAnimations"in e.document&&e.document.getAnimations().forEach(n=>{n.cancel(),this.allAnimations.add(n)}),t.register("activate",ne.moduleName,(n,o)=>{this.allAnimations.forEach(s=>{s.cancel(),s.play()}),o(!0)}),t.register("unfocus",ne.moduleName,(n,o)=>{this.pauseAllMedia(e),this.allAnimations.forEach(s=>s.pause()),o(!0)});const i=e.document.querySelectorAll("audio,video");for(let n=0;n<i.length;n++){const o=i[n];o.addEventListener("play",this.onMediaPlayEvent,{passive:!0}),o.addEventListener("pause",this.onMediaPauseEvent,{passive:!0})}return t.log("Setup Mounted"),!0}unmount(e,t){return e.removeEventListener("error",this.wndOnErr),e.removeEventListener("play",this.onMediaPlayEvent),e.removeEventListener("pause",this.onMediaPauseEvent),this.allAnimations.forEach(i=>i.cancel()),this.allAnimations.clear(),t.log("Setup Unmounted"),!0}};ne.moduleName="setup";let ye=ne;const Bt="readium-viewport",M=class M extends ye{onViewportWidthChanged(e){const t=e.target;Z(t,"--RS__viewportWidth",`${t.innerWidth}px`)}mount(e,t){if(!super.mount(e,t))return!1;const i=e.document.createElement("meta");return i.dataset.readium="true",i.setAttribute("name","viewport"),i.setAttribute("id",Bt),i.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"),e.document.head.appendChild(i),e.addEventListener("orientationchange",this.onViewportWidthChanged),e.addEventListener("resize",this.onViewportWidthChanged),this.onViewportWidthChanged({target:e}),t.register("get_properties",M.moduleName,(n,o)=>{_e(e),o(!0)}),t.register("update_properties",M.moduleName,(n,o)=>{n["--RS__viewportWidth"]=`${e.innerWidth}px`,yt(e,n),o(!0)}),t.register("set_property",M.moduleName,(n,o)=>{const s=n;Z(e,s[0],s[1]),o(!0)}),t.register("remove_property",M.moduleName,(n,o)=>{pe(e,n),o(!0)}),t.register("activate",M.moduleName,(n,o)=>{this.unblock(e),o(!0)}),t.log("ReflowableSetup Mounted"),!0}unmount(e,t){return t.unregisterAll(M.moduleName),e.document.head.querySelector(`#${Bt}`)?.remove(),e.removeEventListener("orientationchange",this.onViewportWidthChanged),t.log("ReflowableSetup Unmounted"),super.unmount(e,t)}};M.moduleName="reflowable_setup";let Be=M;const Gt="readium-fixed-style",R=class R extends ye{mount(e,t){if(!super.mount(e,t))return!1;e.navigator.epubReadingSystem&&(e.navigator.epubReadingSystem.layoutStyle="paginated");const i=e.document.createElement("style");return i.id=Gt,i.dataset.readium="true",i.textContent=`
59
59
  html, body {
60
60
  text-size-adjust: none;
61
61
  -ms-text-size-adjust: none;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/navigator-html-injectables",
3
- "version": "2.3.1-alpha.1",
3
+ "version": "2.3.1-alpha.2",
4
4
  "type": "module",
5
5
  "description": "An embeddable solution for connecting frames of HTML publications with a Readium Navigator",
6
6
  "author": "readium",
@@ -1,6 +1,6 @@
1
1
  import { ReadiumWindow } from "./dom";
2
2
 
3
- export const isTypedOMSupported = typeof window.CSSTransformValue !== 'undefined';
3
+ export const isTypedOMSupported = () => typeof window.CSSTransformValue !== 'undefined';
4
4
 
5
5
  export function getProperties(wnd: ReadiumWindow) {
6
6
  const cssProperties: { [key: string]: string } = {};
@@ -134,7 +134,7 @@ export class ColumnSnapper extends Snapper {
134
134
  const spos = position(startX, so, elapsed, period);
135
135
  doc.scrollLeft = spos;
136
136
  if(this.overscroll !== 0)
137
- if(isTypedOMSupported) {
137
+ if(isTypedOMSupported()) {
138
138
  doc.attributeStyleMap.set("transform", new CSSTransformValue([
139
139
  new CSSTranslate(CSS.px(-lpos), CSS.px(0), CSS.px(0))
140
140
  ]));
@@ -244,7 +244,7 @@ export class ColumnSnapper extends Snapper {
244
244
  const newpos = this.alreadyScrollLeft + dro;
245
245
  if(newpos < 0) {
246
246
  this.overscroll = newpos;
247
- if(isTypedOMSupported) {
247
+ if(isTypedOMSupported()) {
248
248
  this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
249
249
  new CSSTranslate(CSS.px(-newpos), CSS.px(0), CSS.px(0))
250
250
  ]));
@@ -253,7 +253,7 @@ export class ColumnSnapper extends Snapper {
253
253
  }
254
254
  } else if((newpos + this.wnd.innerWidth) > this.cachedScrollWidth) {
255
255
  this.overscroll = newpos;
256
- if(isTypedOMSupported) {
256
+ if(isTypedOMSupported()) {
257
257
  this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
258
258
  new CSSTranslate(CSS.px(-newpos), CSS.px(0), CSS.px(0))
259
259
  ]));
@@ -1,5 +1,5 @@
1
1
  import { ReadiumWindow } from "./dom";
2
- export declare const isTypedOMSupported: boolean;
2
+ export declare const isTypedOMSupported: () => boolean;
3
3
  export declare function getProperties(wnd: ReadiumWindow): {
4
4
  [key: string]: string;
5
5
  };