UNPKG

@readium/navigator

Version:

Next generation SDK for publications in Web Apps

15 lines 295 kB
(function(B,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(B=typeof globalThis<"u"?globalThis:B||self,j(B.navigator={}))})(this,(function(B){"use strict";const j=class yt{constructor(t){if(typeof t=="string"){if(!yt.VALID_MODES.has(t.toLowerCase()))return;this.value=t.toLowerCase()}else{const e=t.filter(i=>yt.VALID_MODES.has(i.toLowerCase()));if(e.length===0)return;this.value=Array.from(new Set(e))}}static deserialize(t){if(!t)return;if(typeof t=="string")return new yt(t);if(!Array.isArray(t))return;const e=t.filter(i=>i?yt.VALID_MODES.has(i.toLowerCase()):!1);if(e.length!==0)return new yt(e)}serialize(){return this.value}};j.VALID_MODES=new Set(["auditory","tactile","textual","visual"]),j.AUDITORY=new j("auditory"),j.TACTILE=new j("tactile"),j.TEXTUAL=new j("textual"),j.VISUAL=new j("visual");const f=class QA{constructor(t){this.value=t}static deserialize(t){if(!(!t||typeof t!="string"))return new QA(t)}serialize(){return this.value}};f.NONE=new f("none"),f.ANNOTATIONS=new f("annotations"),f.ARIA=new f("ARIA"),f.INDEX=new f("index"),f.PAGE_BREAK_MARKERS=new f("pageBreakMarkers"),f.PAGE_NAVIGATION=new f("pageNavigation"),f.PRINT_PAGE_NUMBERS=new f("printPageNumbers"),f.READING_ORDER=new f("readingOrder"),f.STRUCTURAL_NAVIGATION=new f("structuralNavigation"),f.TABLE_OF_CONTENTS=new f("tableOfContents"),f.TAGGED_PDF=new f("taggedPDF"),f.ALTERNATIVE_TEXT=new f("alternativeText"),f.AUDIO_DESCRIPTION=new f("audioDescription"),f.CAPTIONS=new f("captions"),f.CLOSED_CAPTIONS=new f("closedCaptions"),f.DESCRIBED_MATH=new f("describedMath"),f.LONG_DESCRIPTION=new f("longDescription"),f.OPEN_CAPTIONS=new f("openCaptions"),f.SIGN_LANGUAGE=new f("signLanguage"),f.TRANSCRIPT=new f("transcript"),f.DISPLAY_TRANSFORMABILITY=new f("displayTransformability"),f.SYNCHRONIZED_AUDIO_TEXT=new f("synchronizedAudioText"),f.TIMING_CONTROL=new f("timingControl"),f.UNLOCKED=new f("unlocked"),f.CHEM_ML=new f("ChemML"),f.LATEX=new f("latex"),f.LATEX_CHEMISTRY=new f("latex-chemistry"),f.MATH_ML=new f("MathML"),f.MATH_ML_CHEMISTRY=new f("MathML-chemistry"),f.TTS_MARKUP=new f("ttsMarkup"),f.HIGH_CONTRAST_AUDIO=new f("highContrastAudio"),f.HIGH_CONTRAST_DISPLAY=new f("highContrastDisplay"),f.LARGE_PRINT=new f("largePrint"),f.BRAILLE=new f("braille"),f.TACTILE_GRAPHIC=new f("tactileGraphic"),f.TACTILE_OBJECT=new f("tactileObject"),f.FULL_RUBY_ANNOTATIONS=new f("fullRubyAnnotations"),f.HORIZONTAL_WRITING=new f("horizontalWriting"),f.RUBY_ANNOTATIONS=new f("rubyAnnotations"),f.VERTICAL_WRITING=new f("verticalWriting"),f.WITH_ADDITIONAL_WORD_SEGMENTATION=new f("withAdditionalWordSegmentation"),f.WITHOUT_ADDITIONAL_WORD_SEGMENTATION=new f("withoutAdditionalWordSegmentation");let Xe=f;var w=(r=>(r.reflowable="reflowable",r.fixed="fixed",r.scrolled="scrolled",r))(w||{});let jA=class YA{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 YA({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}};var J=(r=>(r.left="left",r.right="right",r.center="center",r))(J||{});let W=class ke{constructor(t){this.otherProperties=t}get page(){return this.otherProperties.page}static deserialize(t){if(t)return new ke(t)}serialize(){return this.otherProperties}add(t){const e=Object.assign({},this.otherProperties);for(const i in t)e[i]=t[i];return new ke(e)}};Object.defineProperty(W.prototype,"encryption",{get:function(){return jA.deserialize(this.otherProperties.encrypted)}});function VA(r){return r&&Array.isArray(r)?r:void 0}function Ze(r){return r&&typeof r=="string"?[r]:VA(r)}function Ke(r){return typeof r=="string"?new Date(r):void 0}function Vt(r){return isNaN(r)?void 0:r}function T(r){return Vt(r)!==void 0&&Math.sign(r)>=0?r:void 0}function vA(r){const t=new Array;return r.forEach(e=>t.push(e)),t}class u{constructor(t){let e,i,A=t.mediaType.replace(/\s/g,"").split(";");const n=A[0].split("/");if(n.length===2){if(e=n[0].toLowerCase().trim(),i=n[1].toLowerCase().trim(),e.length===0||i.length===0)throw new Error("Invalid media type")}else throw new Error("Invalid media type");const o={};for(let g=1;g<A.length;g++){const M=A[g].split("=");if(M.length===2){const l=M[0].toLocaleLowerCase(),p=l==="charset"?M[1].toUpperCase():M[1];o[l]=p}}const s={},a=Object.keys(o);a.sort((g,M)=>g.localeCompare(M)),a.forEach(g=>s[g]=o[g]);let h="";for(const g in s){const M=s[g];h+=`;${g}=${M}`}const c=`${e}/${i}${h}`,d=s.encoding;this.string=c,this.type=e,this.subtype=i,this.parameters=s,this.encoding=d,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 i=new Set(Object.entries(this.parameters).map(([n,o])=>`${n}=${o}`)),A=new Set(Object.entries(e.parameters).map(([n,o])=>`${n}=${o}`));for(const n of Array.from(i.values()))if(!A.has(n))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"})}}let qe=class{constructor(t){this.uri=t,this.parameters=this.getParameters(t)}getParameters(t){const e=/\{\??([^}]+)\}/g,i=t.match(e);return i?new Set(i.join(",").replace(e,"$1").split(",").map(A=>A.trim())):new Set}expand(t){const e=A=>A.split(",").map(n=>{const o=t[n];return o?encodeURIComponent(o):""}).join(","),i=A=>"?"+A.split(",").map(n=>{const o=n.split("=")[0],s=t[o];return s?`${o}=${encodeURIComponent(s)}`:""}).join("&");return this.uri.replace(/\{(\??)([^}]+)\}/g,(...A)=>A[1]?i(A[2]):e(A[2]))}},V=class NA{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=Vt(t.progression),i=Vt(t.totalProgression),A=Vt(t.position),n=new Map,o=new Set(["fragment","fragments","progression","totalProgression","position"]);return Object.entries(t).forEach(([s,a])=>{o.has(s)||n.set(s,a)}),new NA({fragments:Ze(t.fragments||t.fragment),progression:e!==void 0&&e>=0&&e<=1?e:void 0,totalProgression:i!==void 0&&i>=0&&i<=1?i:void 0,position:A!==void 0&&A>0?A:void 0,otherLocations:n.size===0?void 0:n})}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,i)=>t[i]=e),t}},DA=class xA{constructor(t){this.after=t.after,this.before=t.before,this.highlight=t.highlight}static deserialize(t){if(t)return new xA({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}},at=class Je{constructor(t){this.href=t.href,this.type=t.type,this.title=t.title,this.locations=t.locations?t.locations:new V({}),this.text=t.text}static deserialize(t){if(t&&t.href&&t.type)return new Je({href:t.href,type:t.type,title:t.title,locations:V.deserialize(t.locations),text:DA.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 Je({href:this.href,type:this.type,title:this.title,text:this.text,locations:new V({...this.locations,...t})})}};class D{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.size=t.size,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||typeof t.href!="string"))return new D({href:t.href,templated:t.templated,type:t.type,title:t.title,rels:t.rel?Array.isArray(t.rel)?new Set(t.rel):new Set([t.rel]):void 0,properties:W.deserialize(t.properties),height:T(t.height),width:T(t.width),size:T(t.size),duration:T(t.duration),bitrate:T(t.bitrate),languages:Ze(t.language),alternates:_e.deserialize(t.alternate),children:_e.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=vA(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.size!==void 0&&(t.size=this.size),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 i=t||"/";return i.startsWith("/")&&(i="file://"+i),new URL(e,i).href.replace(/^(file:\/\/)/,"")}get templateParameters(){return this.templated?new qe(this.href).parameters:new Set}expandTemplate(t){return new D({href:new qe(this.href).expand(t),templated:!1})}addProperties(t){const e=D.deserialize(this.serialize());return e.properties=e.properties?e.properties?.add(t):new W(t),e}get locator(){let t=this.href.split("#");return new at({href:t.length>0&&t[0]!==void 0?t[0]:this.href,type:this.type??"",title:this.title,locations:new V({fragments:t.length>1&&t[1]!==void 0?[t[1]]:[]})})}}let _e=class TA{constructor(t){this.items=t}static deserialize(t){if(t&&Array.isArray(t))return new TA(t.map(e=>D.deserialize(e)).filter(e=>e!==void 0))}serialize(){return this.items.map(t=>t.serialize())}findWithRel(t){const e=i=>i.rels&&i.rels.has(t);return this.items.find(e)}filterByRel(t){const e=i=>i.rels&&i.rels.has(t);return this.items.filter(e)}findWithHref(t){const e=i=>i.href===t;return this.items.find(e)}findIndexWithHref(t){const e=i=>i.href===t;return this.items.findIndex(e)}findWithMediaType(t){const e=i=>i.mediaType.matches(t);return this.items.find(e)}filterByMediaType(t){const e=i=>i.mediaType.matches(t);return this.items.filter(e)}filterByMediaTypes(t){const e=i=>{for(const A of t)if(i.mediaType.matches(A))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 i of t)return e.mediaType.matches(i);return!1}):this.items.length>0&&this.items.every(e=>e.mediaType.matches(t))}filterLinksHasType(){return this.items.filter(t=>t.type)}};var $e=(r=>(r.EPUB="https://readium.org/webpub-manifest/profiles/epub",r.AUDIOBOOK="https://readium.org/webpub-manifest/profiles/audiobook",r.DIVINA="https://readium.org/webpub-manifest/profiles/divina",r.PDF="https://readium.org/webpub-manifest/profiles/pdf",r))($e||{}),x=(r=>(r.ltr="ltr",r.rtl="rtl",r))(x||{});W.prototype.getContains=function(){return new Set(this.otherProperties.contains||[])};let ti=class PA{constructor(t){this.cssSelector=t.cssSelector,this.textNodeIndex=t.textNodeIndex,this.charOffset=t.charOffset}static deserialize(t){if(!(t&&t.cssSelector))return;let e=T(t.textNodeIndex);if(e===void 0)return;let i=T(t.charOffset);return i===void 0&&(i=T(t.offset)),new PA({cssSelector:t.cssSelector,textNodeIndex:e,charOffset:i})}serialize(){const t={cssSelector:this.cssSelector,textNodeIndex:this.textNodeIndex};return this.charOffset!==void 0&&(t.charOffset=this.charOffset),t}};class ne{constructor(t){this.start=t.start,this.end=t.end}static deserialize(t){if(!t)return;let e=ti.deserialize(t.start);if(e)return new ne({start:e,end:ti.deserialize(t.end)})}serialize(){const t={start:this.start.serialize()};return this.end&&(t.end=this.end.serialize()),t}}V.prototype.getCssSelector=function(){return this.otherLocations?.get("cssSelector")},V.prototype.getPartialCfi=function(){return this.otherLocations?.get("partialCfi")},V.prototype.getDomRange=function(){return ne.deserialize(this.otherLocations?.get("domRange"))},V.prototype.fragmentParameters=function(){return new Map(this.fragments.map(r=>r.startsWith("#")?r.slice(1):r).join("&").split("&").filter(r=>!r.startsWith("#")).map(r=>r.split("=")).filter(r=>r.length===2).map(r=>[r[0].trim().toLowerCase(),r[1].trim()]))},V.prototype.htmlId=function(){if(!this.fragments.length)return;let r=this.fragments.find(t=>t.length&&!t.includes("="));if(!r){const t=this.fragmentParameters();t.has("id")?r=t.get("id"):t.has("name")&&(r=t.get("name"))}return r?.startsWith("#")?r.slice(1):r},V.prototype.page=function(){const r=parseInt(this.fragmentParameters().get("page"));if(!isNaN(r)&&r>=0)return r},V.prototype.time=function(){const r=parseInt(this.fragmentParameters().get("t"));if(!isNaN(r))return r},V.prototype.space=function(){const r=this.fragmentParameters();if(!r.has("xywh"))return;const t=r.get("xywh").split(",").map(e=>parseInt(e));if(t.length===4&&!t.some(isNaN))return t};let HA=class bA{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 i=T(t.value);if(i!==void 0)return new bA({currency:e,value:i})}serialize(){return{currency:this.currency,value:this.value}}},GA=class Ae{constructor(t){this.type=t.type,this.children=t.children}static deserialize(t){if(t&&t.type)return new Ae({type:t.type,children:Ae.deserializeArray(t.children)})}static deserializeArray(t){if(Array.isArray(t))return t.map(e=>Ae.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 re{constructor(t){this.total=t.total,this.position=t.position}static deserialize(t){if(t)return new re({total:T(t.total),position:T(t.position)})}serialize(){const t={};return this.total!==void 0&&(t.total=this.total),this.position!==void 0&&(t.position=this.position),t}}class oe{constructor(t){this.total=t.total,this.available=t.available}static deserialize(t){if(t)return new oe({total:T(t.total),available:T(t.available)})}serialize(){const t={};return this.total!==void 0&&(t.total=this.total),this.available!==void 0&&(t.available=this.available),t}}class se{constructor(t){this.state=t.state,this.since=t.since,this.until=t.until}static deserialize(t){if(t&&t.state)return new se({state:t.state,since:Ke(t.since),until:Ke(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}}W.prototype.getNumberOfItems=function(){return T(this.otherProperties.numberOfItems)},W.prototype.getPrice=function(){return HA.deserialize(this.otherProperties.price)},W.prototype.getIndirectAcquisitions=function(){const r=this.otherProperties.indirectAcquisition;if(r&&Array.isArray(r))return r.map(t=>GA.deserialize(t)).filter(t=>t!==void 0)},W.prototype.getHolds=function(){return re.deserialize(this.otherProperties.holds)},W.prototype.getCopies=function(){return oe.deserialize(this.otherProperties.copies)},W.prototype.getAvailability=function(){return se.deserialize(this.otherProperties.availability)},W.prototype.getAuthenticate=function(){return D.deserialize(this.otherProperties.authenticate)};const kA="CssSelectorGenerator";function ei(r="unknown problem",...t){console.warn(`${kA}: ${r}`,...t)}function JA(r){return r instanceof RegExp}function WA(r){return r.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".+")}function OA(r){const t=r.map(e=>{if(JA(e))return i=>e.test(i);if(typeof e=="function")return i=>{const A=e(i);return typeof A!="boolean"?(ei("pattern matcher function invalid","Provided pattern matching function does not return boolean. It's result will be ignored.",e),!1):A};if(typeof e=="string"){const i=new RegExp("^"+WA(e)+"$");return A=>i.test(A)}return ei("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(i=>i(e))}OA(["class","id","ng-*"]);class ii{}class ae extends ii{goLeft(t=!1,e){this.readingProgression===x.ltr?this.goBackward(t,e):this.readingProgression===x.rtl&&this.goForward(t,e)}goRight(t=!1,e){this.readingProgression===x.ltr?this.goForward(t,e):this.readingProgression===x.rtl&&this.goBackward(t,e)}}const LA=':root[style*=--USER__textAlign]{text-align:var(--USER__textAlign)}:root[style*=--USER__textAlign] body,:root[style*=--USER__textAlign] p:not(blockquote p,figcaption p,header p,hgroup p,:root[style*=readium-experimentalHeaderFiltering-on] p[class*=title],:root[style*=readium-experimentalHeaderFiltering-on] div:has(+*)>h1+p,:root[style*=readium-experimentalHeaderFiltering-on] div:has(+*)>p:has(+h1)),:root[style*=--USER__textAlign] li,:root[style*=--USER__textAlign] dd{text-align:var(--USER__textAlign)!important;-moz-text-align-last:auto!important;-epub-text-align-last:auto!important;text-align-last:auto!important}:root[style*=--USER__bodyHyphens]{-webkit-hyphens:var(--USER__bodyHyphens)!important;-moz-hyphens:var(--USER__bodyHyphens)!important;-ms-hyphens:var(--USER__bodyHyphens)!important;-epub-hyphens:var(--USER__bodyHyphens)!important;hyphens:var(--USER__bodyHyphens)!important}:root[style*=--USER__bodyHyphens] body,:root[style*=--USER__bodyHyphens] p,:root[style*=--USER__bodyHyphens] li,:root[style*=--USER__bodyHyphens] div,:root[style*=--USER__bodyHyphens] dd{-webkit-hyphens:inherit;-moz-hyphens:inherit;-ms-hyphens:inherit;-epub-hyphens:inherit;hyphens:inherit}:root[style*=--USER__fontFamily]{font-family:var(--USER__fontFamily)!important}:root[style*=--USER__fontFamily] *{font-family:revert!important}:root[style*=AccessibleDfA]{font-family:AccessibleDfA,Verdana,Tahoma,Trebuchet MS,sans-serif!important}:root[style*="IA Writer Duospace"]{font-family:IA Writer Duospace,Menlo,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier,monospace!important}:root[style*=AccessibleDfA],:root[style*="IA Writer Duospace"],:root[style*=readium-a11y-on]{font-style:normal!important;font-weight:400!important}:root[style*=AccessibleDfA] body *:not(code):not(var):not(kbd):not(samp),:root[style*="IA Writer Duospace"] body *:not(code):not(var):not(kbd):not(samp),:root[style*=readium-a11y-on] body *:not(code):not(var):not(kbd):not(samp){font-family:inherit!important;font-style:inherit!important;font-weight:inherit!important}:root[style*=AccessibleDfA] body *:not(a),:root[style*="IA Writer Duospace"] body *:not(a),:root[style*=readium-a11y-on] body *:not(a){text-decoration:none!important}:root[style*=AccessibleDfA] body *,:root[style*="IA Writer Duospace"] body *,:root[style*=readium-a11y-on] body *{font-variant-caps:normal!important;font-variant-numeric:normal!important;font-variant-position:normal!important}:root[style*=AccessibleDfA] sup,:root[style*="IA Writer Duospace"] sup,:root[style*=readium-a11y-on] sup,:root[style*=AccessibleDfA] sub,:root[style*="IA Writer Duospace"] sub,:root[style*=readium-a11y-on] sub{font-size:1rem!important;vertical-align:baseline!important}:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] body{zoom:var(--USER__zoom)!important}:root[style*=readium-iOSPatch-on][style*=--USER__zoom] body{-webkit-text-size-adjust:var(--USER__zoom)!important}@supports selector(figure:has(> img)){:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>img),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>video),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>svg),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>canvas),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>iframe),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>audio),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>img:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>video:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>svg:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>canvas:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>iframe:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>audio:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] table{zoom:calc(100% / var(--USER__zoom))!important}:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figcaption,:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] caption,:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] td,:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] th{zoom:var(--USER__zoom)!important}}:root[style*=--USER__lineHeight]{line-height:var(--USER__lineHeight)!important}:root[style*=--USER__lineHeight] body,:root[style*=--USER__lineHeight] p,:root[style*=--USER__lineHeight] li,:root[style*=--USER__lineHeight] div{line-height:inherit}:root[style*=--USER__paraSpacing] p{margin-top:var(--USER__paraSpacing)!important;margin-bottom:var(--USER__paraSpacing)!important}:root[style*=--USER__paraIndent] p:not(blockquote p,figcaption p,header p,hgroup p,:root[style*=readium-experimentalHeaderFiltering-on] p[class*=title],:root[style*=readium-experimentalHeaderFiltering-on] div:has(+*)>h1+p,:root[style*=readium-experimentalHeaderFiltering-on] div:has(+*)>p:has(+h1)){text-indent:var(--USER__paraIndent)!important}:root[style*=--USER__paraIndent] p *,:root[style*=--USER__paraIndent] p:first-letter{text-indent:0!important}:root[style*=--USER__wordSpacing] h1,:root[style*=--USER__wordSpacing] h2,:root[style*=--USER__wordSpacing] h3,:root[style*=--USER__wordSpacing] h4,:root[style*=--USER__wordSpacing] h5,:root[style*=--USER__wordSpacing] h6,:root[style*=--USER__wordSpacing] p,:root[style*=--USER__wordSpacing] li,:root[style*=--USER__wordSpacing] div,:root[style*=--USER__wordSpacing] dt,:root[style*=--USER__wordSpacing] dd{word-spacing:var(--USER__wordSpacing)}:root[style*=--USER__letterSpacing] h1,:root[style*=--USER__letterSpacing] h2,:root[style*=--USER__letterSpacing] h3,:root[style*=--USER__letterSpacing] h4,:root[style*=--USER__letterSpacing] h5,:root[style*=--USER__letterSpacing] h6,:root[style*=--USER__letterSpacing] p,:root[style*=--USER__letterSpacing] li,:root[style*=--USER__letterSpacing] div,:root[style*=--USER__letterSpacing] dt,:root[style*=--USER__letterSpacing] dd{letter-spacing:var(--USER__letterSpacing);font-variant:none}:root[style*=--USER__fontWeight] body{font-weight:var(--USER__fontWeight)!important}:root[style*=--USER__fontWeight] b,:root[style*=--USER__fontWeight] strong{font-weight:bolder}:root[style*=--USER__fontWidth] body{font-stretch:var(--USER__fontWidth)!important}:root[style*=--USER__fontOpticalSizing] body{font-optical-sizing:var(--USER__fontOpticalSizing)!important}:root[style*=readium-noRuby-on] body rt,:root[style*=readium-noRuby-on] body rp{display:none}:root[style*=--USER__ligatures]{font-variant-ligatures:var(--USER__ligatures)!important}:root[style*=--USER__ligatures] *{font-variant-ligatures:inherit!important}:root[style*=readium-iPadOSPatch-on] body{-webkit-text-size-adjust:none}:root[style*=readium-iPadOSPatch-on] p,:root[style*=readium-iPadOSPatch-on] h1,:root[style*=readium-iPadOSPatch-on] h2,:root[style*=readium-iPadOSPatch-on] h3,:root[style*=readium-iPadOSPatch-on] h4,:root[style*=readium-iPadOSPatch-on] h5,:root[style*=readium-iPadOSPatch-on] h6,:root[style*=readium-iPadOSPatch-on] li,:root[style*=readium-iPadOSPatch-on] th,:root[style*=readium-iPadOSPatch-on] td,:root[style*=readium-iPadOSPatch-on] dt,:root[style*=readium-iPadOSPatch-on] dd,:root[style*=readium-iPadOSPatch-on] pre,:root[style*=readium-iPadOSPatch-on] address,:root[style*=readium-iPadOSPatch-on] details,:root[style*=readium-iPadOSPatch-on] summary,:root[style*=readium-iPadOSPatch-on] figcaption,:root[style*=readium-iPadOSPatch-on] div:not(:has(p,h1,h2,h3,h4,h5,h6,li,th,td,dt,dd,pre,address,aside,details,figcaption,summary)),:root[style*=readium-iPadOSPatch-on] aside:not(:has(p,h1,h2,h3,h4,h5,h6,li,th,td,dt,dd,pre,address,aside,details,figcaption,summary)){-webkit-text-zoom:reset}:root[style*=readium-iPadOSPatch-on] abbr,:root[style*=readium-iPadOSPatch-on] b,:root[style*=readium-iPadOSPatch-on] bdi,:root[style*=readium-iPadOSPatch-on] bdo,:root[style*=readium-iPadOSPatch-on] cite,:root[style*=readium-iPadOSPatch-on] code,:root[style*=readium-iPadOSPatch-on] dfn,:root[style*=readium-iPadOSPatch-on] em,:root[style*=readium-iPadOSPatch-on] i,:root[style*=readium-iPadOSPatch-on] kbd,:root[style*=readium-iPadOSPatch-on] mark,:root[style*=readium-iPadOSPatch-on] q,:root[style*=readium-iPadOSPatch-on] rp,:root[style*=readium-iPadOSPatch-on] rt,:root[style*=readium-iPadOSPatch-on] ruby,:root[style*=readium-iPadOSPatch-on] s,:root[style*=readium-iPadOSPatch-on] samp,:root[style*=readium-iPadOSPatch-on] small,:root[style*=readium-iPadOSPatch-on] span,:root[style*=readium-iPadOSPatch-on] strong,:root[style*=readium-iPadOSPatch-on] sub,:root[style*=readium-iPadOSPatch-on] sup,:root[style*=readium-iPadOSPatch-on] time,:root[style*=readium-iPadOSPatch-on] u,:root[style*=readium-iPadOSPatch-on] var{-webkit-text-zoom:normal}:root[style*=readium-iPadOSPatch-on] p:not(:has(b,cite,em,i,q,s,small,span,strong)):first-line{-webkit-text-zoom:normal}',lt=(r,t)=>URL.createObjectURL(new Blob([r],{type:t})),Ai=r=>r.replace(/\/\/.*/g,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/\n/g,"").replace(/\s+/g," "),XA=r=>r.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,"").replace(/ {2,}/g," ").replace(/url\((?!(https?:)?\/\/)("?)\/([^\)]+)/g,`url($2${window.location.origin}/$3`),le=(r,t)=>{const e=r.createElement("script");return e.dataset.readium="true",e.src=t.startsWith("blob:")?t:lt(t,"text/javascript"),e},ZA=(r,t)=>{const e=r.createElement("link");return e.dataset.readium="true",e.rel="stylesheet",e.type="text/css",e.href=t.startsWith("blob:")?t:lt(t,"text/css"),e},he=new Map,vt=(r,t)=>{if(he.has(r))return he.get(r);const e=t();return he.set(r,e),e},KA=r=>le(r,vt("css-selector-generator",()=>lt('!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports._readium_cssSelectorGenerator=e():t._readium_cssSelectorGenerator=e()}(self,(()=>(()=>{"use strict";var t,e,n={d:(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};function r(t){return t&&t instanceof Element}function i(t="unknown problem",...e){console.warn(`CssSelectorGenerator: ${t}`,...e)}n.r(o),n.d(o,{default:()=>z,getCssSelector:()=>U}),function(t){t.NONE="none",t.DESCENDANT="descendant",t.CHILD="child"}(t||(t={})),function(t){t.id="id",t.class="class",t.tag="tag",t.attribute="attribute",t.nthchild="nthchild",t.nthoftype="nthoftype"}(e||(e={}));const c={selectors:[e.id,e.class,e.tag,e.attribute],includeTag:!1,whitelist:[],blacklist:[],combineWithinSelector:!0,combineBetweenSelectors:!0,root:null,maxCombinations:Number.POSITIVE_INFINITY,maxCandidates:Number.POSITIVE_INFINITY};function u(t){return t instanceof RegExp}function s(t){return["string","function"].includes(typeof t)||u(t)}function l(t){return Array.isArray(t)?t.filter(s):[]}function a(t){const e=[Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE,Node.ELEMENT_NODE];return function(t){return t instanceof Node}(t)&&e.includes(t.nodeType)}function f(t,e){if(a(t))return t.contains(e)||i("element root mismatch","Provided root does not contain the element. This will most likely result in producing a fallback selector using element\'s real root node. If you plan to use the selector using provided root (e.g. `root.querySelector`), it will nto work as intended."),t;const n=e.getRootNode({composed:!1});return a(n)?(n!==document&&i("shadow root inferred","You did not provide a root and the element is a child of Shadow DOM. This will produce a selector using ShadowRoot as a root. If you plan to use the selector using document as a root (e.g. `document.querySelector`), it will not work as intended."),n):e.ownerDocument.querySelector(":root")}function d(t){return"number"==typeof t?t:Number.POSITIVE_INFINITY}function m(t=[]){const[e=[],...n]=t;return 0===n.length?e:n.reduce(((t,e)=>t.filter((t=>e.includes(t)))),e)}function p(t){return[].concat(...t)}function h(t){const e=t.map((t=>{if(u(t))return e=>t.test(e);if("function"==typeof t)return e=>{const n=t(e);return"boolean"!=typeof n?(i("pattern matcher function invalid","Provided pattern matching function does not return boolean. It\'s result will be ignored.",t),!1):n};if("string"==typeof t){const e=new RegExp("^"+t.replace(/[|\\\\{}()[\\]^$+?.]/g,"\\\\$&").replace(/\\*/g,".+")+"$");return t=>e.test(t)}return i("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",t),()=>!1}));return t=>e.some((e=>e(t)))}function g(t,e,n){const o=Array.from(f(n,t[0]).querySelectorAll(e));return o.length===t.length&&t.every((t=>o.includes(t)))}function y(t,e){e=null!=e?e:function(t){return t.ownerDocument.querySelector(":root")}(t);const n=[];let o=t;for(;r(o)&&o!==e;)n.push(o),o=o.parentElement;return n}function b(t,e){return m(t.map((t=>y(t,e))))}const N={[t.NONE]:{type:t.NONE,value:""},[t.DESCENDANT]:{type:t.DESCENDANT,value:" > "},[t.CHILD]:{type:t.CHILD,value:" "}},S=new RegExp(["^$","\\\\s"].join("|")),E=new RegExp(["^$"].join("|")),w=[e.nthoftype,e.tag,e.id,e.class,e.attribute,e.nthchild],v=h(["class","id","ng-*"]);function C({nodeName:t}){return`[${t}]`}function O({nodeName:t,nodeValue:e}){return`[${t}=\'${L(e)}\']`}function T(t){const e=Array.from(t.attributes).filter((e=>function({nodeName:t},e){const n=e.tagName.toLowerCase();return!(["input","option"].includes(n)&&"value"===t||v(t))}(e,t)));return[...e.map(C),...e.map(O)]}function I(t){return(t.getAttribute("class")||"").trim().split(/\\s+/).filter((t=>!E.test(t))).map((t=>`.${L(t)}`))}function x(t){const e=t.getAttribute("id")||"",n=`#${L(e)}`,o=t.getRootNode({composed:!1});return!S.test(e)&&g([t],n,o)?[n]:[]}function j(t){const e=t.parentNode;if(e){const n=Array.from(e.childNodes).filter(r).indexOf(t);if(n>-1)return[`:nth-child(${n+1})`]}return[]}function A(t){return[L(t.tagName.toLowerCase())]}function D(t){const e=[...new Set(p(t.map(A)))];return 0===e.length||e.length>1?[]:[e[0]]}function $(t){const e=D([t])[0],n=t.parentElement;if(n){const o=Array.from(n.children).filter((t=>t.tagName.toLowerCase()===e)),r=o.indexOf(t);if(r>-1)return[`${e}:nth-of-type(${r+1})`]}return[]}function R(t=[],{maxResults:e=Number.POSITIVE_INFINITY}={}){const n=[];let o=0,r=k(1);for(;r.length<=t.length&&o<e;)o+=1,n.push(r.map((e=>t[e]))),r=P(r,t.length-1);return n}function P(t=[],e=0){const n=t.length;if(0===n)return[];const o=[...t];o[n-1]+=1;for(let t=n-1;t>=0;t--)if(o[t]>e){if(0===t)return k(n+1);o[t-1]++,o[t]=o[t-1]+1}return o[n-1]>e?k(n+1):o}function k(t=1){return Array.from(Array(t).keys())}const _=":".charCodeAt(0).toString(16).toUpperCase(),M=/[ !"#$%&\'()\\[\\]{|}<>*+,./;=?@^`~\\\\]/;function L(t=""){var e,n;return null!==(n=null===(e=null===CSS||void 0===CSS?void 0:CSS.escape)||void 0===e?void 0:e.call(CSS,t))&&void 0!==n?n:function(t=""){return t.split("").map((t=>":"===t?`\\\\${_} `:M.test(t)?`\\\\${t}`:escape(t).replace(/%/g,"\\\\"))).join("")}(t)}const q={tag:D,id:function(t){return 0===t.length||t.length>1?[]:x(t[0])},class:function(t){return m(t.map(I))},attribute:function(t){return m(t.map(T))},nthchild:function(t){return m(t.map(j))},nthoftype:function(t){return m(t.map($))}},F={tag:A,id:x,class:I,attribute:T,nthchild:j,nthoftype:$};function V(t){return t.includes(e.tag)||t.includes(e.nthoftype)?[...t]:[...t,e.tag]}function Y(t={}){const n=[...w];return t[e.tag]&&t[e.nthoftype]&&n.splice(n.indexOf(e.tag),1),n.map((e=>{return(o=t)[n=e]?o[n].join(""):"";var n,o})).join("")}function B(t,e,n="",o){const r=function(t,e){return""===e?t:function(t,e){return[...t.map((t=>e+" "+t)),...t.map((t=>e+" > "+t))]}(t,e)}(function(t,e,n){const o=function(t,e){const{blacklist:n,whitelist:o,combineWithinSelector:r,maxCombinations:i}=e,c=h(n),u=h(o);return function(t){const{selectors:e,includeTag:n}=t,o=[].concat(e);return n&&!o.includes("tag")&&o.push("tag"),o}(e).reduce(((e,n)=>{const o=function(t,e){var n;return(null!==(n=q[e])&&void 0!==n?n:()=>[])(t)}(t,n),s=function(t=[],e,n){return t.filter((t=>n(t)||!e(t)))}(o,c,u),l=function(t=[],e){return t.sort(((t,n)=>{const o=e(t),r=e(n);return o&&!r?-1:!o&&r?1:0}))}(s,u);return e[n]=r?R(l,{maxResults:i}):l.map((t=>[t])),e}),{})}(t,n),r=function(t,e){return function(t){const{selectors:e,combineBetweenSelectors:n,includeTag:o,maxCandidates:r}=t,i=n?R(e,{maxResults:r}):e.map((t=>[t]));return o?i.map(V):i}(e).map((e=>function(t,e){const n={};return t.forEach((t=>{const o=e[t];o.length>0&&(n[t]=o)})),function(t={}){let e=[];return Object.entries(t).forEach((([t,n])=>{e=n.flatMap((n=>0===e.length?[{[t]:n}]:e.map((e=>Object.assign(Object.assign({},e),{[t]:n})))))})),e}(n).map(Y)}(e,t))).filter((t=>t.length>0))}(o,n),i=p(r);return[...new Set(i)]}(t,o.root,o),n);for(const e of r)if(g(t,e,o.root))return e;return null}function G(t){return{value:t,include:!1}}function W({selectors:t,operator:n}){let o=[...w];t[e.tag]&&t[e.nthoftype]&&(o=o.filter((t=>t!==e.tag)));let r="";return o.forEach((e=>{(t[e]||[]).forEach((({value:t,include:e})=>{e&&(r+=t)}))})),n.value+r}function H(n){return[":root",...y(n).reverse().map((n=>{const o=function(e,n,o=t.NONE){const r={};return n.forEach((t=>{Reflect.set(r,t,function(t,e){return F[e](t)}(e,t).map(G))})),{element:e,operator:N[o],selectors:r}}(n,[e.nthchild],t.DESCENDANT);return o.selectors.nthchild.forEach((t=>{t.include=!0})),o})).map(W)].join("")}function U(t,n={}){const o=function(t){const e=(Array.isArray(t)?t:[t]).filter(r);return[...new Set(e)]}(t),i=function(t,n={}){const o=Object.assign(Object.assign({},c),n);return{selectors:(r=o.selectors,Array.isArray(r)?r.filter((t=>{return n=e,o=t,Object.values(n).includes(o);var n,o})):[]),whitelist:l(o.whitelist),blacklist:l(o.blacklist),root:f(o.root,t),combineWithinSelector:!!o.combineWithinSelector,combineBetweenSelectors:!!o.combineBetweenSelectors,includeTag:!!o.includeTag,maxCombinations:d(o.maxCombinations),maxCandidates:d(o.maxCandidates)};var r}(o[0],n);let u="",s=i.root;function a(){return function(t,e,n="",o){if(0===t.length)return null;const r=[t.length>1?t:[],...b(t,e).map((t=>[t]))];for(const t of r){const e=B(t,0,n,o);if(e)return{foundElements:t,selector:e}}return null}(o,s,u,i)}let m=a();for(;m;){const{foundElements:t,selector:e}=m;if(g(o,e,i.root))return e;s=t[0],u=e,m=a()}return o.length>1?o.map((t=>U(t,i))).join(", "):function(t){return t.map(H).join(", ")}(o)}const z=U;return o})()));',"text/javascript"))),qA=` window._readium_blockedEvents = []; window._readium_blockEvents = false; // WebPub doesn't need event blocking window._readium_eventBlocker = null; `,_A=r=>le(r,vt("webpub-js-before",()=>lt(Ai(qA),"text/javascript"))),$A=r=>le(r,vt("webpub-js-after",()=>lt(Ai(` if(window.onload) window.onload = new Proxy(window.onload, { apply: function(target, receiver, args) { if(!window._readium_blockEvents) { Reflect.apply(target, receiver, args); return; } _readium_blockedEvents.push([0, target, receiver, args]); } });`),"text/javascript")));class ni{constructor(t,e,i,A){this.pub=t,this.item=i,this.burl=i.toURL(e)||"",this.cssProperties=A}async build(){if(!this.item.mediaType.isHTML)throw new Error(`Unsupported media type for WebPub: ${this.item.mediaType.string}`);return await this.buildHtmlFrame()}async buildHtmlFrame(){const t=await this.pub.get(this.item).readAsString();if(!t)throw new Error(`Failed reading item ${this.item.href}`);const e=new DOMParser().parseFromString(t,this.item.mediaType.string),i=e.querySelector("parsererror");if(i){const A=i.querySelector("div");throw new Error(`Failed parsing item ${this.item.href}: ${A?.textContent||i.textContent}`)}return this.finalizeDOM(e,this.burl,this.item.mediaType,t,this.cssProperties)}hasExecutable(t){return!!t.querySelector("script")||!!t.querySelector("body[onload]:not(body[onload=''])")}setProperties(t,e){for(const i in t){const A=t[i];A&&e.documentElement.style.setProperty(i,A)}}finalizeDOM(t,e,i,A,n){if(!t)return"";if(t.head.appendChild(ZA(t,vt("ReadiumCSS-webpub",()=>lt(XA(LA),"text/css")))),n&&this.setProperties(n,t),t.body.querySelectorAll("img").forEach(a=>{a.setAttribute("fetchpriority","high")}),e!==void 0){const a=t.createElement("base");a.href=e,a.dataset.readium="true",t.head.firstChild.before(a)}const o=this.hasExecutable(t);o&&t.head.firstChild.before(_A(t)),t.head.firstChild.before(KA(t)),o&&t.head.appendChild($A(t));let s;return i.string==="application/xhtml+xml"?s=new XMLSerializer().serializeToString(t):s=this.serializeAsHTML(t,A||""),URL.createObjectURL(new Blob([s],{type:i.isHTML?i.string:"application/xhtml+xml"}))}serializeAsHTML(t,e){const i=e.match(/<!DOCTYPE[^>]*>/i),A=i?i[0]+` `:"";let o=t.documentElement.outerHTML;return A+o}}const tn=Math.pow(2,32),ri=()=>Math.round(Math.random()*tn).toString(36),ce=()=>`${Math.round(performance.now())}-${ri()}-${ri()}`,ht=1;class en{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!==ht){e._readium>ht?this.send("error",`received comms version ${e._readium} higher than ${ht}`):this.send("error",`received comms version ${e._readium} lower than ${ht}`),this.destination=null,this.origin="",this.channelId="";return}this.send("_pong",void 0),this.preLog.forEach(i=>this.send("log",i)),this.preLog=[]}return}else if(this.channelId){if(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(i=>i.cb(t.data,A=>{this.send("_ack",A,t.id)}))}register(t,e,i){Array.isArray(t)||(t=[t]),t.forEach(A=>{const n=this.registrar.get(A);if(n&&n.length>=0){if(n.find(o=>o.module===e))throw new Error(`Trying to register another callback for combination of event ${A} and module ${e}`);n.push({cb:i,module:e}),this.registrar.set(A,n)}else this.registrar.set(A,[{cb:i,module:e}])})}unregister(t,e){Array.isArray(t)||(t=[t]),t.forEach(i=>{const A=this.registrar.get(i);!A||A.length===0||A.splice(A.findIndex(n=>n.module===e),1)})}unregisterAll(t){this.registrar.forEach((e,i)=>this.registrar.set(i,e.filter(A=>A.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,i=void 0,A=[]){if(!this.destination)throw Error("Attempted to send comms message before destination has been initialized");const n={_readium:ht,_channel:this.channelId,id:i??ce(),key:t,data:e};try{this.destination.postMessage(n,{targetOrigin:this.origin,transfer:A})}catch(o){if(A.length>0)throw o;this.destination.postMessage(n,this.origin,A)}}}const Z=class It{constructor(t){if(typeof t=="string"){if(!It.VALID_MODES.has(t.toLowerCase()))return;this.value=t.toLowerCase()}else{const e=t.filter(i=>It.VALID_MODES.has(i.toLowerCase()));if(e.length===0)return;this.value=Array.from(new Set(e))}}static deserialize(t){if(!t)return;if(typeof t=="string")return new It(t);if(!Array.isArray(t))return;const e=t.filter(i=>i?It.VALID_MODES.has(i.toLowerCase()):!1);if(e.length!==0)return new It(e)}serialize(){return this.value}};Z.VALID_MODES=new Set(["auditory","tactile","textual","visual"]),Z.AUDITORY=new Z("auditory"),Z.TACTILE=new Z("tactile"),Z.TEXTUAL=new Z("textual"),Z.VISUAL=new Z("visual");class de{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 de({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 P{constructor(t){this.otherProperties=t}get page(){return this.otherProperties.page}static deserialize(t){if(t)return new P(t)}serialize(){return this.otherProperties}add(t){const e=Object.assign({},this.otherProperties);for(