@readium/navigator 2.0.0-beta.4 → 2.0.0-beta.5

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
@@ -3298,7 +3298,7 @@ const wi = (i) => {
3298
3298
  }, Ii = (i) => 0.2126 * i.r * i.a + 0.7152 * i.g * i.a + 0.0722 * i.b * i.a, Fi = (i) => {
3299
3299
  const t = wi(i);
3300
3300
  return Ii(t) < 128;
3301
- }, Ui = "Highlight" in window, Ne = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
3301
+ }, Ui = () => "Highlight" in window, Ne = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
3302
3302
  class yi {
3303
3303
  /**
3304
3304
  * Creates a DecorationGroup object
@@ -3306,7 +3306,7 @@ class yi {
3306
3306
  * @param name Human-readable name of the group
3307
3307
  */
3308
3308
  constructor(t, e, A, n) {
3309
- this.wnd = t, this.comms = e, this.id = A, this.name = n, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, Ui && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
3309
+ this.wnd = t, this.comms = e, this.id = A, this.name = n, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, Ui() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
3310
3310
  }
3311
3311
  get activeable() {
3312
3312
  return this.activateable;
@@ -4116,7 +4116,7 @@ const yA = class qt extends Dt {
4116
4116
  ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
4117
4117
  value: {
4118
4118
  name: "readium-ts-toolkit",
4119
- version: "2.0.0-beta.2",
4119
+ version: "2.0.0-beta.3",
4120
4120
  hasFeature: (n, r = "") => {
4121
4121
  switch (n) {
4122
4122
  case "dom-manipulation":
@@ -24,7 +24,7 @@
24
24
  0, target, receiver, args
25
25
  ]);
26
26
  }
27
- });`),"text/javascript")));class Ce{constructor(t,e,A,n){this.pub=t,this.item=A,this.burl=A.toURL(e)||"",this.cssProperties=n}async build(t=!1){if(this.item.mediaType.isHTML)return await this.buildHtmlFrame(t);if(this.item.mediaType.isBitmap)return this.buildImageFrame();throw Error("Unsupported frame mediatype "+this.item.mediaType.string)}async buildHtmlFrame(t=!1){const e=await this.pub.get(this.item).readAsString();if(!e)throw new Error(`Failed reading item ${this.item.href}`);const A=new DOMParser().parseFromString(e,this.item.mediaType.string),n=A.querySelector("parsererror");if(n){const r=n.querySelector("div");throw new Error(`Failed parsing item ${this.item.href}: ${(r==null?void 0:r.textContent)||n.textContent}`)}return this.finalizeDOM(A,this.burl,this.item.mediaType,t,this.cssProperties)}buildImageFrame(){const t=document.implementation.createHTMLDocument(this.item.title||this.item.href),e=document.createElement("img");return e.src=this.burl||"",e.alt=this.item.title||"",e.decoding="async",t.body.appendChild(e),this.finalizeDOM(t,this.burl,this.item.mediaType,!0)}hasExecutable(t){return!!t.querySelector("script")||!!t.querySelector("body[onload]:not(body[onload=''])")}hasStyle(t){return!!(t.querySelector("link[rel='stylesheet']")||t.querySelector("style")||t.querySelector("[style]:not([style=''])"))}setProperties(t,e){for(const A in t){const n=t[A];n&&e.documentElement.style.setProperty(A,n)}}finalizeDOM(t,e,A,n=!1,r){var o;if(!t)return"";if(!n){const a=Ot(t,st("ReadiumCSS-before",()=>q(Wt(li),"text/css")));t.head.firstChild?t.head.firstChild.before(a):t.head.appendChild(a),this.hasStyle(t)||a.after(Ot(t,st("ReadiumCSS-default",()=>q(Wt(ci),"text/css")))),t.head.appendChild(Ot(t,st("ReadiumCSS-after",()=>q(Wt(hi),"text/css")))),r&&this.setProperties(r,t)}if(t.body.querySelectorAll("img").forEach(a=>{a.setAttribute("fetchpriority","high")}),A.isHTML&&((o=this.pub.metadata.languages)!=null&&o[0])){const a=this.pub.metadata.languages[0];if(A===d.XHTML){const h=document.documentElement.lang||document.documentElement.getAttribute("xml:lang"),l=document.body.lang||document.body.getAttribute("xml:lang");l&&!h?(document.documentElement.lang=l,document.documentElement.setAttribute("xml:lang",l),document.body.removeAttribute("xml:lang"),document.body.removeAttribute("lang")):h||(document.documentElement.lang=a,document.documentElement.setAttribute("xml:lang",a))}else A===d.HTML&&!document.documentElement.lang&&(document.documentElement.lang=a)}if(e!==void 0){const a=t.createElement("base");a.href=e,a.dataset.readium="true",t.head.firstChild.before(a)}const s=this.hasExecutable(t);return s&&t.head.firstChild.before(di(t)),t.head.firstChild.before(gi(t)),s&&t.head.appendChild(ui(t)),URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(t)],{type:A.isHTML?A.string:"application/xhtml+xml"}))}}const mi=Math.pow(2,32),Re=()=>Math.round(Math.random()*mi).toString(36),Zt=()=>`${Math.round(performance.now())}-${Re()}-${Re()}`,ot=1;class Mi{constructor(t){this.destination=null,this.registrar=new Map,this.origin="",this.channelId="",this.receiver=this.receive.bind(this),this.preLog=[],this.wnd=t,t.addEventListener("message",this.receiver)}receive(t){if(t.source===null)throw Error("Event source is null");if(typeof t.data!="object")return;const e=t.data;if(!(!("_readium"in e)||!e._readium||e._readium<=0)){if(e.key==="_ping"){if(!this.destination){if(this.destination=t.source,this.origin=t.origin,this.channelId=e._channel,e._readium!==ot){e._readium>ot?this.send("error",`received comms version ${e._readium} higher than ${ot}`):this.send("error",`received comms version ${e._readium} lower than ${ot}`),this.destination=null,this.origin="",this.channelId="";return}this.send("_pong",void 0),this.preLog.forEach(A=>this.send("log",A)),this.preLog=[]}return}else if(this.channelId){if(e._channel!==this.channelId||t.origin!==this.origin)return}else return;this.handle(e)}}handle(t){const e=this.registrar.get(t.key);if(!e||e.length===0){t.strict&&this.send("_unhandled",t);return}e.forEach(A=>A.cb(t.data,n=>{this.send("_ack",n,t.id)}))}register(t,e,A){Array.isArray(t)||(t=[t]),t.forEach(n=>{const r=this.registrar.get(n);if(r&&r.length>=0){if(r.find(s=>s.module===e))throw new Error(`Trying to register another callback for combination of event ${n} and module ${e}`);r.push({cb:A,module:e}),this.registrar.set(n,r)}else this.registrar.set(n,[{cb:A,module:e}])})}unregister(t,e){Array.isArray(t)||(t=[t]),t.forEach(A=>{const n=this.registrar.get(A);!n||n.length===0||n.splice(n.findIndex(r=>r.module===e),1)})}unregisterAll(t){this.registrar.forEach((e,A)=>this.registrar.set(A,e.filter(n=>n.module!==t)))}log(...t){this.destination?this.send("log",t):this.preLog.push(t)}get ready(){return!!this.destination}destroy(){this.destination=null,this.channelId="",this.preLog=[],this.registrar.clear(),this.wnd.removeEventListener("message",this.receiver)}send(t,e,A=void 0,n=[]){if(!this.destination)throw Error("Attempted to send comms message before destination has been initialized");const r={_readium:ot,_channel:this.channelId,id:A??Zt(),key:t,data:e};try{this.destination.postMessage(r,{targetOrigin:this.origin,transfer:n})}catch(s){if(n.length>0)throw s;this.destination.postMessage(r,this.origin,n)}}}class Kt{constructor(t){this.algorithm=t.algorithm,this.compression=t.compression,this.originalLength=t.originalLength,this.profile=t.profile,this.scheme=t.scheme}static deserialize(t){if(t&&t.algorithm)return new Kt({algorithm:t.algorithm,compression:t.compression,originalLength:t.originalLength,profile:t.profile,scheme:t.scheme})}serialize(){const t={algorithm:this.algorithm};return this.compression!==void 0&&(t.compression=this.compression),this.originalLength!==void 0&&(t.originalLength=this.originalLength),this.profile!==void 0&&(t.profile=this.profile),this.scheme!==void 0&&(t.scheme=this.scheme),t}}class Q{constructor(t){this.otherProperties=t}static deserialize(t){if(t)return new Q(t)}serialize(){return this.otherProperties}add(t){const e=Object.assign({},this.otherProperties);for(const A in t)e[A]=t[A];return new Q(e)}}Object.defineProperty(Q.prototype,"encryption",{get:function(){return Kt.deserialize(this.otherProperties.encrypted)}}),Q.prototype.getContains=function(){return new Set(this.otherProperties.contains||[])},Q.prototype.getLayout=function(){return this.otherProperties.layout};class u{constructor(t){let e,A,n=t.mediaType.replace(/\s/g,"").split(";");const r=n[0].split("/");if(r.length===2){if(e=r[0].toLowerCase().trim(),A=r[1].toLowerCase().trim(),e.length===0||A.length===0)throw new Error("Invalid media type")}else throw new Error("Invalid media type");const s={};for(let g=1;g<n.length;g++){const m=n[g].split("=");if(m.length===2){const M=m[0].toLocaleLowerCase(),B=M==="charset"?m[1].toUpperCase():m[1];s[M]=B}}const o={},a=Object.keys(s);a.sort((g,m)=>g.localeCompare(m)),a.forEach(g=>o[g]=s[g]);let h="";for(const g in o){const m=o[g];h+=`;${g}=${m}`}const l=`${e}/${A}${h}`,c=o.encoding;this.string=l,this.type=e,this.subtype=A,this.parameters=o,this.encoding=c,this.name=t.name,this.fileExtension=t.fileExtension}static parse(t){return new u(t)}get structuredSyntaxSuffix(){const t=this.subtype.split("+");return t.length>1?`+${t[t.length-1]}`:void 0}get charset(){return this.parameters.charset}contains(t){const e=typeof t=="string"?u.parse({mediaType:t}):t;if(!((this.type==="*"||this.type===e.type)&&(this.subtype==="*"||this.subtype===e.subtype)))return!1;const A=new Set(Object.entries(this.parameters).map(([r,s])=>`${r}=${s}`)),n=new Set(Object.entries(e.parameters).map(([r,s])=>`${r}=${s}`));for(const r of Array.from(A.values()))if(!n.has(r))return!1;return!0}matches(t){const e=typeof t=="string"?u.parse({mediaType:t}):t;return this.contains(e)||e.contains(this)}matchesAny(...t){for(const e of t)if(this.matches(e))return!0;return!1}equals(t){return this.string===t.string}get isZIP(){return this.matchesAny(u.ZIP,u.LCP_PROTECTED_AUDIOBOOK,u.LCP_PROTECTED_PDF)||this.structuredSyntaxSuffix==="+zip"}get isJSON(){return this.matchesAny(u.JSON)||this.structuredSyntaxSuffix==="+json"}get isOPDS(){return this.matchesAny(u.OPDS1,u.OPDS1_ENTRY,u.OPDS2,u.OPDS2_PUBLICATION,u.OPDS_AUTHENTICATION)||this.structuredSyntaxSuffix==="+json"}get isHTML(){return this.matchesAny(u.HTML,u.XHTML)}get isBitmap(){return this.matchesAny(u.BMP,u.GIF,u.JPEG,u.PNG,u.TIFF,u.WEBP)}get isAudio(){return this.type==="audio"}get isVideo(){return this.type==="video"}get isRWPM(){return this.matchesAny(u.READIUM_AUDIOBOOK_MANIFEST,u.DIVINA_MANIFEST,u.READIUM_WEBPUB_MANIFEST)}get isPublication(){return this.matchesAny(u.READIUM_AUDIOBOOK,u.READIUM_AUDIOBOOK_MANIFEST,u.CBZ,u.DIVINA,u.DIVINA_MANIFEST,u.EPUB,u.LCP_PROTECTED_AUDIOBOOK,u.LCP_PROTECTED_PDF,u.LPF,u.PDF,u.W3C_WPUB_MANIFEST,u.READIUM_WEBPUB,u.READIUM_WEBPUB_MANIFEST,u.ZAB)}static get AAC(){return u.parse({mediaType:"audio/aac",fileExtension:"aac"})}static get ACSM(){return u.parse({mediaType:"application/vnd.adobe.adept+xml",name:"Adobe Content Server Message",fileExtension:"acsm"})}static get AIFF(){return u.parse({mediaType:"audio/aiff",fileExtension:"aiff"})}static get AVI(){return u.parse({mediaType:"video/x-msvideo",fileExtension:"avi"})}static get BINARY(){return u.parse({mediaType:"application/octet-stream"})}static get BMP(){return u.parse({mediaType:"image/bmp",fileExtension:"bmp"})}static get CBZ(){return u.parse({mediaType:"application/vnd.comicbook+zip",name:"Comic Book Archive",fileExtension:"cbz"})}static get CSS(){return u.parse({mediaType:"text/css",fileExtension:"css"})}static get DIVINA(){return u.parse({mediaType:"application/divina+zip",name:"Digital Visual Narratives",fileExtension:"divina"})}static get DIVINA_MANIFEST(){return u.parse({mediaType:"application/divina+json",name:"Digital Visual Narratives",fileExtension:"json"})}static get EPUB(){return u.parse({mediaType:"application/epub+zip",name:"EPUB",fileExtension:"epub"})}static get GIF(){return u.parse({mediaType:"image/gif",fileExtension:"gif"})}static get GZ(){return u.parse({mediaType:"application/gzip",fileExtension:"gz"})}static get HTML(){return u.parse({mediaType:"text/html",fileExtension:"html"})}static get JAVASCRIPT(){return u.parse({mediaType:"text/javascript",fileExtension:"js"})}static get JPEG(){return u.parse({mediaType:"image/jpeg",fileExtension:"jpeg"})}static get JSON(){return u.parse({mediaType:"application/json"})}static get LCP_LICENSE_DOCUMENT(){return u.parse({mediaType:"application/vnd.readium.lcp.license.v1.0+json",name:"LCP License",fileExtension:"lcpl"})}static get LCP_PROTECTED_AUDIOBOOK(){return u.parse({mediaType:"application/audiobook+lcp",name:"LCP Protected Audiobook",fileExtension:"lcpa"})}static get LCP_PROTECTED_PDF(){return u.parse({mediaType:"application/pdf+lcp",name:"LCP Protected PDF",fileExtension:"lcpdf"})}static get LCP_STATUS_DOCUMENT(){return u.parse({mediaType:"application/vnd.readium.license.status.v1.0+json"})}static get LPF(){return u.parse({mediaType:"application/lpf+zip",fileExtension:"lpf"})}static get MP3(){return u.parse({mediaType:"audio/mpeg",fileExtension:"mp3"})}static get MPEG(){return u.parse({mediaType:"video/mpeg",fileExtension:"mpeg"})}static get NCX(){return u.parse({mediaType:"application/x-dtbncx+xml",fileExtension:"ncx"})}static get OGG(){return u.parse({mediaType:"audio/ogg",fileExtension:"oga"})}static get OGV(){return u.parse({mediaType:"video/ogg",fileExtension:"ogv"})}static get OPDS1(){return u.parse({mediaType:"application/atom+xml;profile=opds-catalog"})}static get OPDS1_ENTRY(){return u.parse({mediaType:"application/atom+xml;type=entry;profile=opds-catalog"})}static get OPDS2(){return u.parse({mediaType:"application/opds+json"})}static get OPDS2_PUBLICATION(){return u.parse({mediaType:"application/opds-publication+json"})}static get OPDS_AUTHENTICATION(){return u.parse({mediaType:"application/opds-authentication+json"})}static get OPUS(){return u.parse({mediaType:"audio/opus",fileExtension:"opus"})}static get OTF(){return u.parse({mediaType:"font/otf",fileExtension:"otf"})}static get PDF(){return u.parse({mediaType:"application/pdf",name:"PDF",fileExtension:"pdf"})}static get PNG(){return u.parse({mediaType:"image/png",fileExtension:"png"})}static get READIUM_AUDIOBOOK(){return u.parse({mediaType:"application/audiobook+zip",name:"Readium Audiobook",fileExtension:"audiobook"})}static get READIUM_AUDIOBOOK_MANIFEST(){return u.parse({mediaType:"application/audiobook+json",name:"Readium Audiobook",fileExtension:"json"})}static get READIUM_CONTENT_DOCUMENT(){return u.parse({mediaType:"application/vnd.readium.content+json",name:"Readium Content Document",fileExtension:"json"})}static get READIUM_GUIDED_NAVIGATION_DOCUMENT(){return u.parse({mediaType:"application/guided-navigation+json",name:"Readium Guided Navigation Document",fileExtension:"json"})}static get READIUM_POSITION_LIST(){return u.parse({mediaType:"application/vnd.readium.position-list+json",name:"Readium Position List",fileExtension:"json"})}static get READIUM_WEBPUB(){return u.parse({mediaType:"application/webpub+zip",name:"Readium Web Publication",fileExtension:"webpub"})}static get READIUM_WEBPUB_MANIFEST(){return u.parse({mediaType:"application/webpub+json",name:"Readium Web Publication",fileExtension:"json"})}static get SMIL(){return u.parse({mediaType:"application/smil+xml",fileExtension:"smil"})}static get SVG(){return u.parse({mediaType:"image/svg+xml",fileExtension:"svg"})}static get TEXT(){return u.parse({mediaType:"text/plain",fileExtension:"txt"})}static get TIFF(){return u.parse({mediaType:"image/tiff",fileExtension:"tiff"})}static get TTF(){return u.parse({mediaType:"font/ttf",fileExtension:"ttf"})}static get W3C_WPUB_MANIFEST(){return u.parse({mediaType:"application/x.readium.w3c.wpub+json",name:"Web Publication",fileExtension:"json"})}static get WAV(){return u.parse({mediaType:"audio/wav",fileExtension:"wav"})}static get WEBM_AUDIO(){return u.parse({mediaType:"audio/webm",fileExtension:"webm"})}static get WEBM_VIDEO(){return u.parse({mediaType:"video/webm",fileExtension:"webm"})}static get WEBP(){return u.parse({mediaType:"image/webp",fileExtension:"webp"})}static get WOFF(){return u.parse({mediaType:"font/woff",fileExtension:"woff"})}static get WOFF2(){return u.parse({mediaType:"font/woff2",fileExtension:"woff2"})}static get XHTML(){return u.parse({mediaType:"application/xhtml+xml",fileExtension:"xhtml"})}static get XML(){return u.parse({mediaType:"application/xml",fileExtension:"xml"})}static get ZAB(){return u.parse({mediaType:"application/x.readium.zab+zip",name:"Zipped Audio Book",fileExtension:"zab"})}static get ZIP(){return u.parse({mediaType:"application/zip",fileExtension:"zip"})}}class Qe{constructor(t){this.uri=t,this.parameters=this.getParameters(t)}getParameters(t){const e=/\{\??([^}]+)\}/g,A=t.match(e);return A?new Set(A.join(",").replace(e,"$1").split(",").map(n=>n.trim())):new Set}expand(t){const e=n=>n.split(",").map(r=>{const s=t[r];return s?encodeURIComponent(s):""}).join(","),A=n=>"?"+n.split(",").map(r=>{const s=r.split("=")[0],o=t[s];return o?`${s}=${encodeURIComponent(o)}`:""}).join("&");return this.uri.replace(/\{(\??)([^}]+)\}/g,(...n)=>n[1]?A(n[2]):e(n[2]))}}function fi(i){return i&&i instanceof Array?i:void 0}function Ye(i){return i&&typeof i=="string"?[i]:fi(i)}function ze(i){return typeof i=="string"?new Date(i):void 0}function Yt(i){return isNaN(i)?void 0:i}function b(i){return Yt(i)!==void 0&&Math.sign(i)>=0?i:void 0}function pi(i){const t=new Array;return i.forEach(e=>t.push(e)),t}class S{constructor(t){this.fragments=t.fragments?t.fragments:new Array,this.progression=t.progression,this.totalProgression=t.totalProgression,this.position=t.position,this.otherLocations=t.otherLocations}static deserialize(t){if(!t)return;const e=Yt(t.progression),A=Yt(t.totalProgression),n=Yt(t.position),r=new Map,s=new Set(["fragment","fragments","progression","totalProgression","position"]);return Object.entries(t).forEach(([o,a])=>{s.has(o)||r.set(o,a)}),new S({fragments:Ye(t.fragments||t.fragment),progression:e!==void 0&&e>=0&&e<=1?e:void 0,totalProgression:A!==void 0&&A>=0&&A<=1?A:void 0,position:n!==void 0&&n>0?n:void 0,otherLocations:r.size===0?void 0:r})}serialize(){const t={};return this.fragments&&(t.fragments=this.fragments),this.progression!==void 0&&(t.progression=this.progression),this.totalProgression!==void 0&&(t.totalProgression=this.totalProgression),this.position!==void 0&&(t.position=this.position),this.otherLocations&&this.otherLocations.forEach((e,A)=>t[A]=e),t}}class at{constructor(t){this.after=t.after,this.before=t.before,this.highlight=t.highlight}static deserialize(t){if(t)return new at({after:t.after,before:t.before,highlight:t.highlight})}serialize(){const t={};return this.after!==void 0&&(t.after=this.after),this.before!==void 0&&(t.before=this.before),this.highlight!==void 0&&(t.highlight=this.highlight),t}}class _{constructor(t){this.href=t.href,this.type=t.type,this.title=t.title,this.locations=t.locations?t.locations:new S({}),this.text=t.text}static deserialize(t){if(t&&t.href&&t.type)return new _({href:t.href,type:t.type,title:t.title,locations:S.deserialize(t.locations),text:at.deserialize(t.text)})}serialize(){const t={href:this.href,type:this.type};return this.title!==void 0&&(t.title=this.title),this.locations&&(t.locations=this.locations.serialize()),this.text&&(t.text=this.text.serialize()),t}copyWithLocations(t){return new _({href:this.href,type:this.type,title:this.title,text:this.text,locations:new S({...this.locations,...t})})}}class ht{constructor(t){this.href=t.href,this.templated=t.templated,this.type=t.type,this.title=t.title,this.rels=t.rels,this.properties=t.properties,this.height=t.height,this.width=t.width,this.duration=t.duration,this.bitrate=t.bitrate,this.languages=t.languages,this.alternates=t.alternates,this.children=t.children}static deserialize(t){if(t&&t.href&&typeof t.href=="string")return new ht({href:t.href,templated:t.templated,type:t.type,title:t.title,rels:t.rel?t.rel instanceof Array?new Set(t.rel):new Set([t.rel]):void 0,properties:Q.deserialize(t.properties),height:b(t.height),width:b(t.width),duration:b(t.duration),bitrate:b(t.bitrate),languages:Ye(t.language),alternates:zt.deserialize(t.alternate),children:zt.deserialize(t.children)})}serialize(){const t={href:this.href};return this.templated!==void 0&&(t.templated=this.templated),this.type!==void 0&&(t.type=this.type),this.title!==void 0&&(t.title=this.title),this.rels&&(t.rel=pi(this.rels)),this.properties&&(t.properties=this.properties.serialize()),this.height!==void 0&&(t.height=this.height),this.width!==void 0&&(t.width=this.width),this.duration!==void 0&&(t.duration=this.duration),this.bitrate!==void 0&&(t.bitrate=this.bitrate),this.languages&&(t.language=this.languages),this.alternates&&(t.alternate=this.alternates.serialize()),this.children&&(t.children=this.children.serialize()),t}get mediaType(){return this.type!==void 0?u.parse({mediaType:this.type}):u.BINARY}toURL(t){const e=this.href.replace(/^(\/)/,"");if(e.length===0)return;let A=t||"/";return A.startsWith("/")&&(A="file://"+A),new URL(e,A).href.replace(/^(file:\/\/)/,"")}get templateParameters(){return this.templated?new Qe(this.href).parameters:new Set}expandTemplate(t){return new ht({href:new Qe(this.href).expand(t),templated:!1})}addProperties(t){var e;const A=ht.deserialize(this.serialize());return A.properties=A.properties?(e=A.properties)==null?void 0:e.add(t):new Q(t),A}get locator(){let t=this.href.split("#");return new _({href:t.length>0&&t[0]!==void 0?t[0]:this.href,type:this.type??"",title:this.title,locations:new S({fragments:t.length>1&&t[1]!==void 0?[t[1]]:[]})})}}class zt{constructor(t){this.items=t}static deserialize(t){if(t&&t instanceof Array)return new zt(t.map(e=>ht.deserialize(e)).filter(e=>e!==void 0))}serialize(){return this.items.map(t=>t.serialize())}findWithRel(t){const e=A=>A.rels&&A.rels.has(t);return this.items.find(e)}filterByRel(t){const e=A=>A.rels&&A.rels.has(t);return this.items.filter(e)}findWithHref(t){const e=A=>A.href===t;return this.items.find(e)}findIndexWithHref(t){const e=A=>A.href===t;return this.items.findIndex(e)}findWithMediaType(t){const e=A=>A.mediaType.matches(t);return this.items.find(e)}filterByMediaType(t){const e=A=>A.mediaType.matches(t);return this.items.filter(e)}filterByMediaTypes(t){const e=A=>{for(const n of t)if(A.mediaType.matches(n))return!0;return!1};return this.items.filter(e)}everyIsAudio(){const t=e=>e.mediaType.isAudio;return this.items.length>0&&this.items.every(t)}everyIsBitmap(){const t=e=>e.mediaType.isBitmap;return this.items.length>0&&this.items.every(t)}everyIsHTML(){const t=e=>e.mediaType.isHTML;return this.items.length>0&&this.items.every(t)}everyIsVideo(){const t=e=>e.mediaType.isVideo;return this.items.length>0&&this.items.every(t)}everyMatchesMediaType(t){return Array.isArray(t)?this.items.length>0&&this.items.every(e=>{for(const A of t)return e.mediaType.matches(A);return!1}):this.items.length>0&&this.items.every(e=>e.mediaType.matches(t))}filterLinksHasType(){return this.items.filter(t=>t.type)}}class Nt{constructor(t){this.cssSelector=t.cssSelector,this.textNodeIndex=t.textNodeIndex,this.charOffset=t.charOffset}static deserialize(t){if(!(t&&t.cssSelector))return;let e=b(t.textNodeIndex);if(e===void 0)return;let A=b(t.charOffset);return A===void 0&&(A=b(t.offset)),new Nt({cssSelector:t.cssSelector,textNodeIndex:e,charOffset:A})}serialize(){const t={cssSelector:this.cssSelector,textNodeIndex:this.textNodeIndex};return this.charOffset!==void 0&&(t.charOffset=this.charOffset),t}}class qt{constructor(t){this.start=t.start,this.end=t.end}static deserialize(t){if(!t)return;let e=Nt.deserialize(t.start);if(e)return new qt({start:e,end:Nt.deserialize(t.end)})}serialize(){const t={start:this.start.serialize()};return this.end&&(t.end=this.end.serialize()),t}}S.prototype.getCssSelector=function(){var i;return(i=this.otherLocations)==null?void 0:i.get("cssSelector")},S.prototype.getPartialCfi=function(){var i;return(i=this.otherLocations)==null?void 0:i.get("partialCfi")},S.prototype.getDomRange=function(){var i;return qt.deserialize((i=this.otherLocations)==null?void 0:i.get("domRange"))},S.prototype.fragmentParameters=function(){return new Map(this.fragments.map(i=>i.startsWith("#")?i.slice(1):i).join("&").split("&").filter(i=>!i.startsWith("#")).map(i=>i.split("=")).filter(i=>i.length===2).map(i=>[i[0].trim().toLowerCase(),i[1].trim()]))},S.prototype.htmlId=function(){if(!this.fragments.length)return;let i=this.fragments.find(t=>t.length&&!t.includes("="));if(!i){const t=this.fragmentParameters();t.has("id")?i=t.get("id"):t.has("name")&&(i=t.get("name"))}return i!=null&&i.startsWith("#")?i.slice(1):i},S.prototype.page=function(){const i=parseInt(this.fragmentParameters().get("page"));if(!isNaN(i)&&i>=0)return i},S.prototype.time=function(){const i=parseInt(this.fragmentParameters().get("t"));if(!isNaN(i))return i},S.prototype.space=function(){const i=this.fragmentParameters();if(!i.has("xywh"))return;const t=i.get("xywh").split(",").map(e=>parseInt(e));if(t.length===4&&!t.some(isNaN))return t};class _t{constructor(t){this.currency=t.currency,this.value=t.value}static deserialize(t){if(!t)return;let e=t.currency;if(!(e&&typeof e=="string"&&e.length>0))return;let A=b(t.value);if(A!==void 0)return new _t({currency:e,value:A})}serialize(){return{currency:this.currency,value:this.value}}}class wt{constructor(t){this.type=t.type,this.children=t.children}static deserialize(t){if(t&&t.type)return new wt({type:t.type,children:wt.deserializeArray(t.children)})}static deserializeArray(t){if(t instanceof Array)return t.map(e=>wt.deserialize(e)).filter(e=>e!==void 0)}serialize(){const t={type:this.type};return this.children&&(t.children=this.children.map(e=>e.serialize())),t}}class $t{constructor(t){this.total=t.total,this.position=t.position}static deserialize(t){if(t)return new $t({total:b(t.total),position:b(t.position)})}serialize(){const t={};return this.total!==void 0&&(t.total=this.total),this.position!==void 0&&(t.position=this.position),t}}class te{constructor(t){this.total=t.total,this.available=t.available}static deserialize(t){if(t)return new te({total:b(t.total),available:b(t.available)})}serialize(){const t={};return this.total!==void 0&&(t.total=this.total),this.available!==void 0&&(t.available=this.available),t}}class ee{constructor(t){this.state=t.state,this.since=t.since,this.until=t.until}static deserialize(t){if(t&&t.state)return new ee({state:t.state,since:ze(t.since),until:ze(t.until)})}serialize(){const t={state:this.state};return this.since!==void 0&&(t.since=this.since.toISOString()),this.until!==void 0&&(t.until=this.until.toISOString()),t}}Q.prototype.getNumberOfItems=function(){return b(this.otherProperties.numberOfItems)},Q.prototype.getPrice=function(){return _t.deserialize(this.otherProperties.price)},Q.prototype.getIndirectAcquisitions=function(){const i=this.otherProperties.indirectAcquisition;if(i&&i instanceof Array)return i.map(t=>wt.deserialize(t)).filter(t=>t!==void 0)},Q.prototype.getHolds=function(){return $t.deserialize(this.otherProperties.holds)},Q.prototype.getCopies=function(){return te.deserialize(this.otherProperties.copies)},Q.prototype.getAvailability=function(){return ee.deserialize(this.otherProperties.availability)},Q.prototype.getAuthenticate=function(){return ht.deserialize(this.otherProperties.authenticate)},Q.prototype.getClipped=function(){return this.otherProperties.clipped},Q.prototype.getFit=function(){return this.otherProperties.fit},Q.prototype.getOrientation=function(){return this.otherProperties.orientation},Q.prototype.getOverflow=function(){return this.otherProperties.overflow},Q.prototype.getPage=function(){return this.otherProperties.page||void 0},Q.prototype.getSpread=function(){return this.otherProperties.spread||void 0};var $;(function(i){i.NONE="none",i.DESCENDANT="descendant",i.CHILD="child"})($||($={}));var H;(function(i){i.id="id",i.class="class",i.tag="tag",i.attribute="attribute",i.nthchild="nthchild",i.nthoftype="nthoftype"})(H||(H={}));const Bi="CssSelectorGenerator";function Ne(i="unknown problem",...t){console.warn(`${Bi}: ${i}`,...t)}H.id,H.class,H.tag,H.attribute;function Ei(i){return i instanceof RegExp}function wi(i){return i.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".+")}function Ii(i){const t=i.map(e=>{if(Ei(e))return A=>e.test(A);if(typeof e=="function")return A=>{const n=e(A);return typeof n!="boolean"?(Ne("pattern matcher function invalid","Provided pattern matching function does not return boolean. It's result will be ignored.",e),!1):n};if(typeof e=="string"){const A=new RegExp("^"+wi(e)+"$");return n=>A.test(n)}return Ne("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",e),()=>!1});return e=>t.some(A=>A(e))}$.NONE+"",$.NONE,$.DESCENDANT+"",$.DESCENDANT,$.CHILD+"",$.CHILD,H.nthoftype,H.tag,H.id,H.class,H.attribute,H.nthchild,Ii(["class","id","ng-*"]);class St{}function Se(i){return i.split("").reverse().join("")}function Fi(i,t,e){const A=Se(t);return e.map(n=>{const r=Math.max(0,n.end-t.length-n.errors),s=Se(i.slice(r,n.end));return{start:Te(s,A,n.errors).reduce((o,a)=>n.end-a.end<o?n.end-a.end:o,n.end),end:n.end,errors:n.errors}})}function Ae(i){return(i|-i)>>31&1}function xe(i,t,e,A){let n=i.P[e],r=i.M[e];const s=A>>>31,o=t[e]|s,a=o|r,h=(o&n)+n^n|o;let l=r|~(h|n),c=n&h;const g=Ae(l&i.lastRowMask[e])-Ae(c&i.lastRowMask[e]);return l<<=1,c<<=1,c|=s,l|=Ae(A)-s,n=c|~(a|l),r=l&a,i.P[e]=n,i.M[e]=r,g}function Te(i,t,e){if(t.length===0)return[];e=Math.min(e,t.length);const A=[],n=32,r=Math.ceil(t.length/n)-1,s={P:new Uint32Array(r+1),M:new Uint32Array(r+1),lastRowMask:new Uint32Array(r+1)};s.lastRowMask.fill(1<<31),s.lastRowMask[r]=1<<(t.length-1)%n;const o=new Uint32Array(r+1),a=new Map,h=[];for(let g=0;g<256;g++)h.push(o);for(let g=0;g<t.length;g+=1){const m=t.charCodeAt(g);if(a.has(m))continue;const M=new Uint32Array(r+1);a.set(m,M),m<h.length&&(h[m]=M);for(let B=0;B<=r;B+=1){M[B]=0;for(let w=0;w<n;w+=1){const f=B*n+w;f>=t.length||t.charCodeAt(f)===m&&(M[B]|=1<<w)}}}let l=Math.max(0,Math.ceil(e/n)-1);const c=new Uint32Array(r+1);for(let g=0;g<=l;g+=1)c[g]=(g+1)*n;c[r]=t.length;for(let g=0;g<=l;g+=1)s.P[g]=-1,s.M[g]=0;for(let g=0;g<i.length;g+=1){const m=i.charCodeAt(g);let M;m<h.length?M=h[m]:(M=a.get(m),typeof M>"u"&&(M=o));let B=0;for(let w=0;w<=l;w+=1)B=xe(s,M,w,B),c[w]+=B;if(c[l]-B<=e&&l<r&&(M[l+1]&1||B<0)){l+=1,s.P[l]=-1,s.M[l]=0;let w;if(l===r){const f=t.length%n;w=f===0?n:f}else w=n;c[l]=c[l-1]+w-B+xe(s,M,l,B)}else for(;l>0&&c[l]>=e+n;)l-=1;l===r&&c[l]<=e&&(c[l]<e&&A.splice(0,A.length),A.push({start:-1,end:g+1,errors:c[l]}),e=c[l])}return A}function Ui(i,t,e){const A=Te(i,t,e);return Fi(i,t,A)}function je(i,t,e){let A=0;const n=[];for(;A!==-1;)A=i.indexOf(t,A),A!==-1&&(n.push({start:A,end:A+t.length,errors:0}),A+=1);return n.length>0?n:Ui(i,t,e)}function Ve(i,t){return t.length===0||i.length===0?0:1-je(i,t,t.length)[0].errors/t.length}function yi(i,t,e={}){if(t.length===0)return null;const A=Math.min(256,t.length/2),n=je(i,t,A);if(n.length===0)return null;const r=o=>{const a=1-o.errors/t.length,h=e.prefix?Ve(i.slice(Math.max(0,o.start-e.prefix.length),o.start),e.prefix):1,l=e.suffix?Ve(i.slice(o.end,o.end+e.suffix.length),e.suffix):1;let c=1;typeof e.hint=="number"&&(c=1-Math.abs(o.start-e.hint)/i.length);const g=50*a+20*h+20*l+2*c,m=50+20+20+2;return g/m},s=n.map(o=>({start:o.start,end:o.end,score:r(o)}));return s.sort((o,a)=>a.score-o.score),s[0]}function ie(i,t,e){const A=e===1?t:t-1;if(i.charAt(A).trim()!=="")return t;let n,r;if(e===2?(n=i.substring(0,t),r=n.trimEnd()):(n=i.substring(t),r=n.trimStart()),!r.length)return-1;const s=n.length-r.length;return e===2?t-s:t+s}function De(i,t){const e=i.commonAncestorContainer.ownerDocument.createNodeIterator(i.commonAncestorContainer,NodeFilter.SHOW_TEXT),A=t===1?i.startContainer:i.endContainer,n=t===1?i.endContainer:i.startContainer;let r=e.nextNode();for(;r&&r!==A;)r=e.nextNode();t===2&&(r=e.previousNode());let s=-1;const o=()=>{if(r=t===1?e.nextNode():e.previousNode(),r){const a=r.textContent,h=t===1?0:a.length;s=ie(a,h,t)}};for(;r&&s===-1&&r!==n;)o();if(r&&s>=0)return{node:r,offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function Ci(i){if(!i.toString().trim().length)throw new RangeError("Range contains no non-whitespace text");if(i.startContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range startContainer is not a text node");if(i.endContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range endContainer is not a text node");const t=i.cloneRange();let e=!1,A=!1;const n={start:ie(i.startContainer.textContent,i.startOffset,1),end:ie(i.endContainer.textContent,i.endOffset,2)};if(n.start>=0&&(t.setStart(i.startContainer,n.start),e=!0),n.end>0&&(t.setEnd(i.endContainer,n.end),A=!0),e&&A)return t;if(!e){const{node:r,offset:s}=De(t,1);r&&s>=0&&t.setStart(r,s)}if(!A){const{node:r,offset:s}=De(t,2);r&&s>0&&t.setEnd(r,s)}return t}function be(i){var t;switch(i.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return((t=i.textContent)==null?void 0:t.length)??0;default:return 0}}function Pe(i){let t=i.previousSibling,e=0;for(;t;)e+=be(t),t=t.previousSibling;return e}function ve(i,...t){let e=t.shift();const A=i.ownerDocument.createNodeIterator(i,NodeFilter.SHOW_TEXT),n=[];let r=A.nextNode(),s,o=0;for(;e!==void 0&&r;)s=r,o+s.data.length>e?(n.push({node:s,offset:e-o}),e=t.shift()):(r=A.nextNode(),o+=s.data.length);for(;e!==void 0&&s&&o===e;)n.push({node:s,offset:s.data.length}),e=t.shift();if(e!==void 0)throw new RangeError("Offset exceeds text length");return n}class O{constructor(t,e){if(e<0)throw new Error("Offset is invalid");this.element=t,this.offset=e}relativeTo(t){if(!t.contains(this.element))throw new Error("Parent is not an ancestor of current element");let e=this.element,A=this.offset;for(;e!==t;)A+=Pe(e),e=e.parentElement;return new O(e,A)}resolve(t={}){try{return ve(this.element,this.offset)[0]}catch(e){if(this.offset===0&&t.direction!==void 0){const A=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);A.currentNode=this.element;const n=t.direction===1,r=n?A.nextNode():A.previousNode();if(!r)throw e;return{node:r,offset:n?0:r.data.length}}else throw e}}static fromCharOffset(t,e){switch(t.nodeType){case Node.TEXT_NODE:return O.fromPoint(t,e);case Node.ELEMENT_NODE:return new O(t,e);default:throw new Error("Node is not an element or text node")}}static fromPoint(t,e){switch(t.nodeType){case Node.TEXT_NODE:{if(e<0||e>t.data.length)throw new Error("Text node offset is out of range");if(!t.parentElement)throw new Error("Text node has no parent");const A=Pe(t)+e;return new O(t.parentElement,A)}case Node.ELEMENT_NODE:{if(e<0||e>t.childNodes.length)throw new Error("Child node offset is out of range");let A=0;for(let n=0;n<e;n++)A+=be(t.childNodes[n]);return new O(t,A)}default:throw new Error("Point is not in an element or text node")}}}class tt{constructor(t,e){this.start=t,this.end=e}relativeTo(t){return new tt(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[t,e]=ve(this.start.element,this.start.offset,this.end.offset):(t=this.start.resolve({direction:1}),e=this.end.resolve({direction:2}));const A=new Range;return A.setStart(t.node,t.offset),A.setEnd(e.node,e.offset),A}static fromRange(t){const e=O.fromPoint(t.startContainer,t.startOffset),A=O.fromPoint(t.endContainer,t.endOffset);return new tt(e,A)}static fromOffsets(t,e,A){return new tt(new O(t,e),new O(t,A))}static trimmedRange(t){return Ci(tt.fromRange(t).toRange())}}class xt{constructor(t,e,A){this.root=t,this.start=e,this.end=A}static fromRange(t,e){const A=tt.fromRange(e).relativeTo(t);return new xt(t,A.start.offset,A.end.offset)}static fromSelector(t,e){return new xt(t,e.start,e.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){return tt.fromOffsets(this.root,this.start,this.end).toRange()}}class Tt{constructor(t,e,A={}){this.root=t,this.exact=e,this.context=A}static fromRange(t,e){const A=t.textContent,n=tt.fromRange(e).relativeTo(t),r=n.start.offset,s=n.end.offset,o=32;return new Tt(t,A.slice(r,s),{prefix:A.slice(Math.max(0,r-o),r),suffix:A.slice(s,Math.min(A.length,s+o))})}static fromSelector(t,e){const{prefix:A,suffix:n}=e;return new Tt(t,e.exact,{prefix:A,suffix:n})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(t={}){return this.toPositionAnchor(t).toRange()}toPositionAnchor(t={}){const e=this.root.textContent,A=yi(e,this.exact,{...this.context,hint:t.hint});if(!A)throw new Error("Quote not found");return new xt(this.root,A.start,A.end)}}function Ri(i){const t=i.tagName.toUpperCase();return t==="IMG"||t==="VIDEO"||t==="AUDIO"||t==="IFRAME"||t==="OBJECT"||t==="EMBED"||t==="CANVAS"}function ne(i,t){try{const e=t.locations,A=t.text;if(A&&A.highlight){let n;e&&e.getCssSelector()&&(n=i.querySelector(e.getCssSelector())),n||(n=i.body);const r=new Tt(n,A.highlight,{prefix:A.before,suffix:A.after});try{return r.toRange()}catch{return console.warn("Quote not found:",r),null}}if(e){let n=null;if(!n&&e.getCssSelector()&&(n=i.querySelector(e.getCssSelector())),!n&&e.fragments){for(const r of e.fragments)if(n=i.getElementById(r),n)break}if(n){const r=i.createRange();return n.childNodes.length===0||Ri(n)?(r.selectNode(n),r):(r.setStartBefore(n),r.setEndAfter(n),r)}}}catch(e){console.error(e)}return null}function Qi(i,t){let e=i.getClientRects();e.length||i.commonAncestorContainer.nodeType===Node.ELEMENT_NODE&&(e=i.commonAncestorContainer.getClientRects());const A=1,n=[];for(const h of e)n.push({bottom:h.bottom,height:h.height,left:h.left,right:h.right,top:h.top,width:h.width});const r=Ge(n,A,t),s=zi(r,A),o=He(s),a=2*2;for(let h=o.length-1;h>=0;h--){const l=o[h];if(!(l.width*l.height>a))if(o.length>1)o.splice(h,1);else break}return o}function Ge(i,t,e){for(let A=0;A<i.length;A++)for(let n=A+1;n<i.length;n++){const r=i[A],s=i[n];if(r===s)continue;const o=k(r.top,s.top,t)&&k(r.bottom,s.bottom,t),a=k(r.left,s.left,t)&&k(r.right,s.right,t);if((a&&!e||o&&!a)&&Je(r,s,t)){const h=i.filter(c=>c!==r&&c!==s),l=Yi(r,s);return h.push(l),Ge(h,t,e)}}return i}function Yi(i,t){const e=Math.min(i.left,t.left),A=Math.max(i.right,t.right),n=Math.min(i.top,t.top),r=Math.max(i.bottom,t.bottom);return{bottom:r,height:r-n,left:e,right:A,top:n,width:A-e}}function zi(i,t){const e=new Set(i);for(const A of i){if(!(A.width>1&&A.height>1)){e.delete(A);continue}for(const n of i)if(A!==n&&e.has(n)&&Ni(n,A,t)){e.delete(A);break}}return Array.from(e)}function Ni(i,t,e){return jt(i,t.left,t.top,e)&&jt(i,t.right,t.top,e)&&jt(i,t.left,t.bottom,e)&&jt(i,t.right,t.bottom,e)}function jt(i,t,e,A){return(i.left<t||k(i.left,t,A))&&(i.right>t||k(i.right,t,A))&&(i.top<e||k(i.top,e,A))&&(i.bottom>e||k(i.bottom,e,A))}function He(i){for(let t=0;t<i.length;t++)for(let e=t+1;e<i.length;e++){const A=i[t],n=i[e];if(A!==n&&Je(A,n,-1)){let r=[],s;const o=ke(A,n);if(o.length===1)r=o,s=A;else{const h=ke(n,A);o.length<h.length?(r=o,s=A):(r=h,s=n)}const a=i.filter(h=>h!==s);return Array.prototype.push.apply(a,r),He(a)}}return i}function ke(i,t){const e=Si(t,i);if(e.height===0||e.width===0)return[i];const A=[];{const n={bottom:i.bottom,height:0,left:i.left,right:e.left,top:i.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&A.push(n)}{const n={bottom:e.top,height:0,left:e.left,right:e.right,top:i.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&A.push(n)}{const n={bottom:i.bottom,height:0,left:e.left,right:e.right,top:e.bottom,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&A.push(n)}{const n={bottom:i.bottom,height:0,left:e.right,right:i.right,top:i.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&A.push(n)}return A}function Si(i,t){const e=Math.max(i.left,t.left),A=Math.min(i.right,t.right),n=Math.max(i.top,t.top),r=Math.min(i.bottom,t.bottom);return{bottom:r,height:Math.max(0,r-n),left:e,right:A,top:n,width:Math.max(0,A-e)}}function Je(i,t,e){return(i.left<t.right||e>=0&&k(i.left,t.right,e))&&(t.left<i.right||e>=0&&k(t.left,i.right,e))&&(i.top<t.bottom||e>=0&&k(i.top,t.bottom,e))&&(t.top<i.bottom||e>=0&&k(t.top,i.bottom,e))}function k(i,t,e){return Math.abs(i-t)<=e}function We(i){const t={},e=i.document.documentElement.style;for(const A in i.document.documentElement.style)Object.hasOwn(e,A)&&!Number.isNaN(Number.parseInt(A))&&(t[e[A]]=e.getPropertyValue(e[A]));return t}function xi(i,t){const e=We(i);Object.keys(e).forEach(A=>{t.hasOwnProperty(A)||re(i,A)}),Object.entries(t).forEach(([A,n])=>{e[A]!==n&&Vt(i,A,n)})}function Le(i,t){return i.document.documentElement.style.getPropertyValue(t)}function Vt(i,t,e){i.document.documentElement.style.setProperty(t,e)}function re(i,t){i.document.documentElement.style.removeProperty(t)}const Ti=i=>{if(i.startsWith("rgb")){const t=i.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);if(t)return{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10),a:t[4]?parseInt(t[4],10)/255:1}}else if(i.startsWith("#")){const t=i.slice(1);if(t.length===3||t.length===4)return{r:parseInt(t[0]+t[0],16)/255,g:parseInt(t[1]+t[1],16)/255,b:parseInt(t[2]+t[2],16)/255,a:t.length===4?parseInt(t[3]+t[3],16)/255:1};if(t.length===6||t.length===8)return{r:parseInt(t[0]+t[1],16)/255,g:parseInt(t[2]+t[3],16)/255,b:parseInt(t[4]+t[5],16)/255,a:t.length===8?parseInt(t[6]+t[7],16)/255:1}}return{r:0,g:0,b:0,a:1}},ji=i=>.2126*i.r*i.a+.7152*i.g*i.a+.0722*i.b*i.a,Vi=i=>{const t=Ti(i);return ji(t)<128},Di="Highlight"in window,Oe=["IMG","IMAGE","AUDIO","VIDEO","SVG"];class bi{constructor(t,e,A,n){this.wnd=t,this.comms=e,this.id=A,this.name=n,this.items=[],this.lastItemId=0,this.container=void 0,this.activateable=!1,this.experimentalHighlights=!1,this.currentRender=0,Di&&(this.experimentalHighlights=!0,this.notTextFlag=new Map)}get activeable(){return this.activateable}set activeable(t){this.activateable=t}add(t){var e,A,n,r;const s=`${this.id}-${this.lastItemId++}`,o=ne(this.wnd.document,t.locator);if(!o){this.comms.log("Can't locate DOM range for decoration",t);return}const a=o.commonAncestorContainer;a.nodeType!==Node.TEXT_NODE&&this.experimentalHighlights&&(Oe.includes(a.nodeName.toUpperCase())&&((e=this.notTextFlag)==null||e.set(s,!0)),a.querySelector(Oe.join(", ").toLowerCase())&&((A=this.notTextFlag)==null||A.set(s,!0)),(((n=a.textContent)==null?void 0:n.trim())||"").length===0&&((r=this.notTextFlag)==null||r.set(s,!0)));const h={decoration:t,id:s,range:o};this.items.push(h),this.layout(h),this.renderLayout([h])}remove(t){var e,A;const n=this.items.findIndex(s=>s.decoration.id===t);if(n<0)return;const r=this.items[n];if(this.items.splice(n,1),r.clickableElements=void 0,r.container&&(r.container.remove(),r.container=void 0),this.experimentalHighlights&&!((e=this.notTextFlag)!=null&&e.has(r.id))){const s=this.wnd.CSS.highlights.get(this.id);s==null||s.delete(r.range)}(A=this.notTextFlag)==null||A.delete(r.id)}update(t){this.remove(t.id),this.add(t)}clear(){var t;this.clearContainer(),this.items.length=0,(t=this.notTextFlag)==null||t.clear()}requestLayout(){this.wnd.cancelAnimationFrame(this.currentRender),this.clearContainer(),this.items.forEach(t=>this.layout(t)),this.renderLayout(this.items)}experimentalLayout(t){var e,A;const[n,r]=this.requireContainer(!0);r.add(t.range),n.innerHTML=`
27
+ });`),"text/javascript")));class Ce{constructor(t,e,A,n){this.pub=t,this.item=A,this.burl=A.toURL(e)||"",this.cssProperties=n}async build(t=!1){if(this.item.mediaType.isHTML)return await this.buildHtmlFrame(t);if(this.item.mediaType.isBitmap)return this.buildImageFrame();throw Error("Unsupported frame mediatype "+this.item.mediaType.string)}async buildHtmlFrame(t=!1){const e=await this.pub.get(this.item).readAsString();if(!e)throw new Error(`Failed reading item ${this.item.href}`);const A=new DOMParser().parseFromString(e,this.item.mediaType.string),n=A.querySelector("parsererror");if(n){const r=n.querySelector("div");throw new Error(`Failed parsing item ${this.item.href}: ${(r==null?void 0:r.textContent)||n.textContent}`)}return this.finalizeDOM(A,this.burl,this.item.mediaType,t,this.cssProperties)}buildImageFrame(){const t=document.implementation.createHTMLDocument(this.item.title||this.item.href),e=document.createElement("img");return e.src=this.burl||"",e.alt=this.item.title||"",e.decoding="async",t.body.appendChild(e),this.finalizeDOM(t,this.burl,this.item.mediaType,!0)}hasExecutable(t){return!!t.querySelector("script")||!!t.querySelector("body[onload]:not(body[onload=''])")}hasStyle(t){return!!(t.querySelector("link[rel='stylesheet']")||t.querySelector("style")||t.querySelector("[style]:not([style=''])"))}setProperties(t,e){for(const A in t){const n=t[A];n&&e.documentElement.style.setProperty(A,n)}}finalizeDOM(t,e,A,n=!1,r){var o;if(!t)return"";if(!n){const a=Ot(t,st("ReadiumCSS-before",()=>q(Wt(li),"text/css")));t.head.firstChild?t.head.firstChild.before(a):t.head.appendChild(a),this.hasStyle(t)||a.after(Ot(t,st("ReadiumCSS-default",()=>q(Wt(ci),"text/css")))),t.head.appendChild(Ot(t,st("ReadiumCSS-after",()=>q(Wt(hi),"text/css")))),r&&this.setProperties(r,t)}if(t.body.querySelectorAll("img").forEach(a=>{a.setAttribute("fetchpriority","high")}),A.isHTML&&((o=this.pub.metadata.languages)!=null&&o[0])){const a=this.pub.metadata.languages[0];if(A===d.XHTML){const h=document.documentElement.lang||document.documentElement.getAttribute("xml:lang"),l=document.body.lang||document.body.getAttribute("xml:lang");l&&!h?(document.documentElement.lang=l,document.documentElement.setAttribute("xml:lang",l),document.body.removeAttribute("xml:lang"),document.body.removeAttribute("lang")):h||(document.documentElement.lang=a,document.documentElement.setAttribute("xml:lang",a))}else A===d.HTML&&!document.documentElement.lang&&(document.documentElement.lang=a)}if(e!==void 0){const a=t.createElement("base");a.href=e,a.dataset.readium="true",t.head.firstChild.before(a)}const s=this.hasExecutable(t);return s&&t.head.firstChild.before(di(t)),t.head.firstChild.before(gi(t)),s&&t.head.appendChild(ui(t)),URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(t)],{type:A.isHTML?A.string:"application/xhtml+xml"}))}}const mi=Math.pow(2,32),Re=()=>Math.round(Math.random()*mi).toString(36),Zt=()=>`${Math.round(performance.now())}-${Re()}-${Re()}`,ot=1;class Mi{constructor(t){this.destination=null,this.registrar=new Map,this.origin="",this.channelId="",this.receiver=this.receive.bind(this),this.preLog=[],this.wnd=t,t.addEventListener("message",this.receiver)}receive(t){if(t.source===null)throw Error("Event source is null");if(typeof t.data!="object")return;const e=t.data;if(!(!("_readium"in e)||!e._readium||e._readium<=0)){if(e.key==="_ping"){if(!this.destination){if(this.destination=t.source,this.origin=t.origin,this.channelId=e._channel,e._readium!==ot){e._readium>ot?this.send("error",`received comms version ${e._readium} higher than ${ot}`):this.send("error",`received comms version ${e._readium} lower than ${ot}`),this.destination=null,this.origin="",this.channelId="";return}this.send("_pong",void 0),this.preLog.forEach(A=>this.send("log",A)),this.preLog=[]}return}else if(this.channelId){if(e._channel!==this.channelId||t.origin!==this.origin)return}else return;this.handle(e)}}handle(t){const e=this.registrar.get(t.key);if(!e||e.length===0){t.strict&&this.send("_unhandled",t);return}e.forEach(A=>A.cb(t.data,n=>{this.send("_ack",n,t.id)}))}register(t,e,A){Array.isArray(t)||(t=[t]),t.forEach(n=>{const r=this.registrar.get(n);if(r&&r.length>=0){if(r.find(s=>s.module===e))throw new Error(`Trying to register another callback for combination of event ${n} and module ${e}`);r.push({cb:A,module:e}),this.registrar.set(n,r)}else this.registrar.set(n,[{cb:A,module:e}])})}unregister(t,e){Array.isArray(t)||(t=[t]),t.forEach(A=>{const n=this.registrar.get(A);!n||n.length===0||n.splice(n.findIndex(r=>r.module===e),1)})}unregisterAll(t){this.registrar.forEach((e,A)=>this.registrar.set(A,e.filter(n=>n.module!==t)))}log(...t){this.destination?this.send("log",t):this.preLog.push(t)}get ready(){return!!this.destination}destroy(){this.destination=null,this.channelId="",this.preLog=[],this.registrar.clear(),this.wnd.removeEventListener("message",this.receiver)}send(t,e,A=void 0,n=[]){if(!this.destination)throw Error("Attempted to send comms message before destination has been initialized");const r={_readium:ot,_channel:this.channelId,id:A??Zt(),key:t,data:e};try{this.destination.postMessage(r,{targetOrigin:this.origin,transfer:n})}catch(s){if(n.length>0)throw s;this.destination.postMessage(r,this.origin,n)}}}class Kt{constructor(t){this.algorithm=t.algorithm,this.compression=t.compression,this.originalLength=t.originalLength,this.profile=t.profile,this.scheme=t.scheme}static deserialize(t){if(t&&t.algorithm)return new Kt({algorithm:t.algorithm,compression:t.compression,originalLength:t.originalLength,profile:t.profile,scheme:t.scheme})}serialize(){const t={algorithm:this.algorithm};return this.compression!==void 0&&(t.compression=this.compression),this.originalLength!==void 0&&(t.originalLength=this.originalLength),this.profile!==void 0&&(t.profile=this.profile),this.scheme!==void 0&&(t.scheme=this.scheme),t}}class Q{constructor(t){this.otherProperties=t}static deserialize(t){if(t)return new Q(t)}serialize(){return this.otherProperties}add(t){const e=Object.assign({},this.otherProperties);for(const A in t)e[A]=t[A];return new Q(e)}}Object.defineProperty(Q.prototype,"encryption",{get:function(){return Kt.deserialize(this.otherProperties.encrypted)}}),Q.prototype.getContains=function(){return new Set(this.otherProperties.contains||[])},Q.prototype.getLayout=function(){return this.otherProperties.layout};class u{constructor(t){let e,A,n=t.mediaType.replace(/\s/g,"").split(";");const r=n[0].split("/");if(r.length===2){if(e=r[0].toLowerCase().trim(),A=r[1].toLowerCase().trim(),e.length===0||A.length===0)throw new Error("Invalid media type")}else throw new Error("Invalid media type");const s={};for(let g=1;g<n.length;g++){const m=n[g].split("=");if(m.length===2){const M=m[0].toLocaleLowerCase(),B=M==="charset"?m[1].toUpperCase():m[1];s[M]=B}}const o={},a=Object.keys(s);a.sort((g,m)=>g.localeCompare(m)),a.forEach(g=>o[g]=s[g]);let h="";for(const g in o){const m=o[g];h+=`;${g}=${m}`}const l=`${e}/${A}${h}`,c=o.encoding;this.string=l,this.type=e,this.subtype=A,this.parameters=o,this.encoding=c,this.name=t.name,this.fileExtension=t.fileExtension}static parse(t){return new u(t)}get structuredSyntaxSuffix(){const t=this.subtype.split("+");return t.length>1?`+${t[t.length-1]}`:void 0}get charset(){return this.parameters.charset}contains(t){const e=typeof t=="string"?u.parse({mediaType:t}):t;if(!((this.type==="*"||this.type===e.type)&&(this.subtype==="*"||this.subtype===e.subtype)))return!1;const A=new Set(Object.entries(this.parameters).map(([r,s])=>`${r}=${s}`)),n=new Set(Object.entries(e.parameters).map(([r,s])=>`${r}=${s}`));for(const r of Array.from(A.values()))if(!n.has(r))return!1;return!0}matches(t){const e=typeof t=="string"?u.parse({mediaType:t}):t;return this.contains(e)||e.contains(this)}matchesAny(...t){for(const e of t)if(this.matches(e))return!0;return!1}equals(t){return this.string===t.string}get isZIP(){return this.matchesAny(u.ZIP,u.LCP_PROTECTED_AUDIOBOOK,u.LCP_PROTECTED_PDF)||this.structuredSyntaxSuffix==="+zip"}get isJSON(){return this.matchesAny(u.JSON)||this.structuredSyntaxSuffix==="+json"}get isOPDS(){return this.matchesAny(u.OPDS1,u.OPDS1_ENTRY,u.OPDS2,u.OPDS2_PUBLICATION,u.OPDS_AUTHENTICATION)||this.structuredSyntaxSuffix==="+json"}get isHTML(){return this.matchesAny(u.HTML,u.XHTML)}get isBitmap(){return this.matchesAny(u.BMP,u.GIF,u.JPEG,u.PNG,u.TIFF,u.WEBP)}get isAudio(){return this.type==="audio"}get isVideo(){return this.type==="video"}get isRWPM(){return this.matchesAny(u.READIUM_AUDIOBOOK_MANIFEST,u.DIVINA_MANIFEST,u.READIUM_WEBPUB_MANIFEST)}get isPublication(){return this.matchesAny(u.READIUM_AUDIOBOOK,u.READIUM_AUDIOBOOK_MANIFEST,u.CBZ,u.DIVINA,u.DIVINA_MANIFEST,u.EPUB,u.LCP_PROTECTED_AUDIOBOOK,u.LCP_PROTECTED_PDF,u.LPF,u.PDF,u.W3C_WPUB_MANIFEST,u.READIUM_WEBPUB,u.READIUM_WEBPUB_MANIFEST,u.ZAB)}static get AAC(){return u.parse({mediaType:"audio/aac",fileExtension:"aac"})}static get ACSM(){return u.parse({mediaType:"application/vnd.adobe.adept+xml",name:"Adobe Content Server Message",fileExtension:"acsm"})}static get AIFF(){return u.parse({mediaType:"audio/aiff",fileExtension:"aiff"})}static get AVI(){return u.parse({mediaType:"video/x-msvideo",fileExtension:"avi"})}static get BINARY(){return u.parse({mediaType:"application/octet-stream"})}static get BMP(){return u.parse({mediaType:"image/bmp",fileExtension:"bmp"})}static get CBZ(){return u.parse({mediaType:"application/vnd.comicbook+zip",name:"Comic Book Archive",fileExtension:"cbz"})}static get CSS(){return u.parse({mediaType:"text/css",fileExtension:"css"})}static get DIVINA(){return u.parse({mediaType:"application/divina+zip",name:"Digital Visual Narratives",fileExtension:"divina"})}static get DIVINA_MANIFEST(){return u.parse({mediaType:"application/divina+json",name:"Digital Visual Narratives",fileExtension:"json"})}static get EPUB(){return u.parse({mediaType:"application/epub+zip",name:"EPUB",fileExtension:"epub"})}static get GIF(){return u.parse({mediaType:"image/gif",fileExtension:"gif"})}static get GZ(){return u.parse({mediaType:"application/gzip",fileExtension:"gz"})}static get HTML(){return u.parse({mediaType:"text/html",fileExtension:"html"})}static get JAVASCRIPT(){return u.parse({mediaType:"text/javascript",fileExtension:"js"})}static get JPEG(){return u.parse({mediaType:"image/jpeg",fileExtension:"jpeg"})}static get JSON(){return u.parse({mediaType:"application/json"})}static get LCP_LICENSE_DOCUMENT(){return u.parse({mediaType:"application/vnd.readium.lcp.license.v1.0+json",name:"LCP License",fileExtension:"lcpl"})}static get LCP_PROTECTED_AUDIOBOOK(){return u.parse({mediaType:"application/audiobook+lcp",name:"LCP Protected Audiobook",fileExtension:"lcpa"})}static get LCP_PROTECTED_PDF(){return u.parse({mediaType:"application/pdf+lcp",name:"LCP Protected PDF",fileExtension:"lcpdf"})}static get LCP_STATUS_DOCUMENT(){return u.parse({mediaType:"application/vnd.readium.license.status.v1.0+json"})}static get LPF(){return u.parse({mediaType:"application/lpf+zip",fileExtension:"lpf"})}static get MP3(){return u.parse({mediaType:"audio/mpeg",fileExtension:"mp3"})}static get MPEG(){return u.parse({mediaType:"video/mpeg",fileExtension:"mpeg"})}static get NCX(){return u.parse({mediaType:"application/x-dtbncx+xml",fileExtension:"ncx"})}static get OGG(){return u.parse({mediaType:"audio/ogg",fileExtension:"oga"})}static get OGV(){return u.parse({mediaType:"video/ogg",fileExtension:"ogv"})}static get OPDS1(){return u.parse({mediaType:"application/atom+xml;profile=opds-catalog"})}static get OPDS1_ENTRY(){return u.parse({mediaType:"application/atom+xml;type=entry;profile=opds-catalog"})}static get OPDS2(){return u.parse({mediaType:"application/opds+json"})}static get OPDS2_PUBLICATION(){return u.parse({mediaType:"application/opds-publication+json"})}static get OPDS_AUTHENTICATION(){return u.parse({mediaType:"application/opds-authentication+json"})}static get OPUS(){return u.parse({mediaType:"audio/opus",fileExtension:"opus"})}static get OTF(){return u.parse({mediaType:"font/otf",fileExtension:"otf"})}static get PDF(){return u.parse({mediaType:"application/pdf",name:"PDF",fileExtension:"pdf"})}static get PNG(){return u.parse({mediaType:"image/png",fileExtension:"png"})}static get READIUM_AUDIOBOOK(){return u.parse({mediaType:"application/audiobook+zip",name:"Readium Audiobook",fileExtension:"audiobook"})}static get READIUM_AUDIOBOOK_MANIFEST(){return u.parse({mediaType:"application/audiobook+json",name:"Readium Audiobook",fileExtension:"json"})}static get READIUM_CONTENT_DOCUMENT(){return u.parse({mediaType:"application/vnd.readium.content+json",name:"Readium Content Document",fileExtension:"json"})}static get READIUM_GUIDED_NAVIGATION_DOCUMENT(){return u.parse({mediaType:"application/guided-navigation+json",name:"Readium Guided Navigation Document",fileExtension:"json"})}static get READIUM_POSITION_LIST(){return u.parse({mediaType:"application/vnd.readium.position-list+json",name:"Readium Position List",fileExtension:"json"})}static get READIUM_WEBPUB(){return u.parse({mediaType:"application/webpub+zip",name:"Readium Web Publication",fileExtension:"webpub"})}static get READIUM_WEBPUB_MANIFEST(){return u.parse({mediaType:"application/webpub+json",name:"Readium Web Publication",fileExtension:"json"})}static get SMIL(){return u.parse({mediaType:"application/smil+xml",fileExtension:"smil"})}static get SVG(){return u.parse({mediaType:"image/svg+xml",fileExtension:"svg"})}static get TEXT(){return u.parse({mediaType:"text/plain",fileExtension:"txt"})}static get TIFF(){return u.parse({mediaType:"image/tiff",fileExtension:"tiff"})}static get TTF(){return u.parse({mediaType:"font/ttf",fileExtension:"ttf"})}static get W3C_WPUB_MANIFEST(){return u.parse({mediaType:"application/x.readium.w3c.wpub+json",name:"Web Publication",fileExtension:"json"})}static get WAV(){return u.parse({mediaType:"audio/wav",fileExtension:"wav"})}static get WEBM_AUDIO(){return u.parse({mediaType:"audio/webm",fileExtension:"webm"})}static get WEBM_VIDEO(){return u.parse({mediaType:"video/webm",fileExtension:"webm"})}static get WEBP(){return u.parse({mediaType:"image/webp",fileExtension:"webp"})}static get WOFF(){return u.parse({mediaType:"font/woff",fileExtension:"woff"})}static get WOFF2(){return u.parse({mediaType:"font/woff2",fileExtension:"woff2"})}static get XHTML(){return u.parse({mediaType:"application/xhtml+xml",fileExtension:"xhtml"})}static get XML(){return u.parse({mediaType:"application/xml",fileExtension:"xml"})}static get ZAB(){return u.parse({mediaType:"application/x.readium.zab+zip",name:"Zipped Audio Book",fileExtension:"zab"})}static get ZIP(){return u.parse({mediaType:"application/zip",fileExtension:"zip"})}}class Qe{constructor(t){this.uri=t,this.parameters=this.getParameters(t)}getParameters(t){const e=/\{\??([^}]+)\}/g,A=t.match(e);return A?new Set(A.join(",").replace(e,"$1").split(",").map(n=>n.trim())):new Set}expand(t){const e=n=>n.split(",").map(r=>{const s=t[r];return s?encodeURIComponent(s):""}).join(","),A=n=>"?"+n.split(",").map(r=>{const s=r.split("=")[0],o=t[s];return o?`${s}=${encodeURIComponent(o)}`:""}).join("&");return this.uri.replace(/\{(\??)([^}]+)\}/g,(...n)=>n[1]?A(n[2]):e(n[2]))}}function fi(i){return i&&i instanceof Array?i:void 0}function Ye(i){return i&&typeof i=="string"?[i]:fi(i)}function ze(i){return typeof i=="string"?new Date(i):void 0}function Yt(i){return isNaN(i)?void 0:i}function b(i){return Yt(i)!==void 0&&Math.sign(i)>=0?i:void 0}function pi(i){const t=new Array;return i.forEach(e=>t.push(e)),t}class S{constructor(t){this.fragments=t.fragments?t.fragments:new Array,this.progression=t.progression,this.totalProgression=t.totalProgression,this.position=t.position,this.otherLocations=t.otherLocations}static deserialize(t){if(!t)return;const e=Yt(t.progression),A=Yt(t.totalProgression),n=Yt(t.position),r=new Map,s=new Set(["fragment","fragments","progression","totalProgression","position"]);return Object.entries(t).forEach(([o,a])=>{s.has(o)||r.set(o,a)}),new S({fragments:Ye(t.fragments||t.fragment),progression:e!==void 0&&e>=0&&e<=1?e:void 0,totalProgression:A!==void 0&&A>=0&&A<=1?A:void 0,position:n!==void 0&&n>0?n:void 0,otherLocations:r.size===0?void 0:r})}serialize(){const t={};return this.fragments&&(t.fragments=this.fragments),this.progression!==void 0&&(t.progression=this.progression),this.totalProgression!==void 0&&(t.totalProgression=this.totalProgression),this.position!==void 0&&(t.position=this.position),this.otherLocations&&this.otherLocations.forEach((e,A)=>t[A]=e),t}}class at{constructor(t){this.after=t.after,this.before=t.before,this.highlight=t.highlight}static deserialize(t){if(t)return new at({after:t.after,before:t.before,highlight:t.highlight})}serialize(){const t={};return this.after!==void 0&&(t.after=this.after),this.before!==void 0&&(t.before=this.before),this.highlight!==void 0&&(t.highlight=this.highlight),t}}class _{constructor(t){this.href=t.href,this.type=t.type,this.title=t.title,this.locations=t.locations?t.locations:new S({}),this.text=t.text}static deserialize(t){if(t&&t.href&&t.type)return new _({href:t.href,type:t.type,title:t.title,locations:S.deserialize(t.locations),text:at.deserialize(t.text)})}serialize(){const t={href:this.href,type:this.type};return this.title!==void 0&&(t.title=this.title),this.locations&&(t.locations=this.locations.serialize()),this.text&&(t.text=this.text.serialize()),t}copyWithLocations(t){return new _({href:this.href,type:this.type,title:this.title,text:this.text,locations:new S({...this.locations,...t})})}}class ht{constructor(t){this.href=t.href,this.templated=t.templated,this.type=t.type,this.title=t.title,this.rels=t.rels,this.properties=t.properties,this.height=t.height,this.width=t.width,this.duration=t.duration,this.bitrate=t.bitrate,this.languages=t.languages,this.alternates=t.alternates,this.children=t.children}static deserialize(t){if(t&&t.href&&typeof t.href=="string")return new ht({href:t.href,templated:t.templated,type:t.type,title:t.title,rels:t.rel?t.rel instanceof Array?new Set(t.rel):new Set([t.rel]):void 0,properties:Q.deserialize(t.properties),height:b(t.height),width:b(t.width),duration:b(t.duration),bitrate:b(t.bitrate),languages:Ye(t.language),alternates:zt.deserialize(t.alternate),children:zt.deserialize(t.children)})}serialize(){const t={href:this.href};return this.templated!==void 0&&(t.templated=this.templated),this.type!==void 0&&(t.type=this.type),this.title!==void 0&&(t.title=this.title),this.rels&&(t.rel=pi(this.rels)),this.properties&&(t.properties=this.properties.serialize()),this.height!==void 0&&(t.height=this.height),this.width!==void 0&&(t.width=this.width),this.duration!==void 0&&(t.duration=this.duration),this.bitrate!==void 0&&(t.bitrate=this.bitrate),this.languages&&(t.language=this.languages),this.alternates&&(t.alternate=this.alternates.serialize()),this.children&&(t.children=this.children.serialize()),t}get mediaType(){return this.type!==void 0?u.parse({mediaType:this.type}):u.BINARY}toURL(t){const e=this.href.replace(/^(\/)/,"");if(e.length===0)return;let A=t||"/";return A.startsWith("/")&&(A="file://"+A),new URL(e,A).href.replace(/^(file:\/\/)/,"")}get templateParameters(){return this.templated?new Qe(this.href).parameters:new Set}expandTemplate(t){return new ht({href:new Qe(this.href).expand(t),templated:!1})}addProperties(t){var e;const A=ht.deserialize(this.serialize());return A.properties=A.properties?(e=A.properties)==null?void 0:e.add(t):new Q(t),A}get locator(){let t=this.href.split("#");return new _({href:t.length>0&&t[0]!==void 0?t[0]:this.href,type:this.type??"",title:this.title,locations:new S({fragments:t.length>1&&t[1]!==void 0?[t[1]]:[]})})}}class zt{constructor(t){this.items=t}static deserialize(t){if(t&&t instanceof Array)return new zt(t.map(e=>ht.deserialize(e)).filter(e=>e!==void 0))}serialize(){return this.items.map(t=>t.serialize())}findWithRel(t){const e=A=>A.rels&&A.rels.has(t);return this.items.find(e)}filterByRel(t){const e=A=>A.rels&&A.rels.has(t);return this.items.filter(e)}findWithHref(t){const e=A=>A.href===t;return this.items.find(e)}findIndexWithHref(t){const e=A=>A.href===t;return this.items.findIndex(e)}findWithMediaType(t){const e=A=>A.mediaType.matches(t);return this.items.find(e)}filterByMediaType(t){const e=A=>A.mediaType.matches(t);return this.items.filter(e)}filterByMediaTypes(t){const e=A=>{for(const n of t)if(A.mediaType.matches(n))return!0;return!1};return this.items.filter(e)}everyIsAudio(){const t=e=>e.mediaType.isAudio;return this.items.length>0&&this.items.every(t)}everyIsBitmap(){const t=e=>e.mediaType.isBitmap;return this.items.length>0&&this.items.every(t)}everyIsHTML(){const t=e=>e.mediaType.isHTML;return this.items.length>0&&this.items.every(t)}everyIsVideo(){const t=e=>e.mediaType.isVideo;return this.items.length>0&&this.items.every(t)}everyMatchesMediaType(t){return Array.isArray(t)?this.items.length>0&&this.items.every(e=>{for(const A of t)return e.mediaType.matches(A);return!1}):this.items.length>0&&this.items.every(e=>e.mediaType.matches(t))}filterLinksHasType(){return this.items.filter(t=>t.type)}}class Nt{constructor(t){this.cssSelector=t.cssSelector,this.textNodeIndex=t.textNodeIndex,this.charOffset=t.charOffset}static deserialize(t){if(!(t&&t.cssSelector))return;let e=b(t.textNodeIndex);if(e===void 0)return;let A=b(t.charOffset);return A===void 0&&(A=b(t.offset)),new Nt({cssSelector:t.cssSelector,textNodeIndex:e,charOffset:A})}serialize(){const t={cssSelector:this.cssSelector,textNodeIndex:this.textNodeIndex};return this.charOffset!==void 0&&(t.charOffset=this.charOffset),t}}class qt{constructor(t){this.start=t.start,this.end=t.end}static deserialize(t){if(!t)return;let e=Nt.deserialize(t.start);if(e)return new qt({start:e,end:Nt.deserialize(t.end)})}serialize(){const t={start:this.start.serialize()};return this.end&&(t.end=this.end.serialize()),t}}S.prototype.getCssSelector=function(){var i;return(i=this.otherLocations)==null?void 0:i.get("cssSelector")},S.prototype.getPartialCfi=function(){var i;return(i=this.otherLocations)==null?void 0:i.get("partialCfi")},S.prototype.getDomRange=function(){var i;return qt.deserialize((i=this.otherLocations)==null?void 0:i.get("domRange"))},S.prototype.fragmentParameters=function(){return new Map(this.fragments.map(i=>i.startsWith("#")?i.slice(1):i).join("&").split("&").filter(i=>!i.startsWith("#")).map(i=>i.split("=")).filter(i=>i.length===2).map(i=>[i[0].trim().toLowerCase(),i[1].trim()]))},S.prototype.htmlId=function(){if(!this.fragments.length)return;let i=this.fragments.find(t=>t.length&&!t.includes("="));if(!i){const t=this.fragmentParameters();t.has("id")?i=t.get("id"):t.has("name")&&(i=t.get("name"))}return i!=null&&i.startsWith("#")?i.slice(1):i},S.prototype.page=function(){const i=parseInt(this.fragmentParameters().get("page"));if(!isNaN(i)&&i>=0)return i},S.prototype.time=function(){const i=parseInt(this.fragmentParameters().get("t"));if(!isNaN(i))return i},S.prototype.space=function(){const i=this.fragmentParameters();if(!i.has("xywh"))return;const t=i.get("xywh").split(",").map(e=>parseInt(e));if(t.length===4&&!t.some(isNaN))return t};class _t{constructor(t){this.currency=t.currency,this.value=t.value}static deserialize(t){if(!t)return;let e=t.currency;if(!(e&&typeof e=="string"&&e.length>0))return;let A=b(t.value);if(A!==void 0)return new _t({currency:e,value:A})}serialize(){return{currency:this.currency,value:this.value}}}class wt{constructor(t){this.type=t.type,this.children=t.children}static deserialize(t){if(t&&t.type)return new wt({type:t.type,children:wt.deserializeArray(t.children)})}static deserializeArray(t){if(t instanceof Array)return t.map(e=>wt.deserialize(e)).filter(e=>e!==void 0)}serialize(){const t={type:this.type};return this.children&&(t.children=this.children.map(e=>e.serialize())),t}}class $t{constructor(t){this.total=t.total,this.position=t.position}static deserialize(t){if(t)return new $t({total:b(t.total),position:b(t.position)})}serialize(){const t={};return this.total!==void 0&&(t.total=this.total),this.position!==void 0&&(t.position=this.position),t}}class te{constructor(t){this.total=t.total,this.available=t.available}static deserialize(t){if(t)return new te({total:b(t.total),available:b(t.available)})}serialize(){const t={};return this.total!==void 0&&(t.total=this.total),this.available!==void 0&&(t.available=this.available),t}}class ee{constructor(t){this.state=t.state,this.since=t.since,this.until=t.until}static deserialize(t){if(t&&t.state)return new ee({state:t.state,since:ze(t.since),until:ze(t.until)})}serialize(){const t={state:this.state};return this.since!==void 0&&(t.since=this.since.toISOString()),this.until!==void 0&&(t.until=this.until.toISOString()),t}}Q.prototype.getNumberOfItems=function(){return b(this.otherProperties.numberOfItems)},Q.prototype.getPrice=function(){return _t.deserialize(this.otherProperties.price)},Q.prototype.getIndirectAcquisitions=function(){const i=this.otherProperties.indirectAcquisition;if(i&&i instanceof Array)return i.map(t=>wt.deserialize(t)).filter(t=>t!==void 0)},Q.prototype.getHolds=function(){return $t.deserialize(this.otherProperties.holds)},Q.prototype.getCopies=function(){return te.deserialize(this.otherProperties.copies)},Q.prototype.getAvailability=function(){return ee.deserialize(this.otherProperties.availability)},Q.prototype.getAuthenticate=function(){return ht.deserialize(this.otherProperties.authenticate)},Q.prototype.getClipped=function(){return this.otherProperties.clipped},Q.prototype.getFit=function(){return this.otherProperties.fit},Q.prototype.getOrientation=function(){return this.otherProperties.orientation},Q.prototype.getOverflow=function(){return this.otherProperties.overflow},Q.prototype.getPage=function(){return this.otherProperties.page||void 0},Q.prototype.getSpread=function(){return this.otherProperties.spread||void 0};var $;(function(i){i.NONE="none",i.DESCENDANT="descendant",i.CHILD="child"})($||($={}));var H;(function(i){i.id="id",i.class="class",i.tag="tag",i.attribute="attribute",i.nthchild="nthchild",i.nthoftype="nthoftype"})(H||(H={}));const Bi="CssSelectorGenerator";function Ne(i="unknown problem",...t){console.warn(`${Bi}: ${i}`,...t)}H.id,H.class,H.tag,H.attribute;function Ei(i){return i instanceof RegExp}function wi(i){return i.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".+")}function Ii(i){const t=i.map(e=>{if(Ei(e))return A=>e.test(A);if(typeof e=="function")return A=>{const n=e(A);return typeof n!="boolean"?(Ne("pattern matcher function invalid","Provided pattern matching function does not return boolean. It's result will be ignored.",e),!1):n};if(typeof e=="string"){const A=new RegExp("^"+wi(e)+"$");return n=>A.test(n)}return Ne("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",e),()=>!1});return e=>t.some(A=>A(e))}$.NONE+"",$.NONE,$.DESCENDANT+"",$.DESCENDANT,$.CHILD+"",$.CHILD,H.nthoftype,H.tag,H.id,H.class,H.attribute,H.nthchild,Ii(["class","id","ng-*"]);class St{}function Se(i){return i.split("").reverse().join("")}function Fi(i,t,e){const A=Se(t);return e.map(n=>{const r=Math.max(0,n.end-t.length-n.errors),s=Se(i.slice(r,n.end));return{start:Te(s,A,n.errors).reduce((o,a)=>n.end-a.end<o?n.end-a.end:o,n.end),end:n.end,errors:n.errors}})}function Ae(i){return(i|-i)>>31&1}function xe(i,t,e,A){let n=i.P[e],r=i.M[e];const s=A>>>31,o=t[e]|s,a=o|r,h=(o&n)+n^n|o;let l=r|~(h|n),c=n&h;const g=Ae(l&i.lastRowMask[e])-Ae(c&i.lastRowMask[e]);return l<<=1,c<<=1,c|=s,l|=Ae(A)-s,n=c|~(a|l),r=l&a,i.P[e]=n,i.M[e]=r,g}function Te(i,t,e){if(t.length===0)return[];e=Math.min(e,t.length);const A=[],n=32,r=Math.ceil(t.length/n)-1,s={P:new Uint32Array(r+1),M:new Uint32Array(r+1),lastRowMask:new Uint32Array(r+1)};s.lastRowMask.fill(1<<31),s.lastRowMask[r]=1<<(t.length-1)%n;const o=new Uint32Array(r+1),a=new Map,h=[];for(let g=0;g<256;g++)h.push(o);for(let g=0;g<t.length;g+=1){const m=t.charCodeAt(g);if(a.has(m))continue;const M=new Uint32Array(r+1);a.set(m,M),m<h.length&&(h[m]=M);for(let B=0;B<=r;B+=1){M[B]=0;for(let w=0;w<n;w+=1){const f=B*n+w;f>=t.length||t.charCodeAt(f)===m&&(M[B]|=1<<w)}}}let l=Math.max(0,Math.ceil(e/n)-1);const c=new Uint32Array(r+1);for(let g=0;g<=l;g+=1)c[g]=(g+1)*n;c[r]=t.length;for(let g=0;g<=l;g+=1)s.P[g]=-1,s.M[g]=0;for(let g=0;g<i.length;g+=1){const m=i.charCodeAt(g);let M;m<h.length?M=h[m]:(M=a.get(m),typeof M>"u"&&(M=o));let B=0;for(let w=0;w<=l;w+=1)B=xe(s,M,w,B),c[w]+=B;if(c[l]-B<=e&&l<r&&(M[l+1]&1||B<0)){l+=1,s.P[l]=-1,s.M[l]=0;let w;if(l===r){const f=t.length%n;w=f===0?n:f}else w=n;c[l]=c[l-1]+w-B+xe(s,M,l,B)}else for(;l>0&&c[l]>=e+n;)l-=1;l===r&&c[l]<=e&&(c[l]<e&&A.splice(0,A.length),A.push({start:-1,end:g+1,errors:c[l]}),e=c[l])}return A}function Ui(i,t,e){const A=Te(i,t,e);return Fi(i,t,A)}function je(i,t,e){let A=0;const n=[];for(;A!==-1;)A=i.indexOf(t,A),A!==-1&&(n.push({start:A,end:A+t.length,errors:0}),A+=1);return n.length>0?n:Ui(i,t,e)}function Ve(i,t){return t.length===0||i.length===0?0:1-je(i,t,t.length)[0].errors/t.length}function yi(i,t,e={}){if(t.length===0)return null;const A=Math.min(256,t.length/2),n=je(i,t,A);if(n.length===0)return null;const r=o=>{const a=1-o.errors/t.length,h=e.prefix?Ve(i.slice(Math.max(0,o.start-e.prefix.length),o.start),e.prefix):1,l=e.suffix?Ve(i.slice(o.end,o.end+e.suffix.length),e.suffix):1;let c=1;typeof e.hint=="number"&&(c=1-Math.abs(o.start-e.hint)/i.length);const g=50*a+20*h+20*l+2*c,m=50+20+20+2;return g/m},s=n.map(o=>({start:o.start,end:o.end,score:r(o)}));return s.sort((o,a)=>a.score-o.score),s[0]}function ie(i,t,e){const A=e===1?t:t-1;if(i.charAt(A).trim()!=="")return t;let n,r;if(e===2?(n=i.substring(0,t),r=n.trimEnd()):(n=i.substring(t),r=n.trimStart()),!r.length)return-1;const s=n.length-r.length;return e===2?t-s:t+s}function De(i,t){const e=i.commonAncestorContainer.ownerDocument.createNodeIterator(i.commonAncestorContainer,NodeFilter.SHOW_TEXT),A=t===1?i.startContainer:i.endContainer,n=t===1?i.endContainer:i.startContainer;let r=e.nextNode();for(;r&&r!==A;)r=e.nextNode();t===2&&(r=e.previousNode());let s=-1;const o=()=>{if(r=t===1?e.nextNode():e.previousNode(),r){const a=r.textContent,h=t===1?0:a.length;s=ie(a,h,t)}};for(;r&&s===-1&&r!==n;)o();if(r&&s>=0)return{node:r,offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function Ci(i){if(!i.toString().trim().length)throw new RangeError("Range contains no non-whitespace text");if(i.startContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range startContainer is not a text node");if(i.endContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range endContainer is not a text node");const t=i.cloneRange();let e=!1,A=!1;const n={start:ie(i.startContainer.textContent,i.startOffset,1),end:ie(i.endContainer.textContent,i.endOffset,2)};if(n.start>=0&&(t.setStart(i.startContainer,n.start),e=!0),n.end>0&&(t.setEnd(i.endContainer,n.end),A=!0),e&&A)return t;if(!e){const{node:r,offset:s}=De(t,1);r&&s>=0&&t.setStart(r,s)}if(!A){const{node:r,offset:s}=De(t,2);r&&s>0&&t.setEnd(r,s)}return t}function be(i){var t;switch(i.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return((t=i.textContent)==null?void 0:t.length)??0;default:return 0}}function Pe(i){let t=i.previousSibling,e=0;for(;t;)e+=be(t),t=t.previousSibling;return e}function ve(i,...t){let e=t.shift();const A=i.ownerDocument.createNodeIterator(i,NodeFilter.SHOW_TEXT),n=[];let r=A.nextNode(),s,o=0;for(;e!==void 0&&r;)s=r,o+s.data.length>e?(n.push({node:s,offset:e-o}),e=t.shift()):(r=A.nextNode(),o+=s.data.length);for(;e!==void 0&&s&&o===e;)n.push({node:s,offset:s.data.length}),e=t.shift();if(e!==void 0)throw new RangeError("Offset exceeds text length");return n}class O{constructor(t,e){if(e<0)throw new Error("Offset is invalid");this.element=t,this.offset=e}relativeTo(t){if(!t.contains(this.element))throw new Error("Parent is not an ancestor of current element");let e=this.element,A=this.offset;for(;e!==t;)A+=Pe(e),e=e.parentElement;return new O(e,A)}resolve(t={}){try{return ve(this.element,this.offset)[0]}catch(e){if(this.offset===0&&t.direction!==void 0){const A=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);A.currentNode=this.element;const n=t.direction===1,r=n?A.nextNode():A.previousNode();if(!r)throw e;return{node:r,offset:n?0:r.data.length}}else throw e}}static fromCharOffset(t,e){switch(t.nodeType){case Node.TEXT_NODE:return O.fromPoint(t,e);case Node.ELEMENT_NODE:return new O(t,e);default:throw new Error("Node is not an element or text node")}}static fromPoint(t,e){switch(t.nodeType){case Node.TEXT_NODE:{if(e<0||e>t.data.length)throw new Error("Text node offset is out of range");if(!t.parentElement)throw new Error("Text node has no parent");const A=Pe(t)+e;return new O(t.parentElement,A)}case Node.ELEMENT_NODE:{if(e<0||e>t.childNodes.length)throw new Error("Child node offset is out of range");let A=0;for(let n=0;n<e;n++)A+=be(t.childNodes[n]);return new O(t,A)}default:throw new Error("Point is not in an element or text node")}}}class tt{constructor(t,e){this.start=t,this.end=e}relativeTo(t){return new tt(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[t,e]=ve(this.start.element,this.start.offset,this.end.offset):(t=this.start.resolve({direction:1}),e=this.end.resolve({direction:2}));const A=new Range;return A.setStart(t.node,t.offset),A.setEnd(e.node,e.offset),A}static fromRange(t){const e=O.fromPoint(t.startContainer,t.startOffset),A=O.fromPoint(t.endContainer,t.endOffset);return new tt(e,A)}static fromOffsets(t,e,A){return new tt(new O(t,e),new O(t,A))}static trimmedRange(t){return Ci(tt.fromRange(t).toRange())}}class xt{constructor(t,e,A){this.root=t,this.start=e,this.end=A}static fromRange(t,e){const A=tt.fromRange(e).relativeTo(t);return new xt(t,A.start.offset,A.end.offset)}static fromSelector(t,e){return new xt(t,e.start,e.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){return tt.fromOffsets(this.root,this.start,this.end).toRange()}}class Tt{constructor(t,e,A={}){this.root=t,this.exact=e,this.context=A}static fromRange(t,e){const A=t.textContent,n=tt.fromRange(e).relativeTo(t),r=n.start.offset,s=n.end.offset,o=32;return new Tt(t,A.slice(r,s),{prefix:A.slice(Math.max(0,r-o),r),suffix:A.slice(s,Math.min(A.length,s+o))})}static fromSelector(t,e){const{prefix:A,suffix:n}=e;return new Tt(t,e.exact,{prefix:A,suffix:n})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(t={}){return this.toPositionAnchor(t).toRange()}toPositionAnchor(t={}){const e=this.root.textContent,A=yi(e,this.exact,{...this.context,hint:t.hint});if(!A)throw new Error("Quote not found");return new xt(this.root,A.start,A.end)}}function Ri(i){const t=i.tagName.toUpperCase();return t==="IMG"||t==="VIDEO"||t==="AUDIO"||t==="IFRAME"||t==="OBJECT"||t==="EMBED"||t==="CANVAS"}function ne(i,t){try{const e=t.locations,A=t.text;if(A&&A.highlight){let n;e&&e.getCssSelector()&&(n=i.querySelector(e.getCssSelector())),n||(n=i.body);const r=new Tt(n,A.highlight,{prefix:A.before,suffix:A.after});try{return r.toRange()}catch{return console.warn("Quote not found:",r),null}}if(e){let n=null;if(!n&&e.getCssSelector()&&(n=i.querySelector(e.getCssSelector())),!n&&e.fragments){for(const r of e.fragments)if(n=i.getElementById(r),n)break}if(n){const r=i.createRange();return n.childNodes.length===0||Ri(n)?(r.selectNode(n),r):(r.setStartBefore(n),r.setEndAfter(n),r)}}}catch(e){console.error(e)}return null}function Qi(i,t){let e=i.getClientRects();e.length||i.commonAncestorContainer.nodeType===Node.ELEMENT_NODE&&(e=i.commonAncestorContainer.getClientRects());const A=1,n=[];for(const h of e)n.push({bottom:h.bottom,height:h.height,left:h.left,right:h.right,top:h.top,width:h.width});const r=Ge(n,A,t),s=zi(r,A),o=He(s),a=2*2;for(let h=o.length-1;h>=0;h--){const l=o[h];if(!(l.width*l.height>a))if(o.length>1)o.splice(h,1);else break}return o}function Ge(i,t,e){for(let A=0;A<i.length;A++)for(let n=A+1;n<i.length;n++){const r=i[A],s=i[n];if(r===s)continue;const o=k(r.top,s.top,t)&&k(r.bottom,s.bottom,t),a=k(r.left,s.left,t)&&k(r.right,s.right,t);if((a&&!e||o&&!a)&&Je(r,s,t)){const h=i.filter(c=>c!==r&&c!==s),l=Yi(r,s);return h.push(l),Ge(h,t,e)}}return i}function Yi(i,t){const e=Math.min(i.left,t.left),A=Math.max(i.right,t.right),n=Math.min(i.top,t.top),r=Math.max(i.bottom,t.bottom);return{bottom:r,height:r-n,left:e,right:A,top:n,width:A-e}}function zi(i,t){const e=new Set(i);for(const A of i){if(!(A.width>1&&A.height>1)){e.delete(A);continue}for(const n of i)if(A!==n&&e.has(n)&&Ni(n,A,t)){e.delete(A);break}}return Array.from(e)}function Ni(i,t,e){return jt(i,t.left,t.top,e)&&jt(i,t.right,t.top,e)&&jt(i,t.left,t.bottom,e)&&jt(i,t.right,t.bottom,e)}function jt(i,t,e,A){return(i.left<t||k(i.left,t,A))&&(i.right>t||k(i.right,t,A))&&(i.top<e||k(i.top,e,A))&&(i.bottom>e||k(i.bottom,e,A))}function He(i){for(let t=0;t<i.length;t++)for(let e=t+1;e<i.length;e++){const A=i[t],n=i[e];if(A!==n&&Je(A,n,-1)){let r=[],s;const o=ke(A,n);if(o.length===1)r=o,s=A;else{const h=ke(n,A);o.length<h.length?(r=o,s=A):(r=h,s=n)}const a=i.filter(h=>h!==s);return Array.prototype.push.apply(a,r),He(a)}}return i}function ke(i,t){const e=Si(t,i);if(e.height===0||e.width===0)return[i];const A=[];{const n={bottom:i.bottom,height:0,left:i.left,right:e.left,top:i.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&A.push(n)}{const n={bottom:e.top,height:0,left:e.left,right:e.right,top:i.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&A.push(n)}{const n={bottom:i.bottom,height:0,left:e.left,right:e.right,top:e.bottom,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&A.push(n)}{const n={bottom:i.bottom,height:0,left:e.right,right:i.right,top:i.top,width:0};n.width=n.right-n.left,n.height=n.bottom-n.top,n.height!==0&&n.width!==0&&A.push(n)}return A}function Si(i,t){const e=Math.max(i.left,t.left),A=Math.min(i.right,t.right),n=Math.max(i.top,t.top),r=Math.min(i.bottom,t.bottom);return{bottom:r,height:Math.max(0,r-n),left:e,right:A,top:n,width:Math.max(0,A-e)}}function Je(i,t,e){return(i.left<t.right||e>=0&&k(i.left,t.right,e))&&(t.left<i.right||e>=0&&k(t.left,i.right,e))&&(i.top<t.bottom||e>=0&&k(i.top,t.bottom,e))&&(t.top<i.bottom||e>=0&&k(t.top,i.bottom,e))}function k(i,t,e){return Math.abs(i-t)<=e}function We(i){const t={},e=i.document.documentElement.style;for(const A in i.document.documentElement.style)Object.hasOwn(e,A)&&!Number.isNaN(Number.parseInt(A))&&(t[e[A]]=e.getPropertyValue(e[A]));return t}function xi(i,t){const e=We(i);Object.keys(e).forEach(A=>{t.hasOwnProperty(A)||re(i,A)}),Object.entries(t).forEach(([A,n])=>{e[A]!==n&&Vt(i,A,n)})}function Le(i,t){return i.document.documentElement.style.getPropertyValue(t)}function Vt(i,t,e){i.document.documentElement.style.setProperty(t,e)}function re(i,t){i.document.documentElement.style.removeProperty(t)}const Ti=i=>{if(i.startsWith("rgb")){const t=i.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);if(t)return{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10),a:t[4]?parseInt(t[4],10)/255:1}}else if(i.startsWith("#")){const t=i.slice(1);if(t.length===3||t.length===4)return{r:parseInt(t[0]+t[0],16)/255,g:parseInt(t[1]+t[1],16)/255,b:parseInt(t[2]+t[2],16)/255,a:t.length===4?parseInt(t[3]+t[3],16)/255:1};if(t.length===6||t.length===8)return{r:parseInt(t[0]+t[1],16)/255,g:parseInt(t[2]+t[3],16)/255,b:parseInt(t[4]+t[5],16)/255,a:t.length===8?parseInt(t[6]+t[7],16)/255:1}}return{r:0,g:0,b:0,a:1}},ji=i=>.2126*i.r*i.a+.7152*i.g*i.a+.0722*i.b*i.a,Vi=i=>{const t=Ti(i);return ji(t)<128},Di=()=>"Highlight"in window,Oe=["IMG","IMAGE","AUDIO","VIDEO","SVG"];class bi{constructor(t,e,A,n){this.wnd=t,this.comms=e,this.id=A,this.name=n,this.items=[],this.lastItemId=0,this.container=void 0,this.activateable=!1,this.experimentalHighlights=!1,this.currentRender=0,Di()&&(this.experimentalHighlights=!0,this.notTextFlag=new Map)}get activeable(){return this.activateable}set activeable(t){this.activateable=t}add(t){var e,A,n,r;const s=`${this.id}-${this.lastItemId++}`,o=ne(this.wnd.document,t.locator);if(!o){this.comms.log("Can't locate DOM range for decoration",t);return}const a=o.commonAncestorContainer;a.nodeType!==Node.TEXT_NODE&&this.experimentalHighlights&&(Oe.includes(a.nodeName.toUpperCase())&&((e=this.notTextFlag)==null||e.set(s,!0)),a.querySelector(Oe.join(", ").toLowerCase())&&((A=this.notTextFlag)==null||A.set(s,!0)),(((n=a.textContent)==null?void 0:n.trim())||"").length===0&&((r=this.notTextFlag)==null||r.set(s,!0)));const h={decoration:t,id:s,range:o};this.items.push(h),this.layout(h),this.renderLayout([h])}remove(t){var e,A;const n=this.items.findIndex(s=>s.decoration.id===t);if(n<0)return;const r=this.items[n];if(this.items.splice(n,1),r.clickableElements=void 0,r.container&&(r.container.remove(),r.container=void 0),this.experimentalHighlights&&!((e=this.notTextFlag)!=null&&e.has(r.id))){const s=this.wnd.CSS.highlights.get(this.id);s==null||s.delete(r.range)}(A=this.notTextFlag)==null||A.delete(r.id)}update(t){this.remove(t.id),this.add(t)}clear(){var t;this.clearContainer(),this.items.length=0,(t=this.notTextFlag)==null||t.clear()}requestLayout(){this.wnd.cancelAnimationFrame(this.currentRender),this.clearContainer(),this.items.forEach(t=>this.layout(t)),this.renderLayout(this.items)}experimentalLayout(t){var e,A;const[n,r]=this.requireContainer(!0);r.add(t.range),n.innerHTML=`
28
28
  ::highlight(${this.id}) {
29
29
  color: black;
30
30
  background-color: ${((A=(e=t.decoration)==null?void 0:e.style)==null?void 0:A.tint)??"yellow"};
@@ -80,7 +80,7 @@
80
80
  body::-webkit-scrollbar {
81
81
  display: none; /* for Chrome, Safari, and Opera */
82
82
  }
83
- `,t.document.head.appendChild(A),this.resizeObserver=new ResizeObserver(()=>{this.comms.ready&&this.handleScroll()}),this.resizeObserver.observe(t.document.body),t.addEventListener("scroll",this.handleScroll,{passive:!0}),e.register("go_progression",L.moduleName,(n,r)=>{const s=n;if(s<0||s>1){e.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*s,this.reportProgress({progress:s,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_id",L.moduleName,(n,r)=>{const s=t.document.getElementById(n);if(!s){r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=s.getBoundingClientRect().top+t.scrollY-t.innerHeight/2;const o=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:o,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_text",L.moduleName,(n,r)=>{let s;Array.isArray(n)&&(n.length>1&&(s=n[1]),n=n[0]);const o=at.deserialize(n),a=ne(this.wnd.document,new _({href:t.location.href,type:"text/html",text:o,locations:s?new S({otherLocations:new Map([["cssSelector",s]])}):void 0}));if(!a){r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+t.scrollY-t.innerHeight/2;const h=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:h,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_start",L.moduleName,(n,r)=>{if(this.doc().scrollTop===0)return r(!1);this.doc().scrollTop=0,this.reportProgress({progress:0,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("go_end",L.moduleName,(n,r)=>{if(this.doc().scrollTop===0)return r(!1);this.doc().scrollTop=0,this.reportProgress({progress:0,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("unfocus",L.moduleName,(n,r)=>{T(this.wnd),r(!0)}),e.register(["go_next","go_prev"],L.moduleName,(n,r)=>r(!1)),e.register("focus",L.moduleName,(n,r)=>{const s=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:s,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("first_visible_locator",L.moduleName,(n,r)=>{const s=eA(t,!0);this.comms.send("first_visible_locator",s.serialize()),r(!0)}),e.log("ScrollSnapper Mounted"),!0}unmount(t,e){var A;return e.unregisterAll(L.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&t.removeEventListener("scroll",this.handleScroll),(A=t.document.getElementById(rA))==null||A.remove(),e.log("ScrollSnapper Unmounted"),!0}};sA.moduleName="scroll_snapper";let Xi=sA;class oA extends St{constructor(){super(...arguments),this.pointerMoved=!1,this.onPointerUp=this.onPointUp.bind(this),this.onPointerMove=this.onPointMove.bind(this),this.onPointerDown=this.onPointDown.bind(this),this.onContextMenu=this.onContext.bind(this),this.onClicker=this.onClick.bind(this)}onPointUp(t){var e,A,n,r,s;const o=this.wnd.getSelection();if(o&&((e=o.toString())==null?void 0:e.length)>0){const h=(A=o.getRangeAt(0))==null?void 0:A.getClientRects();if(!h||h.length===0)return;const l=h[0],c={text:o.toString(),x:l.x,y:l.y,width:l.width,height:l.height,targetFrameSrc:(r=(n=this.wnd)==null?void 0:n.location)==null?void 0:r.href};this.comms.send("text_selected",c)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!(o!=null&&o.isCollapsed)||!t.isPrimary)return;const a=this.wnd.devicePixelRatio;t.preventDefault(),this.comms.send(t.pointerType==="touch"?"tap":"click",{defaultPrevented:t.defaultPrevented,x:t.clientX*a,y:t.clientY*a,targetFrameSrc:this.wnd.location.href,targetElement:t.target.outerHTML,interactiveElement:(s=tA(t.target))==null?void 0:s.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)}),this.pointerMoved=!1}onPointMove(t){if(t.movementY!==void 0&&t.movementX!==void 0){(Math.abs(t.movementX)>1||Math.abs(t.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onContext(t){this.onPointUp(t),this.pointerMoved=!1}onClick(t){if(t.preventDefault(),!t.isTrusted){const e=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:t.clientX,clientY:t.clientY});Object.defineProperty(e,"target",{writable:!1,value:t.target}),Object.defineProperty(e,"defaultPrevented",{writable:!1,value:t.defaultPrevented}),this.onPointUp(e)}}mount(t,e){return this.wnd=t,this.comms=e,t.document.addEventListener("pointerdown",this.onPointerDown),t.document.addEventListener("pointerup",this.onPointerUp),t.document.addEventListener("contextmenu",this.onContextMenu),t.document.addEventListener("pointermove",this.onPointerMove),t.document.addEventListener("click",this.onClicker),e.log("Peripherals Mounted"),!0}unmount(t,e){return t.document.removeEventListener("pointerdown",this.onPointerDown),t.document.removeEventListener("pointerup",this.onPointerUp),t.document.removeEventListener("contextmenu",this.onContextMenu),t.document.removeEventListener("pointermove",this.onPointerMove),t.document.removeEventListener("click",this.onClicker),e.log("Peripherals Unmounted"),!0}}oA.moduleName="peripherals";const aA=class Me extends St{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(t){var e;(e=this.comms)==null||e.send("error",{message:t.message,filename:t.filename,lineno:t.lineno,colno:t.colno})}unblock(t){var e;for(t._readium_blockEvents=!1;((e=t._readium_blockedEvents)==null?void 0:e.length)>0;){const A=t._readium_blockedEvents.shift();switch(A[0]){case 0:Reflect.apply(A[1],A[2],A[3]);break;case 1:const n=A[1],r=A[2];t.removeEventListener(n.type,t._readium_eventBlocker,!0);const s=new Event(n.type,{bubbles:n.bubbles,cancelable:n.cancelable});r?r.dispatchEvent(s):t.dispatchEvent(s);break}}}onMediaPlayEvent(){var t;this.mediaPlayingCount++,(t=this.comms)==null||t.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){var t;this.mediaPlayingCount>0&&this.mediaPlayingCount--,(t=this.comms)==null||t.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(t){const e=t.document.querySelectorAll("audio,video");for(let A=0;A<e.length;A++)e[A].pause()}mount(t,e){this.comms=e,t.addEventListener("error",this.wndOnErr,!1),Reflect.defineProperty(t.navigator,"epubReadingSystem",{value:{name:"readium-ts-toolkit",version:"2.0.0-beta.2",hasFeature:(n,r="")=>{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 t.document&&t.document.getAnimations().forEach(n=>{n.cancel(),this.allAnimations.add(n)}),e.register("activate",Me.moduleName,(n,r)=>{this.allAnimations.forEach(s=>{s.cancel(),s.play()}),r(!0)}),e.register("unfocus",Me.moduleName,(n,r)=>{this.pauseAllMedia(t),this.allAnimations.forEach(s=>s.pause()),r(!0)});const A=t.document.querySelectorAll("audio,video");for(let n=0;n<A.length;n++){const r=A[n];r.addEventListener("play",this.onMediaPlayEvent,{passive:!0}),r.addEventListener("pause",this.onMediaPauseEvent,{passive:!0})}return e.log("Setup Mounted"),!0}unmount(t,e){return t.removeEventListener("error",this.wndOnErr),t.removeEventListener("play",this.onMediaPlayEvent),t.removeEventListener("pause",this.onMediaPauseEvent),this.allAnimations.forEach(A=>A.cancel()),this.allAnimations.clear(),e.log("Setup Unmounted"),!0}};aA.moduleName="setup";let hA=aA;const lA="readium-viewport",cA=class nt extends hA{onViewportWidthChanged(t){const e=t.target;Vt(e,"--RS__viewportWidth",`${e.innerWidth}px`)}mount(t,e){if(!super.mount(t,e))return!1;const A=t.document.createElement("meta");return A.dataset.readium="true",A.setAttribute("name","viewport"),A.setAttribute("id",lA),A.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"),t.document.head.appendChild(A),t.addEventListener("orientationchange",this.onViewportWidthChanged),t.addEventListener("resize",this.onViewportWidthChanged),this.onViewportWidthChanged({target:t}),e.register("get_properties",nt.moduleName,(n,r)=>{We(t),r(!0)}),e.register("update_properties",nt.moduleName,(n,r)=>{n["--RS__viewportWidth"]=`${t.innerWidth}px`,xi(t,n),r(!0)}),e.register("set_property",nt.moduleName,(n,r)=>{const s=n;Vt(t,s[0],s[1]),r(!0)}),e.register("remove_property",nt.moduleName,(n,r)=>{re(t,n),r(!0)}),e.register("activate",nt.moduleName,(n,r)=>{this.unblock(t),r(!0)}),e.log("ReflowableSetup Mounted"),!0}unmount(t,e){var A;return e.unregisterAll(nt.moduleName),(A=t.document.head.querySelector(`#${lA}`))==null||A.remove(),t.removeEventListener("orientationchange",this.onViewportWidthChanged),e.log("ReflowableSetup Unmounted"),super.unmount(t,e)}};cA.moduleName="reflowable_setup";let Zi=cA;const gA="readium-fixed-style",dA=class et extends hA{mount(t,e){if(!super.mount(t,e))return!1;t.navigator.epubReadingSystem.layoutStyle="paginated";const A=t.document.createElement("style");return A.id=gA,A.dataset.readium="true",A.textContent=`
83
+ `,t.document.head.appendChild(A),this.resizeObserver=new ResizeObserver(()=>{this.comms.ready&&this.handleScroll()}),this.resizeObserver.observe(t.document.body),t.addEventListener("scroll",this.handleScroll,{passive:!0}),e.register("go_progression",L.moduleName,(n,r)=>{const s=n;if(s<0||s>1){e.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*s,this.reportProgress({progress:s,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_id",L.moduleName,(n,r)=>{const s=t.document.getElementById(n);if(!s){r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=s.getBoundingClientRect().top+t.scrollY-t.innerHeight/2;const o=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:o,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_text",L.moduleName,(n,r)=>{let s;Array.isArray(n)&&(n.length>1&&(s=n[1]),n=n[0]);const o=at.deserialize(n),a=ne(this.wnd.document,new _({href:t.location.href,type:"text/html",text:o,locations:s?new S({otherLocations:new Map([["cssSelector",s]])}):void 0}));if(!a){r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+t.scrollY-t.innerHeight/2;const h=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:h,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_start",L.moduleName,(n,r)=>{if(this.doc().scrollTop===0)return r(!1);this.doc().scrollTop=0,this.reportProgress({progress:0,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("go_end",L.moduleName,(n,r)=>{if(this.doc().scrollTop===0)return r(!1);this.doc().scrollTop=0,this.reportProgress({progress:0,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("unfocus",L.moduleName,(n,r)=>{T(this.wnd),r(!0)}),e.register(["go_next","go_prev"],L.moduleName,(n,r)=>r(!1)),e.register("focus",L.moduleName,(n,r)=>{const s=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:s,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("first_visible_locator",L.moduleName,(n,r)=>{const s=eA(t,!0);this.comms.send("first_visible_locator",s.serialize()),r(!0)}),e.log("ScrollSnapper Mounted"),!0}unmount(t,e){var A;return e.unregisterAll(L.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&t.removeEventListener("scroll",this.handleScroll),(A=t.document.getElementById(rA))==null||A.remove(),e.log("ScrollSnapper Unmounted"),!0}};sA.moduleName="scroll_snapper";let Xi=sA;class oA extends St{constructor(){super(...arguments),this.pointerMoved=!1,this.onPointerUp=this.onPointUp.bind(this),this.onPointerMove=this.onPointMove.bind(this),this.onPointerDown=this.onPointDown.bind(this),this.onContextMenu=this.onContext.bind(this),this.onClicker=this.onClick.bind(this)}onPointUp(t){var e,A,n,r,s;const o=this.wnd.getSelection();if(o&&((e=o.toString())==null?void 0:e.length)>0){const h=(A=o.getRangeAt(0))==null?void 0:A.getClientRects();if(!h||h.length===0)return;const l=h[0],c={text:o.toString(),x:l.x,y:l.y,width:l.width,height:l.height,targetFrameSrc:(r=(n=this.wnd)==null?void 0:n.location)==null?void 0:r.href};this.comms.send("text_selected",c)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!(o!=null&&o.isCollapsed)||!t.isPrimary)return;const a=this.wnd.devicePixelRatio;t.preventDefault(),this.comms.send(t.pointerType==="touch"?"tap":"click",{defaultPrevented:t.defaultPrevented,x:t.clientX*a,y:t.clientY*a,targetFrameSrc:this.wnd.location.href,targetElement:t.target.outerHTML,interactiveElement:(s=tA(t.target))==null?void 0:s.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)}),this.pointerMoved=!1}onPointMove(t){if(t.movementY!==void 0&&t.movementX!==void 0){(Math.abs(t.movementX)>1||Math.abs(t.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onContext(t){this.onPointUp(t),this.pointerMoved=!1}onClick(t){if(t.preventDefault(),!t.isTrusted){const e=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:t.clientX,clientY:t.clientY});Object.defineProperty(e,"target",{writable:!1,value:t.target}),Object.defineProperty(e,"defaultPrevented",{writable:!1,value:t.defaultPrevented}),this.onPointUp(e)}}mount(t,e){return this.wnd=t,this.comms=e,t.document.addEventListener("pointerdown",this.onPointerDown),t.document.addEventListener("pointerup",this.onPointerUp),t.document.addEventListener("contextmenu",this.onContextMenu),t.document.addEventListener("pointermove",this.onPointerMove),t.document.addEventListener("click",this.onClicker),e.log("Peripherals Mounted"),!0}unmount(t,e){return t.document.removeEventListener("pointerdown",this.onPointerDown),t.document.removeEventListener("pointerup",this.onPointerUp),t.document.removeEventListener("contextmenu",this.onContextMenu),t.document.removeEventListener("pointermove",this.onPointerMove),t.document.removeEventListener("click",this.onClicker),e.log("Peripherals Unmounted"),!0}}oA.moduleName="peripherals";const aA=class Me extends St{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(t){var e;(e=this.comms)==null||e.send("error",{message:t.message,filename:t.filename,lineno:t.lineno,colno:t.colno})}unblock(t){var e;for(t._readium_blockEvents=!1;((e=t._readium_blockedEvents)==null?void 0:e.length)>0;){const A=t._readium_blockedEvents.shift();switch(A[0]){case 0:Reflect.apply(A[1],A[2],A[3]);break;case 1:const n=A[1],r=A[2];t.removeEventListener(n.type,t._readium_eventBlocker,!0);const s=new Event(n.type,{bubbles:n.bubbles,cancelable:n.cancelable});r?r.dispatchEvent(s):t.dispatchEvent(s);break}}}onMediaPlayEvent(){var t;this.mediaPlayingCount++,(t=this.comms)==null||t.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){var t;this.mediaPlayingCount>0&&this.mediaPlayingCount--,(t=this.comms)==null||t.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(t){const e=t.document.querySelectorAll("audio,video");for(let A=0;A<e.length;A++)e[A].pause()}mount(t,e){this.comms=e,t.addEventListener("error",this.wndOnErr,!1),Reflect.defineProperty(t.navigator,"epubReadingSystem",{value:{name:"readium-ts-toolkit",version:"2.0.0-beta.3",hasFeature:(n,r="")=>{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 t.document&&t.document.getAnimations().forEach(n=>{n.cancel(),this.allAnimations.add(n)}),e.register("activate",Me.moduleName,(n,r)=>{this.allAnimations.forEach(s=>{s.cancel(),s.play()}),r(!0)}),e.register("unfocus",Me.moduleName,(n,r)=>{this.pauseAllMedia(t),this.allAnimations.forEach(s=>s.pause()),r(!0)});const A=t.document.querySelectorAll("audio,video");for(let n=0;n<A.length;n++){const r=A[n];r.addEventListener("play",this.onMediaPlayEvent,{passive:!0}),r.addEventListener("pause",this.onMediaPauseEvent,{passive:!0})}return e.log("Setup Mounted"),!0}unmount(t,e){return t.removeEventListener("error",this.wndOnErr),t.removeEventListener("play",this.onMediaPlayEvent),t.removeEventListener("pause",this.onMediaPauseEvent),this.allAnimations.forEach(A=>A.cancel()),this.allAnimations.clear(),e.log("Setup Unmounted"),!0}};aA.moduleName="setup";let hA=aA;const lA="readium-viewport",cA=class nt extends hA{onViewportWidthChanged(t){const e=t.target;Vt(e,"--RS__viewportWidth",`${e.innerWidth}px`)}mount(t,e){if(!super.mount(t,e))return!1;const A=t.document.createElement("meta");return A.dataset.readium="true",A.setAttribute("name","viewport"),A.setAttribute("id",lA),A.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"),t.document.head.appendChild(A),t.addEventListener("orientationchange",this.onViewportWidthChanged),t.addEventListener("resize",this.onViewportWidthChanged),this.onViewportWidthChanged({target:t}),e.register("get_properties",nt.moduleName,(n,r)=>{We(t),r(!0)}),e.register("update_properties",nt.moduleName,(n,r)=>{n["--RS__viewportWidth"]=`${t.innerWidth}px`,xi(t,n),r(!0)}),e.register("set_property",nt.moduleName,(n,r)=>{const s=n;Vt(t,s[0],s[1]),r(!0)}),e.register("remove_property",nt.moduleName,(n,r)=>{re(t,n),r(!0)}),e.register("activate",nt.moduleName,(n,r)=>{this.unblock(t),r(!0)}),e.log("ReflowableSetup Mounted"),!0}unmount(t,e){var A;return e.unregisterAll(nt.moduleName),(A=t.document.head.querySelector(`#${lA}`))==null||A.remove(),t.removeEventListener("orientationchange",this.onViewportWidthChanged),e.log("ReflowableSetup Unmounted"),super.unmount(t,e)}};cA.moduleName="reflowable_setup";let Zi=cA;const gA="readium-fixed-style",dA=class et extends hA{mount(t,e){if(!super.mount(t,e))return!1;t.navigator.epubReadingSystem.layoutStyle="paginated";const A=t.document.createElement("style");return A.id=gA,A.dataset.readium="true",A.textContent=`
84
84
  html, body {
85
85
  text-size-adjust: none;
86
86
  -ms-text-size-adjust: none;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/navigator",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.5",
4
4
  "type": "module",
5
5
  "description": "Next generation SDK for publications in Web Apps",
6
6
  "author": "readium",