@readium/shared 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.MD +8 -7
  2. package/dist/_virtual/preload-helper.js +1 -0
  3. package/dist/fetcher/Fetcher.js +1 -0
  4. package/dist/fetcher/HttpFetcher.js +1 -0
  5. package/dist/fetcher/Resource.js +1 -0
  6. package/dist/index.js +1 -4972
  7. package/dist/locales/publication-metadata/ar.json.js +1 -0
  8. package/dist/locales/publication-metadata/da.json.js +1 -0
  9. package/dist/locales/publication-metadata/el.json.js +1 -0
  10. package/dist/locales/publication-metadata/en.json.js +1 -0
  11. package/dist/locales/publication-metadata/es.json.js +1 -0
  12. package/dist/locales/publication-metadata/et.json.js +1 -0
  13. package/dist/locales/publication-metadata/fi.json.js +1 -0
  14. package/dist/locales/publication-metadata/fr.json.js +1 -0
  15. package/dist/locales/publication-metadata/it.json.js +1 -0
  16. package/dist/locales/publication-metadata/pl.json.js +1 -0
  17. package/dist/locales/publication-metadata/pt_PT.json.js +1 -0
  18. package/dist/locales/publication-metadata/sv.json.js +1 -0
  19. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/constants.js +1 -0
  20. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/index.js +1 -0
  21. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-attribute.js +1 -0
  22. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-class.js +1 -0
  23. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-fallback.js +1 -0
  24. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-id.js +1 -0
  25. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-nth-child.js +1 -0
  26. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-nth-of-type.js +1 -0
  27. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/selector-tag.js +1 -0
  28. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/types.js +1 -0
  29. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-cartesian.js +1 -0
  30. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-data.js +1 -0
  31. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-dom.js +1 -0
  32. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-element-data.js +1 -0
  33. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-iselement.js +1 -0
  34. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-messages.js +1 -0
  35. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-options.js +1 -0
  36. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-powerset.js +1 -0
  37. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-selectors.js +1 -0
  38. package/dist/node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/utilities-typescript.js +1 -0
  39. package/dist/opds/Acquisition.js +1 -0
  40. package/dist/opds/Availability.js +1 -0
  41. package/dist/opds/Copies.js +1 -0
  42. package/dist/opds/Holds.js +1 -0
  43. package/dist/opds/Price.js +1 -0
  44. package/dist/publication/AltIdentifier.js +1 -0
  45. package/dist/publication/BelongsTo.js +1 -0
  46. package/dist/publication/Contributor.js +1 -0
  47. package/dist/publication/GuidedNavigation.js +1 -0
  48. package/dist/publication/Layout.js +1 -0
  49. package/dist/publication/Link.js +1 -0
  50. package/dist/publication/LocalizedString.js +1 -0
  51. package/dist/publication/Locator.js +1 -0
  52. package/dist/publication/LocatorCollection.js +1 -0
  53. package/dist/publication/Manifest.js +1 -0
  54. package/dist/publication/Metadata.js +1 -0
  55. package/dist/publication/Profiles.js +1 -0
  56. package/dist/publication/Properties.js +1 -0
  57. package/dist/publication/Publication.js +1 -0
  58. package/dist/publication/PublicationCollection.js +1 -0
  59. package/dist/publication/ReadingProgression.js +1 -0
  60. package/dist/publication/Subject.js +1 -0
  61. package/dist/publication/TDM.js +1 -0
  62. package/dist/publication/accessibility/Accessibility.js +1 -0
  63. package/dist/publication/accessibility/AccessibilityMetadataDisplayGuide.js +1 -0
  64. package/dist/publication/accessibility/Localization.js +1 -0
  65. package/dist/publication/accessibility/SupportedLanguages.js +1 -0
  66. package/dist/publication/encryption/Encryption.js +1 -0
  67. package/dist/publication/encryption/Properties.js +1 -0
  68. package/dist/publication/encryption/index.js +1 -0
  69. package/dist/publication/epub/MediaOverlay.js +1 -0
  70. package/dist/publication/epub/Metadata.js +1 -0
  71. package/dist/publication/epub/Properties.js +1 -0
  72. package/dist/publication/epub/Publication.js +1 -0
  73. package/dist/publication/epub/index.js +1 -0
  74. package/dist/publication/html/DomRange.js +1 -0
  75. package/dist/publication/html/DomRangePoint.js +1 -0
  76. package/dist/publication/html/Locations.js +1 -0
  77. package/dist/publication/html/index.js +1 -0
  78. package/dist/publication/opds/Properties.js +1 -0
  79. package/dist/publication/opds/Publication.js +1 -0
  80. package/dist/publication/opds/index.js +1 -0
  81. package/dist/publication/services/content/Content.js +2 -0
  82. package/dist/publication/services/content/ContentTokenizer.js +1 -0
  83. package/dist/publication/services/content/Iterator.js +1 -0
  84. package/dist/publication/services/content/element/attributes.js +1 -0
  85. package/dist/publication/services/content/element/element.js +1 -0
  86. package/dist/publication/services/content/element/text_role.js +1 -0
  87. package/dist/publication/services/content/iterators/HTMLResourceContentIterator.js +1 -0
  88. package/dist/publication/services/content/iterators/PDFTextContentIterator.js +1 -0
  89. package/dist/publication/services/content/iterators/PublicationContentIterator.js +1 -0
  90. package/dist/publication/services/content/iterators/helpers.js +1 -0
  91. package/dist/publication/services/timeline/Timeline.js +1 -0
  92. package/dist/publication/services/timeline/audio.js +1 -0
  93. package/dist/publication/services/timeline/html.js +1 -0
  94. package/dist/publication/services/timeline/index.js +1 -0
  95. package/dist/util/JSONParse.js +1 -0
  96. package/dist/util/URITemplate.js +1 -0
  97. package/dist/util/mediatype/MediaType.js +1 -0
  98. package/dist/util/npt.js +1 -0
  99. package/dist/util/tokenizer/TextTokenizer.js +1 -0
  100. package/dist/util/tokenizer/tokenize-english/abbreviations.js +1 -0
  101. package/dist/util/tokenizer/tokenize-english/index.js +2 -0
  102. package/dist/util/tokenizer/tokenize-english/utils.js +1 -0
  103. package/dist/util/tokenizer/tokenize-text/index.js +1 -0
  104. package/dist/util/tokenizer/tokenize-text/tokens.js +1 -0
  105. package/package.json +26 -19
  106. package/src/locales/publication-metadata/ar.json +402 -0
  107. package/src/locales/publication-metadata/brh.json +1 -0
  108. package/src/locales/publication-metadata/da.json +310 -0
  109. package/src/locales/publication-metadata/el.json +310 -0
  110. package/src/locales/publication-metadata/en.json +310 -0
  111. package/src/locales/publication-metadata/es.json +333 -0
  112. package/src/locales/publication-metadata/et.json +310 -0
  113. package/src/locales/publication-metadata/fi.json +310 -0
  114. package/src/locales/publication-metadata/fr.json +333 -0
  115. package/src/locales/publication-metadata/he.json +9 -0
  116. package/src/locales/publication-metadata/it.json +333 -0
  117. package/src/locales/publication-metadata/lt.json +8 -0
  118. package/src/locales/publication-metadata/pl.json +333 -0
  119. package/src/locales/publication-metadata/pt_PT.json +329 -0
  120. package/src/locales/publication-metadata/sv.json +310 -0
  121. package/src/locales/publication-metadata/tr.json +51 -0
  122. package/src/locales/publication-metadata/uk.json +1 -0
  123. package/src/opds/Acquisition.ts +1 -1
  124. package/src/opds/Availability.ts +1 -1
  125. package/src/opds/Copies.ts +1 -1
  126. package/src/opds/Holds.ts +1 -1
  127. package/src/opds/Price.ts +1 -1
  128. package/src/publication/Link.ts +2 -6
  129. package/src/publication/Locator.ts +21 -3
  130. package/src/publication/Manifest.ts +5 -7
  131. package/src/publication/Publication.ts +2 -1
  132. package/src/publication/accessibility/Localization.ts +12 -14
  133. package/src/publication/accessibility/SupportedLanguages.ts +1 -1
  134. package/src/publication/encryption/Properties.ts +3 -15
  135. package/src/publication/epub/Metadata.ts +6 -12
  136. package/src/publication/epub/Properties.ts +3 -13
  137. package/src/publication/epub/Publication.ts +18 -39
  138. package/src/publication/html/Locations.ts +57 -104
  139. package/src/publication/opds/Properties.ts +22 -67
  140. package/src/publication/opds/Publication.ts +3 -9
  141. package/src/publication/services/content/iterators/HTMLResourceContentIterator.ts +3 -1
  142. package/src/publication/services/timeline/Timeline.ts +274 -65
  143. package/src/publication/services/timeline/TimelineItem.ts +3 -3
  144. package/src/publication/services/timeline/audio.ts +31 -0
  145. package/src/publication/services/timeline/html.ts +5 -0
  146. package/src/publication/services/timeline/index.ts +12 -0
  147. package/src/util/index.ts +1 -0
  148. package/src/util/npt.ts +70 -0
  149. package/types/src/opds/Acquisition.d.ts +1 -1
  150. package/types/src/opds/Availability.d.ts +1 -1
  151. package/types/src/opds/Copies.d.ts +1 -1
  152. package/types/src/opds/Holds.d.ts +1 -1
  153. package/types/src/opds/Price.d.ts +1 -1
  154. package/types/src/publication/encryption/Properties.d.ts +2 -9
  155. package/types/src/publication/epub/Metadata.d.ts +3 -6
  156. package/types/src/publication/epub/Properties.d.ts +2 -10
  157. package/types/src/publication/epub/Publication.d.ts +7 -18
  158. package/types/src/publication/html/Locations.d.ts +15 -44
  159. package/types/src/publication/opds/Properties.d.ts +8 -36
  160. package/types/src/publication/opds/Publication.d.ts +2 -5
  161. package/types/src/publication/services/timeline/Timeline.d.ts +80 -15
  162. package/types/src/publication/services/timeline/TimelineItem.d.ts +3 -3
  163. package/types/src/publication/services/timeline/audio.d.ts +4 -0
  164. package/types/src/publication/services/timeline/html.d.ts +4 -0
  165. package/types/src/publication/services/timeline/index.d.ts +6 -0
  166. package/types/src/util/index.d.ts +1 -0
  167. package/types/src/util/npt.d.ts +30 -0
  168. package/dist/ar-DyHX_uy2.js +0 -7
  169. package/dist/da-Dct0PS3E.js +0 -7
  170. package/dist/fr-C5HEel98.js +0 -7
  171. package/dist/index.umd.cjs +0 -3
  172. package/dist/it-DFOBoXGy.js +0 -7
  173. package/dist/pt_PT-Di3sVjze.js +0 -7
  174. package/dist/sv-BfzAFsVN.js +0 -7
@@ -0,0 +1 @@
1
+ function*s(r=[],{maxResults:f=Number.POSITIVE_INFINITY}={}){let t=0,e=o(1);for(;e.length<=r.length&&t<f;)t+=1,yield e.map(u=>r[u]),e=l(e,r.length-1)}function i(r=[],{maxResults:f=Number.POSITIVE_INFINITY}={}){return Array.from(s(r,{maxResults:f}))}function l(r=[],f=0){const t=r.length;if(t===0)return[];const e=[...r];e[t-1]+=1;for(let n=t-1;n>=0;n--)if(e[n]>f){if(n===0)return o(t+1);e[n-1]++,e[n]=e[n-1]+1}return e[t-1]>f?o(t+1):e}function o(r=1){return Array.from(Array(r).keys())}export{i as getPowerSet,s as powerSetGenerator};
@@ -0,0 +1 @@
1
+ import{SELECTOR_PATTERN as y}from"./constants.js";import{getElementAttributeSelectors as h,getAttributeSelectors as C}from"./selector-attribute.js";import{getElementClassSelectors as _,getClassSelectors as b}from"./selector-class.js";import{getElementIdSelectors as R,getIdSelector as A}from"./selector-id.js";import{getElementNthChildSelector as G,getNthChildSelector as L}from"./selector-nth-child.js";import{getElementNthOfTypeSelector as N,getNthOfTypeSelector as P}from"./selector-nth-of-type.js";import{getElementTagSelectors as O,getTagSelector as w}from"./selector-tag.js";import{createPatternMatcher as S}from"./utilities-data.js";import{testSelector as p,getParents as I}from"./utilities-dom.js";import{OPERATOR as d,CSS_SELECTOR_TYPE as l}from"./types.js";import{isElement as x}from"./utilities-iselement.js";import{powerSetGenerator as B,getPowerSet as j}from"./utilities-powerset.js";import{cartesianProductGenerator as k}from"./utilities-cartesian.js";const z="3a".toUpperCase(),H=/[ !"#$%&'()\[\]{|}<>*+,./;=?@^`~\\]/;function Et(t=""){return CSS?CSS.escape(t):M(t)}function M(t=""){return t.split("").map(e=>e===":"?`\\${z} `:H.test(e)?`\\${e}`:escape(e).replace(/%/g,"\\")).join("")}const W={tag:w,id:A,class:b,attribute:C,nthchild:L,nthoftype:P},Y={tag:O,id:R,class:_,attribute:h,nthchild:G,nthoftype:N};function Tt(t,e){return Y[e](t)}function $(t,e){const o=W[e];return o(t)}function D(t=[],e,o){return t.filter(r=>o(r)||!e(r))}function v(t=[],e){return t.sort((o,r)=>{const n=e(o),c=e(r);return n&&!c?-1:!n&&c?1:0})}function*U(t,e){const o=new Set,r=q(t,e);for(const n of Q(r,e))o.has(n)||(o.add(n),yield n)}function q(t,e){const{blacklist:o,whitelist:r,combineWithinSelector:n,maxCombinations:c}=e,i=S(o),f=S(r),u=(a,s)=>{const g=$(t,s),E=D(g,i,f),m=v(E,f);return a[s]=n?Array.from(B(m,{maxResults:c})):m.map(T=>[T]),a};return F(e).reduce(u,{})}function F(t){const{selectors:e,includeTag:o}=t,r=[...e];return o&&!r.includes("tag")&&r.push("tag"),r}function J(t){return t.includes(l.tag)||t.includes(l.nthoftype)?[...t]:[...t,l.tag]}function K(t){const{selectors:e,combineBetweenSelectors:o,includeTag:r,maxCandidates:n}=t,c=o?j(e,{maxResults:n}):e.map(i=>[i]);return r?c.map(J):c}function*Q(t,e){for(const o of K(e))yield*V(o,t)}function*V(t,e){const o={};for(const r of t){const n=e[r];n&&n.length>0&&(o[r]=n)}for(const r of k(o))yield Z(r)}function X(t,e){return e[t]?e[t].join(""):""}function Z(t={}){const e=[...y];return t[l.tag]&&t[l.nthoftype]&&e.splice(e.indexOf(l.tag),1),e.map(o=>X(o,t)).join("")}function tt(t,e){return[...t.map(o=>e+d.DESCENDANT+o),...t.map(o=>e+d.CHILD+o)]}function*et(t,e){if(e==="")yield*t;else for(const o of t)yield*tt([o],e)}function*ot(t,e,o="",r){const n=U(t,r);for(const c of et(n,o))p(t,c,e)&&(yield c)}function*rt(t,e,o="",r){if(t.length===0)return null;const n=[t.length>1?t:[],...I(t,e).map(c=>[c])];for(const c of n)for(const i of ot(c,e,o,r))yield{foundElements:c,selector:i}}function*yt({elements:t,root:e,rootSelector:o="",options:r}){let n=e,c=o,i=!0;for(;i;){let f=!1;for(const u of rt(t,n,c,r)){const{foundElements:a,selector:s}=u;if(f=!0,p(t,s,e))yield s;else{n=a[0],c=s;break}}f||(i=!1)}}function ht(t){(t instanceof NodeList||t instanceof HTMLCollection)&&(t=Array.from(t));const e=(Array.isArray(t)?t:[t]).filter(x);return[...new Set(e)]}export{Y as ELEMENT_SELECTOR_TYPE_GETTERS,z as ESCAPED_COLON,W as SELECTOR_TYPE_GETTERS,H as SPECIAL_CHARACTERS_RE,U as allSelectorsGenerator,rt as closestIdentifiableParentGenerator,K as combineSelectorTypes,Z as constructSelector,X as constructSelectorType,V as constructedSelectorsGenerator,D as filterSelectors,Tt as getElementSelectorsByType,$ as getSelectorsByType,q as getSelectorsList,F as getSelectorsToGet,M as legacySanitizeSelectorItem,v as orderSelectors,Et as sanitizeSelectorItem,ht as sanitizeSelectorNeedle,yt as selectorGenerator,Q as selectorTypeCombinationsGenerator,ot as selectorWithinRootGenerator};
@@ -0,0 +1 @@
1
+ function n(e,u){return Object.values(e).includes(u)}export{n as isEnumValue};
@@ -0,0 +1 @@
1
+ class i{constructor(e){this.type=e.type,this.children=e.children}static deserialize(e){if(e&&e.type)return new i({type:e.type,children:i.deserializeArray(e.children)})}static deserializeArray(e){if(Array.isArray(e))return e.map(r=>i.deserialize(r)).filter(r=>r!==void 0)}serialize(){const e={type:this.type};return this.children&&(e.children=this.children.map(r=>r.serialize())),e}}export{i as Acquisition};
@@ -0,0 +1 @@
1
+ import{datefromJSON as i}from"../util/JSONParse.js";var s=(e=>(e.available="available",e.reserved="reserved",e.ready="ready",e))(s||{});class r{constructor(t){this.state=t.state,this.since=t.since,this.until=t.until}static deserialize(t){if(t&&t.state)return new r({state:t.state,since:i(t.since),until:i(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}}export{r as Availability,s as AvailabilityStatus};
@@ -0,0 +1 @@
1
+ import{positiveNumberfromJSON as t}from"../util/JSONParse.js";class i{constructor(a){this.total=a.total,this.available=a.available}static deserialize(a){if(a)return new i({total:t(a.total),available:t(a.available)})}serialize(){const a={};return this.total!==void 0&&(a.total=this.total),this.available!==void 0&&(a.available=this.available),a}}export{i as Copies};
@@ -0,0 +1 @@
1
+ import{positiveNumberfromJSON as i}from"../util/JSONParse.js";class o{constructor(t){this.total=t.total,this.position=t.position}static deserialize(t){if(t)return new o({total:i(t.total),position:i(t.position)})}serialize(){const t={};return this.total!==void 0&&(t.total=this.total),this.position!==void 0&&(t.position=this.position),t}}export{o as Holds};
@@ -0,0 +1 @@
1
+ import{positiveNumberfromJSON as c}from"../util/JSONParse.js";class u{constructor(r){this.currency=r.currency,this.value=r.value}static deserialize(r){if(!r)return;let e=r.currency;if(!(e&&typeof e=="string"&&e.length>0))return;let t=c(r.value);if(t!==void 0)return new u({currency:e,value:t})}serialize(){return{currency:this.currency,value:this.value}}}export{u as Price};
@@ -0,0 +1 @@
1
+ class t{constructor(e){this.value=e.value,this.scheme=e.scheme}static deserialize(e){if(e){if(typeof e=="string")return new t({value:e});if(typeof e=="object"&&e.value)return new t({value:e.value,scheme:e.scheme})}}serialize(){return this.scheme?{value:this.value,scheme:this.scheme}:this.value}}export{t as AltIdentifier};
@@ -0,0 +1 @@
1
+ import{Contributors as n}from"./Contributor.js";class s{constructor(e){this.items=e&&e.items?e.items:new Map}static deserialize(e){if(!(e&&typeof e=="object"))return;const t=new Map;return Object.entries(e).forEach(([i,o])=>{const r=n.deserialize(o);r&&r.items.length>0&&t.set(i,r)}),new s({items:t})}serialize(){const e={};return this.items.forEach((t,i)=>e[i]=t.serialize()),e}}export{s as BelongsTo};
@@ -0,0 +1 @@
1
+ import{Links as o}from"./Link.js";import{numberfromJSON as f,arrayfromJSONorString as d,setToArray as n}from"../util/JSONParse.js";import{LocalizedString as s}from"./LocalizedString.js";import{AltIdentifier as a}from"./AltIdentifier.js";class t{constructor(i){this.name=i.name,this.sortAs=i.sortAs,this.identifier=i.identifier,this.altIdentifiers=i.altIdentifiers,this.roles=i.roles,this.links=i.links,this.position=i.position}static deserialize(i){if(i)return typeof i=="string"?new t({name:s.deserialize(i)}):i.name?new t({name:s.deserialize(i.name),sortAs:s.deserialize(i.sortAs),identifier:i.identifier,altIdentifiers:i.altIdentifier?Array.isArray(i.altIdentifier)?new Set(i.altIdentifier.map(e=>a.deserialize(e)).filter(e=>e!==void 0)):new Set([a.deserialize(i.altIdentifier)].filter(e=>e!==void 0)):void 0,roles:i.role?new Set(d(i.role)):void 0,links:o.deserialize(i.links),position:f(i.position)}):void 0}serialize(){const i={name:this.name.serialize()};return this.sortAs!==void 0&&(i.sortAs=this.sortAs.serialize()),this.identifier!==void 0&&(i.identifier=this.identifier),this.altIdentifiers&&(i.altIdentifier=n(this.altIdentifiers).map(e=>e.serialize())),this.roles&&(i.role=n(this.roles)),this.links&&(i.links=this.links.serialize()),this.position!==void 0&&(i.position=this.position),i}}class l{constructor(i){this.items=i}static deserialize(i){if(!i)return;const e=Array.isArray(i)?i:[i];return new l(e.map(r=>t.deserialize(r)).filter(r=>r!==void 0))}serialize(){return this.items.map(i=>i.serialize())}}export{t as Contributor,l as Contributors};
@@ -0,0 +1 @@
1
+ import{arrayfromJSONorString as a,setToArray as n}from"../util/JSONParse.js";import{Links as o}from"./Link.js";class d{constructor(i){this.links=i.links,this.guided=i.guided}static deserialize(i){if(i)return new d({links:o.deserialize(i.links),guided:r.deserializeArray(i.guided)})}serialize(){const i={};return this.links!==void 0&&(i.links=this.links.serialize()),this.guided!==void 0&&(i.guided=this.guided.map(e=>e.serialize())),i}}class s{constructor(i){this.plain=i.plain,this.ssml=i.ssml,this.language=i.language}static deserialize(i){if(i!=null){if(typeof i=="string")return new s({plain:i});if(i.plain||i.ssml||i.language)return new s({plain:i.plain,ssml:i.ssml,language:i.language})}}serialize(){const i={};return this.plain!==void 0&&(i.plain=this.plain),this.ssml!==void 0&&(i.ssml=this.ssml),this.language!==void 0&&(i.language=this.language),Object.keys(i).length>0?i:void 0}}class r{constructor(i){this.audioref=i.audioref,this.children=i.children,this.imgref=i.imgref,this.role=i.role,this.level=i.level!==void 0?Math.min(6,Math.max(1,i.level)):void 0,this.text=i.text,this.textref=i.textref,this.description=i.description}get plainText(){return this.text?.plain}get ssmlText(){return this.text?.ssml}get textLanguage(){return this.text?.language}static deserialize(i){if(i)return new r({audioref:i.audioref,children:r.deserializeArray(i.children),imgref:i.imgref,role:i.role?new Set(a(i.role)):void 0,level:typeof i.level=="number"?i.level:void 0,text:s.deserialize(i.text),textref:i.textref,description:r.deserialize(i.description)})}static deserializeArray(i){if(Array.isArray(i))return i.map(e=>r.deserialize(e)).filter(e=>e!==void 0)}serialize(){const i={};if(this.audioref!==void 0&&(i.audioref=this.audioref),this.children!==void 0&&(i.children=this.children.map(e=>e.serialize())),this.imgref!==void 0&&(i.imgref=this.imgref),this.role!==void 0&&(i.role=n(this.role)),this.level!==void 0&&(i.level=this.level),this.text!==void 0){const e=this.text.serialize();e!==void 0&&(i.text=e)}return this.textref!==void 0&&(i.textref=this.textref),this.description&&(i.description=this.description.serialize()),i}get audioFile(){return this.audioref?.split("#")[0]}get audioTime(){if(this.audioref?.includes("#"))return this.audioref.split("#",2)[1]}get textFile(){return this.textref?.split("#")[0]}get fragmentId(){if(this.textref?.includes("#"))return this.textref.split("#",2)[1]}get clip(){const i=this.audioFile;if(!i)return;const e=this.audioTime,t={audioResource:i,fragmentId:this.fragmentId};if(!e)return t;const l=this.parseTimer(e);return t.start=l[0],t.end=l[1],t}parseTimer(i){if(!i||!i.startsWith("t="))return[void 0,void 0];const e=i.substring(2).split(",").map(t=>parseFloat(t));return e.length===1?[isNaN(e[0])?void 0:e[0],void 0]:e.length>2?[void 0,void 0]:[isNaN(e[0])?void 0:e[0],isNaN(e[1])?void 0:e[1]]}}export{d as GuidedNavigationDocument,r as GuidedNavigationObject,s as GuidedNavigationText};
@@ -0,0 +1 @@
1
+ var l=(e=>(e.reflowable="reflowable",e.fixed="fixed",e.scrolled="scrolled",e))(l||{});export{l as Layout};
@@ -0,0 +1 @@
1
+ import{MediaType as a}from"../util/mediatype/MediaType.js";import{Properties as d}from"./Properties.js";import{URITemplate as n}from"../util/URITemplate.js";import{arrayfromJSONorString as l,positiveNumberfromJSON as r,setToArray as f}from"../util/JSONParse.js";import{Locator as m}from"./Locator.js";class s{constructor(e){this.href=e.href,this.templated=e.templated,this.type=e.type,this.title=e.title,this.rels=e.rels,this.properties=e.properties,this.height=e.height,this.width=e.width,this.size=e.size,this.duration=e.duration,this.bitrate=e.bitrate,this.languages=e.languages,this.alternates=e.alternates,this.children=e.children}static deserialize(e){if(!(!e||typeof e.href!="string"))return new s({href:e.href,templated:e.templated,type:e.type,title:e.title,rels:e.rel?Array.isArray(e.rel)?new Set(e.rel):new Set([e.rel]):void 0,properties:d.deserialize(e.properties),height:r(e.height),width:r(e.width),size:r(e.size),duration:r(e.duration),bitrate:r(e.bitrate),languages:l(e.language),alternates:h.deserialize(e.alternate),children:h.deserialize(e.children)})}serialize(){const e={href:this.href};return this.templated!==void 0&&(e.templated=this.templated),this.type!==void 0&&(e.type=this.type),this.title!==void 0&&(e.title=this.title),this.rels&&(e.rel=f(this.rels)),this.properties&&(e.properties=this.properties.serialize()),this.height!==void 0&&(e.height=this.height),this.width!==void 0&&(e.width=this.width),this.size!==void 0&&(e.size=this.size),this.duration!==void 0&&(e.duration=this.duration),this.bitrate!==void 0&&(e.bitrate=this.bitrate),this.languages&&(e.language=this.languages),this.alternates&&(e.alternate=this.alternates.serialize()),this.children&&(e.children=this.children.serialize()),e}get mediaType(){return this.type!==void 0?a.parse({mediaType:this.type}):a.BINARY}toURL(e){const t=this.href.replace(/^(\/)/,"");if(t.length===0)return;let i=e||"/";return i.startsWith("/")&&(i="file://"+i),new URL(t,i).href.replace(/^(file:\/\/)/,"")}get templateParameters(){return this.templated?new n(this.href).parameters:new Set}expandTemplate(e){return new s({href:new n(this.href).expand(e),templated:!1})}addProperties(e){const t=s.deserialize(this.serialize());return t.properties=t.properties?t.properties?.add(e):new d(e),t}get locator(){return new m({href:this.href,type:this.type??"",title:this.title})}}class h{constructor(e){this.items=e}static deserialize(e){if(e&&Array.isArray(e))return new h(e.map(t=>s.deserialize(t)).filter(t=>t!==void 0))}serialize(){return this.items.map(e=>e.serialize())}findWithRel(e){const t=i=>i.rels&&i.rels.has(e);return this.items.find(t)}filterByRel(e){const t=i=>i.rels&&i.rels.has(e);return this.items.filter(t)}findWithHref(e){const t=i=>i.href===e;return this.items.find(t)}findIndexWithHref(e){const t=i=>i.href===e;return this.items.findIndex(t)}findWithMediaType(e){const t=i=>i.mediaType.matches(e);return this.items.find(t)}filterByMediaType(e){const t=i=>i.mediaType.matches(e);return this.items.filter(t)}filterByMediaTypes(e){const t=i=>{for(const p of e)if(i.mediaType.matches(p))return!0;return!1};return this.items.filter(t)}everyIsAudio(){const e=t=>t.mediaType.isAudio;return this.items.length>0&&this.items.every(e)}everyIsBitmap(){const e=t=>t.mediaType.isBitmap;return this.items.length>0&&this.items.every(e)}everyIsHTML(){const e=t=>t.mediaType.isHTML;return this.items.length>0&&this.items.every(e)}everyIsVideo(){const e=t=>t.mediaType.isVideo;return this.items.length>0&&this.items.every(e)}everyMatchesMediaType(e){return Array.isArray(e)?this.items.length>0&&this.items.every(t=>{for(const i of e)return t.mediaType.matches(i);return!1}):this.items.length>0&&this.items.every(t=>t.mediaType.matches(e))}filterLinksHasType(){return this.items.filter(e=>e.type)}}export{s as Link,h as Links};
@@ -0,0 +1 @@
1
+ const s=class s{constructor(t){this.translations=typeof t=="string"?{[s.UNDEFINED_LANGUAGE]:t}:t}static deserialize(t){if(t&&(typeof t=="string"||t.constructor===Object))return new s(t)}serialize(){return this.translations}getTranslation(t){return this.translations[t||s.UNDEFINED_LANGUAGE]||this.translations[s.UNDEFINED_LANGUAGE]||this.translations[s.LANGUAGE_EN]||(Object.values(this.translations).length===0?"":Object.values(this.translations)[0])}};s.UNDEFINED_LANGUAGE="und",s.LANGUAGE_EN="en";let r=s;export{r as LocalizedString};
@@ -0,0 +1 @@
1
+ import{numberfromJSON as f,arrayfromJSONorString as l}from"../util/JSONParse.js";class o{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 i=f(t.progression),e=f(t.totalProgression),r=f(t.position),s=new Map,g=new Set(["fragment","fragments","progression","totalProgression","position","otherLocations"]);return Object.entries(t).forEach(([n,h])=>{g.has(n)||s.set(n,h)}),t.otherLocations instanceof Map&&t.otherLocations.forEach((n,h)=>s.set(h,n)),new o({fragments:l(t.fragments||t.fragment),progression:i!==void 0&&i>=0&&i<=1?i:void 0,totalProgression:e!==void 0&&e>=0&&e<=1?e:void 0,position:r!==void 0&&r>0?r:void 0,otherLocations:s.size===0?void 0:s})}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((i,e)=>t[e]=i),t}}class c{constructor(t){this.after=t.after,this.before=t.before,this.highlight=t.highlight}static deserialize(t){if(t)return new c({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 a{constructor(t){const i=t.href.indexOf("#"),e=i>=0?t.href.slice(i+1):void 0;this.href=i>=0?t.href.slice(0,i):t.href,this.type=t.type,this.title=t.title;const r=t.locations?.fragments,s=e&&(!r||r.length===0);this.locations=t.locations?s?new o({...t.locations,fragments:[e]}):t.locations:e?new o({fragments:[e]}):new o({}),this.text=t.text}static deserialize(t){if(t&&t.href&&t.type)return new a({href:t.href,type:t.type,title:t.title,locations:o.deserialize(t.locations),text:c.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 a({href:this.href,type:this.type,title:this.title,text:this.text,locations:new o({...this.locations,...t})})}}export{a as Locator,o as LocatorLocations,c as LocatorText};
@@ -0,0 +1 @@
1
+ import{numberfromJSON as n}from"../util/JSONParse.js";import{Links as s}from"./Link.js";import{LocalizedString as m}from"./LocalizedString.js";import{Locator as h}from"./Locator.js";class a{constructor(t){this.title=t.title,this.numberOfItems=t.numberOfItems,this.otherMetadata=t.otherMetadata}static deserialize(t){if(!t)return;const e=new Map,i=new Set(["title","numberOfItems"]);return Object.entries(t).forEach(([r,l])=>{i.has(r)||e.set(r,l)}),new a({title:m.deserialize(t.title),numberOfItems:n(t.numberOfItems),otherMetadata:e.size===0?void 0:e})}serialize(){const t={};return this.title&&(t.title=this.title.serialize()),this.numberOfItems!==void 0&&(t.numberOfItems=this.numberOfItems),this.otherMetadata&&this.otherMetadata.forEach((e,i)=>t[i]=e),t}}class o{constructor(t){this.metadata=t.metadata??new a({}),this.links=t.links??new s([]),this.locators=t.locators??[]}static deserialize(t){if(!t)return;let e,i=t.locators;return i&&Array.isArray(i)&&(e=i.map(r=>h.deserialize(r)).filter(r=>r!==void 0)),new o({metadata:a.deserialize(t.metadata),links:s.deserialize(t.links),locators:e})}serialize(){const t={};if(this.metadata){let e=this.metadata.serialize();e&&Object.keys(e).length>0&&(t.metadata=e)}return this.links&&this.links.items.length>0&&(t.links=this.links.serialize()),this.locators&&(t.locators=this.locators.map(e=>e.serialize())),t}}export{o as LocatorCollection,a as LocatorCollectionMetadata};
@@ -0,0 +1 @@
1
+ import{Metadata as k}from"./Metadata.js";import{Links as l,Link as m}from"./Link.js";import{arrayfromJSONorString as g}from"../util/JSONParse.js";import{PublicationCollection as u}from"./PublicationCollection.js";import{MediaType as z}from"../util/mediatype/MediaType.js";import{Locator as O,LocatorLocations as w}from"./Locator.js";class p{constructor(e){this.context=e.context,this.metadata=e.metadata,this.links=e.links,this.readingOrder=e.readingOrder,this.resources=e.resources,this.toc=e.toc,this.subcollections=e.subcollections}static deserialize(e){if(!e)return;const i=k.deserialize(e.metadata);if(!i)return;const t=l.deserialize(e.links),r=l.deserialize(e.readingOrder?e.readingOrder:e.spine);if(!r)return;const s=new Set(["@context","metadata","links","readingOrder","spine","resources","toc"]),c={};return Object.keys(e).forEach(n=>{s.has(n)||(c[n]=e[n])}),new p({context:g(e["@context"]),metadata:i,links:t,readingOrder:r,resources:l.deserialize(e.resources),toc:l.deserialize(e.toc),subcollections:u.deserializeCollections(c)})}serialize(){const e={};return this.context!==void 0&&(e["@context"]=this.context),e.metadata=this.metadata.serialize(),this.links!==void 0&&(e.links=this.links.serialize()),e.readingOrder=this.readingOrder.serialize(),this.resources&&(e.resources=this.resources.serialize()),this.toc&&(e.toc=this.toc.serialize()),u.serializeCollection(e,this.subcollections),e}linkWithRel(e){const i=new Array;i.push(this.readingOrder),this.resources&&i.push(this.resources),this.links&&i.push(this.links);let t;for(const r of i)if(t=r.findWithRel(e),t!==void 0)return t;return t}linksWithRel(e){const i=[];return i.push(this.readingOrder.filterByRel(e)),this.resources&&i.push(this.resources.filterByRel(e)),this.links&&i.push(this.links.filterByRel(e)),i.reduce((t,r)=>t.concat(r),[])}locatorFromLink(e){const i=e.href.split("#")[0],t=this.linkWithHref(i);if(!t)return;const r=t.type;if(!r)return;const s=e.href.includes("#");return new O({href:e.href,type:r,title:t.title??e.title,locations:new w({progression:s?void 0:0})})}linkWithHref(e){const i=n=>{let o;for(const f of n)if(o=f.findWithHref(e),o!==void 0)return o;const h=new Array;return n.forEach(f=>{const d=[];for(const a of f.items)a.alternates&&d.push(a.alternates),a.children&&d.push(a.children);h.push(...d)}),h.length>0&&(o=i(h)),o},t=[];t.push(this.readingOrder),this.resources&&t.push(this.resources),this.links&&t.push(this.links);const r=i(t);if(r!==void 0)return r;const s=e.split(/[#]/);if(s.length<2)return;const c=s[0];return this.linkWithHref(c)}get baseURL(){const e=this.links?.items.find(i=>i.rels&&i.rels.has("self"));if(e){let i=e.href;if(i){const t=i.lastIndexOf("/"),r=t===-1?void 0:i.substring(t+1);i=i.replace(new RegExp("/?$query$"),""),i=i.replace(new RegExp("//$"),""),r&&(i=i.replace(new RegExp(r+"$"),""))}return i}}setSelfLink(e){this.links||(this.links=new l([])),this.links.items=this.links.items.filter(i=>i.rels===void 0||!i.rels?.has("self")),this.links.items.push(new m({href:e,type:z.READIUM_WEBPUB_MANIFEST.string,rels:new Set(["self"])}))}}export{p as Manifest};
@@ -0,0 +1 @@
1
+ import{arrayfromJSONorString as d,datefromJSON as f,positiveNumberfromJSON as g}from"../util/JSONParse.js";import{AltIdentifier as W}from"./AltIdentifier.js";import{BelongsTo as h}from"./BelongsTo.js";import{Contributors as t}from"./Contributor.js";import{Layout as l}from"./Layout.js";import{LocalizedString as c}from"./LocalizedString.js";import{Profile as a}from"./Profiles.js";import{ReadingProgression as s}from"./ReadingProgression.js";import{Subjects as X}from"./Subject.js";import{Accessibility as Y}from"./accessibility/Accessibility.js";import{TDM as Z}from"./TDM.js";const r=class r{constructor(i){this.title=i.title,this.typeUri=i.typeUri,this.conformsTo=i.conformsTo,this.identifier=i.identifier,this.altIdentifier=i.altIdentifier,this.subtitle=i.subtitle,this.sortAs=i.sortAs,this.artists=i.artists,this.authors=i.authors,this.colorists=i.colorists,this.contributors=i.contributors,this.editors=i.editors,this.illustrators=i.illustrators,this.inkers=i.inkers,this.letterers=i.letterers,this.narrators=i.narrators,this.pencilers=i.pencilers,this.translators=i.translators,this.languages=i.languages,this.description=i.description,this.publishers=i.publishers,this.imprints=i.imprints,this.published=i.published,this.modified=i.modified,this.subjects=i.subjects,this.belongsTo=i.belongsTo,this.belongsToCollections=i.belongsToCollections,this.belongsToSeries=i.belongsToSeries,this.belongsToCollections&&this.belongsToCollections.items.length>0&&(this.belongsTo||(this.belongsTo=new h),this.belongsTo.items.set("collection",this.belongsToCollections)),this.belongsToSeries&&this.belongsToSeries.items.length>0&&(this.belongsTo||(this.belongsTo=new h),this.belongsTo.items.set("series",this.belongsToSeries)),this.layout=i.layout,this.readingProgression=i.readingProgression,this.duration=i.duration,this.numberOfPages=i.numberOfPages,this.accessibility=i.accessibility,this.tdm=i.tdm,this.otherMetadata=i.otherMetadata}static deserialize(i){if(!(i&&i.title))return;const e=c.deserialize(i.title),o=i["@type"],u=d(i.conformsTo),m=i.identifier,p=W.deserialize(i.altIdentifier),z=c.deserialize(i.subtitle),T=c.deserialize(i.sortAs),y=t.deserialize(i.artist),P=t.deserialize(i.author),O=t.deserialize(i.colorist),S=t.deserialize(i.contributor),I=t.deserialize(i.editor),A=t.deserialize(i.illustrator),k=t.deserialize(i.inker),w=t.deserialize(i.letterer),C=t.deserialize(i.narrator),U=t.deserialize(i.penciler),L=t.deserialize(i.translator),N=d(i.language),D=i.description,M=t.deserialize(i.publisher),B=t.deserialize(i.imprint),E=f(i.published),J=f(i.modified),x=X.deserialize(i.subject),R=h.deserialize(i.belongsTo),F=Y.deserialize(i.accessibility),K=i.layout,V=i.readingProgression,q=g(i.duration),G=g(i.numberOfPages),H=Z.deserialize(i.tdm);let n=Object.assign({},i);return r.mappedProperties.forEach(Q=>delete n[Q]),Object.keys(n).length===0&&(n=void 0),new r({title:e,typeUri:o,conformsTo:u,identifier:m,altIdentifier:p,subtitle:z,sortAs:T,artists:y,authors:P,colorists:O,contributors:S,editors:I,illustrators:A,inkers:k,letterers:w,narrators:C,pencilers:U,translators:L,languages:N,description:D,publishers:M,imprints:B,published:E,modified:J,subjects:x,belongsTo:R,layout:K,readingProgression:V,duration:q,numberOfPages:G,accessibility:F,tdm:H,otherMetadata:n})}serialize(){const i={title:this.title.serialize()};if(this.typeUri!==void 0&&(i["@type"]=this.typeUri),this.conformsTo&&(i.conformsTo=this.conformsTo),this.identifier!==void 0&&(i.identifier=this.identifier),this.altIdentifier&&(i.altIdentifier=this.altIdentifier.serialize()),this.subtitle&&(i.subtitle=this.subtitle.serialize()),this.sortAs&&(i.sortAs=this.sortAs.serialize()),this.editors&&(i.editor=this.editors.serialize()),this.artists&&(i.artist=this.artists.serialize()),this.authors&&(i.author=this.authors.serialize()),this.colorists&&(i.colorist=this.colorists.serialize()),this.contributors&&(i.contributor=this.contributors.serialize()),this.illustrators&&(i.illustrator=this.illustrators.serialize()),this.letterers&&(i.letterer=this.letterers.serialize()),this.narrators&&(i.narrator=this.narrators.serialize()),this.pencilers&&(i.penciler=this.pencilers.serialize()),this.translators&&(i.translator=this.translators.serialize()),this.inkers&&(i.inker=this.inkers.serialize()),this.languages&&(i.language=this.languages),this.description!==void 0&&(i.description=this.description),this.publishers&&(i.publisher=this.publishers.serialize()),this.imprints&&(i.imprint=this.imprints.serialize()),this.published!==void 0&&(i.published=this.published.toISOString()),this.modified!==void 0&&(i.modified=this.modified.toISOString()),this.subjects&&(i.subject=this.subjects.serialize()),this.belongsTo&&(i.belongsTo=this.belongsTo.serialize()),this.layout&&(i.layout=this.layout),this.readingProgression&&(i.readingProgression=this.readingProgression),this.duration!==void 0&&(i.duration=this.duration),this.numberOfPages!==void 0&&(i.numberOfPages=this.numberOfPages),this.accessibility&&(i.accessibility=this.accessibility.serialize()),this.tdm&&(i.tdm=this.tdm.serialize()),this.otherMetadata){const e=this.otherMetadata;Object.keys(e).forEach(o=>i[o]=e[o])}return i}get effectiveLayout(){if(!this.conformsTo)return null;for(const i of this.conformsTo)switch(i){case a.EPUB:return this.layout||l.reflowable;case a.DIVINA:return this.layout===l.reflowable?l.fixed:this.layout||l.fixed;case a.AUDIOBOOK:case a.PDF:return null}return null}get effectiveReadingProgression(){if(this.readingProgression)return this.readingProgression;if(this.languages?.length!==1)return s.ltr;const i=this.languages[0].toLowerCase();if(i==="zh-hant"||i==="zh-tw")return s.rtl;switch(i.split("-")[0]){case"ar":return s.rtl;case"fa":return s.rtl;case"he":return s.rtl;default:return s.ltr}}};r.mappedProperties=["title","@type","conformsTo","identifier","altIdentifier","subtitle","sortAs","artist","author","colorist","contributor","editor","illustrator","inker","letterer","narrator","penciler","translator","language","description","publisher","imprint","published","modified","subject","belongsTo","layout","readingProgression","duration","numberOfPages","accessibility","tdm"];let b=r;export{b as Metadata};
@@ -0,0 +1 @@
1
+ var p=(e=>(e.EPUB="https://readium.org/webpub-manifest/profiles/epub",e.AUDIOBOOK="https://readium.org/webpub-manifest/profiles/audiobook",e.DIVINA="https://readium.org/webpub-manifest/profiles/divina",e.PDF="https://readium.org/webpub-manifest/profiles/pdf",e))(p||{});export{p as Profile};
@@ -0,0 +1 @@
1
+ var n=(e=>(e.left="left",e.right="right",e.center="center",e))(n||{});class t{constructor(r){this.otherProperties=r}get page(){return this.otherProperties.page}static deserialize(r){if(r)return new t(r)}serialize(){return this.otherProperties}add(r){const i=Object.assign({},this.otherProperties);for(const s in r)i[s]=r[s];return new t(i)}}export{n as Page,t as Properties};
@@ -0,0 +1 @@
1
+ import{Link as f}from"./Link.js";import{Locator as h}from"./Locator.js";import{EmptyFetcher as m}from"../fetcher/Fetcher.js";import{GuidedNavigationDocument as c}from"./GuidedNavigation.js";import{buildTimeline as d}from"./services/timeline/index.js";import{MediaType as l}from"../util/mediatype/MediaType.js";import{URITemplate as o}from"../util/URITemplate.js";class R{constructor(i){this.fetcher=new m,i.fetcher&&(this.fetcher=i.fetcher),this.manifest=i.manifest,this.context=i.manifest.context,this.metadata=i.manifest.metadata,this.links=i.manifest.links,this.readingOrder=i.manifest.readingOrder,this.resources=i.manifest.resources,this.toc=i.manifest.toc,this.subcollections=i.manifest.subcollections}get timeline(){return this._timeline||(this._timeline=d(this)),this._timeline}get baseURL(){return this.manifest.baseURL}linkWithHref(i){return this.manifest.linkWithHref(i)}linksWithRole(i){const e=this.subcollections?.get(i);return e&&e.length>0?e[0].links:void 0}linksWithRel(i){return this.manifest.linksWithRel(i)}linkWithRel(i){return this.manifest.linkWithRel(i)}getCover(){const i=[this.links,this.resources,this.readingOrder].filter(Boolean);for(const e of i){const t=e.items.find(n=>n.rels?.has("cover"));if(t)return t}for(const e of i){const t=e.items.find(n=>n.mediaType.isBitmap||n.mediaType.matches(l.SVG));if(t)return t}}async positionsFromManifest(){const i=this.manifest.links?.findWithMediaType("application/vnd.readium.position-list+json");if(i===void 0)return[];const e=await this.get(i).readAsJSON();return e.total?e.positions.map(t=>h.deserialize(t)).filter(t=>t!==void 0):[]}async guideForLink(i){const e=s=>s.alternates?.findWithMediaType("application/guided-navigation+json");let t=e(i);if(!t){const s=this.linkWithHref(i.href);s!==void 0&&(t=e(s))}if(t||(t=this.manifest.links?.findWithMediaType("application/guided-navigation+json")),!t)return;let n=t.href;if(t.templated){const s=new o(n),r={};s.parameters.has("ref")&&(r.ref=i.href),n=new o(n).expand(r)}const a=await this.get(new f({href:n})).readAsJSON();return c.deserialize(a)}get(i){return this.fetcher.get(i)}}export{R as Publication};
@@ -0,0 +1 @@
1
+ import{Links as n}from"./Link.js";class l{constructor(e){this.metadata=e.metadata,this.links=e.links,this.subcollections=e.subcollections}static deserialize(e){if(!e)return;let i,t,s;if(Array.isArray(e))i=n.deserialize(e);else if(typeof e=="object")i=n.deserialize(e.links),t=new Map,e.metadata&&Object.entries(e.metadata).forEach(([a,r])=>{t?.set(a,r)}),s=l.deserializeCollections(e);else return;if(!(!i||i.items.length===0))return new l({metadata:t?.size?t:void 0,links:i,subcollections:s?.size?s:void 0})}static deserializeCollections(e){if(!e)return;const i=new Map;return Object.entries(e).forEach(([t,s])=>{if(t!=="links"&&t!=="metadata"){const a=l.deserialize(s);if(a){const r=new Array;r.push(a),i.set(t,r)}else if(Array.isArray(s)){const r=s.map(c=>l.deserialize(c)).filter(c=>c!==void 0);i.set(t,r)}}}),i.size?i:void 0}serialize(){const e={};return this.metadata&&(e.metadata={},this.metadata.forEach((i,t)=>e.metadata[t]=i)),this.links.items.length&&(e.links=this.links.serialize()),l.serializeCollection(e,this.subcollections),e}static serializeCollection(e,i){i&&i.size>0&&i.forEach((t,s)=>{t.length===1?e[s]=t[0].serialize():e[s]=t.map(a=>a.serialize())})}}export{l as PublicationCollection};
@@ -0,0 +1 @@
1
+ import{Page as t}from"./Properties.js";var l=(r=>(r.ltr="ltr",r.rtl="rtl",r))(l||{});function a(r){return r==="rtl"?t.right:t.left}export{l as ReadingProgression,a as leadingPage};
@@ -0,0 +1 @@
1
+ import{Links as c}from"./Link.js";import{LocalizedString as r}from"./LocalizedString.js";class i{constructor(e){this.name=e.name,this.sortAs=e.sortAs,this.code=e.code,this.scheme=e.scheme,this.links=e.links}static deserialize(e){if(e)return typeof e=="string"?new i({name:r.deserialize(e)}):e.name?new i({name:r.deserialize(e.name),sortAs:e.sortAs?r.deserialize(e.sortAs):void 0,code:e.code,scheme:e.scheme,links:c.deserialize(e.links)}):void 0}serialize(){const e={name:this.name.serialize()};return this.sortAs!==void 0&&(e.sortAs=this.sortAs.serialize()),this.code!==void 0&&(e.code=this.code),this.scheme!==void 0&&(e.scheme=this.scheme),this.links&&(e.links=this.links.serialize()),e}}class t{constructor(e){this.items=e}static deserialize(e){if(!e)return;const a=Array.isArray(e)?e:[e];return new t(a.map(s=>i.deserialize(s)).filter(s=>s!==void 0))}serialize(){return this.items.map(e=>e.serialize())}}export{i as Subject,t as Subjects};
@@ -0,0 +1 @@
1
+ var t=(r=>(r.all="all",r.none="none",r))(t||{});class e{constructor(i){this.reservation=i.reservation,this.policy=i.policy}static deserialize(i){if(i)return new e({reservation:i.reservation,policy:i.policy})}serialize(){const i={};return this.reservation!==void 0&&(i.reservation=this.reservation),this.policy!==void 0&&(i.policy=this.policy),i}}export{e as TDM,t as TDMReservation};
@@ -0,0 +1 @@
1
+ class O{constructor(i={}){this.conformsTo=i.conformsTo??[],this.certification=i.certification??null,this.summary=i.summary??null,this.accessMode=i.accessMode??[],this.accessModeSufficient=i.accessModeSufficient??[],this.feature=i.feature??[],this.hazard=i.hazard??[],this.exemption=i.exemption??[]}static deserialize(i){if(!i||typeof i!="object")return;const a=i;return new O({conformsTo:a.conformsTo?a.conformsTo.map(e=>c.deserialize(e)).filter(e=>e!==void 0):void 0,certification:a.certification?I.deserialize(a.certification):void 0,summary:a.summary,accessMode:a.accessMode?a.accessMode.map(e=>w.deserialize(e)).filter(e=>e!==void 0):void 0,accessModeSufficient:a.accessModeSufficient?a.accessModeSufficient.map(e=>o.deserialize(e)).filter(e=>e!==void 0):void 0,feature:a.feature?a.feature.map(e=>T.deserialize(e)).filter(e=>e!==void 0):void 0,hazard:a.hazard?a.hazard.map(e=>l.deserialize(e)).filter(e=>e!==void 0):void 0,exemption:a.exemption?a.exemption.map(e=>N.deserialize(e)).filter(e=>e!==void 0):void 0})}serialize(){const i={};return this.conformsTo?.length>0&&(i.conformsTo=this.conformsTo.map(a=>a.serialize())),this.certification!==void 0&&this.certification!==null&&(i.certification=this.certification.serialize()),this.summary!==void 0&&this.summary!==null&&(i.summary=this.summary),this.accessMode?.length>0&&(i.accessMode=this.accessMode.map(a=>a.serialize())),this.accessModeSufficient?.length>0&&(i.accessModeSufficient=this.accessModeSufficient.map(a=>a.serialize())),this.feature?.length>0&&(i.feature=this.feature.map(a=>a.serialize())),this.hazard?.length>0&&(i.hazard=this.hazard.map(a=>a.serialize())),this.exemption?.length>0&&(i.exemption=this.exemption.map(a=>a.serialize())),i}}const s=class s{constructor(i){this.uri=i}static deserialize(i){if(!(!i||typeof i!="string"))return new s(i)}serialize(){return this.uri}get isWCAGLevelA(){return this===s.EPUB_A11Y_10_WCAG_20_A||this===s.EPUB_A11Y_11_WCAG_20_A||this===s.EPUB_A11Y_11_WCAG_21_A||this===s.EPUB_A11Y_11_WCAG_22_A}get isWCAGLevelAA(){return this===s.EPUB_A11Y_10_WCAG_20_AA||this===s.EPUB_A11Y_11_WCAG_20_AA||this===s.EPUB_A11Y_11_WCAG_21_AA||this===s.EPUB_A11Y_11_WCAG_22_AA}get isWCAGLevelAAA(){return this===s.EPUB_A11Y_10_WCAG_20_AAA||this===s.EPUB_A11Y_11_WCAG_20_AAA||this===s.EPUB_A11Y_11_WCAG_21_AAA||this===s.EPUB_A11Y_11_WCAG_22_AAA}};s.EPUB_A11Y_10_WCAG_20_A=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"),s.EPUB_A11Y_10_WCAG_20_AA=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"),s.EPUB_A11Y_10_WCAG_20_AAA=new s("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"),s.EPUB_A11Y_11_WCAG_20_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"),s.EPUB_A11Y_11_WCAG_20_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"),s.EPUB_A11Y_11_WCAG_20_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"),s.EPUB_A11Y_11_WCAG_21_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"),s.EPUB_A11Y_11_WCAG_21_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"),s.EPUB_A11Y_11_WCAG_21_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"),s.EPUB_A11Y_11_WCAG_22_A=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"),s.EPUB_A11Y_11_WCAG_22_AA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"),s.EPUB_A11Y_11_WCAG_22_AAA=new s("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");let c=s;class I{constructor(i=null,a=null,e=null){this.certifiedBy=i,this.credential=a,this.report=e}static deserialize(i){if(!(!i||typeof i!="object"))return new I(i.certifiedBy,i.credential,i.report)}serialize(){const i={};return this.certifiedBy&&(i.certifiedBy=this.certifiedBy),this.credential&&(i.credential=this.credential),this.report&&(i.report=this.report),i}}const n=class n{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new n(i)}serialize(){return this.value}};n.AUDITORY=new n("auditory"),n.CHART_ON_VISUAL=new n("chartOnVisual"),n.CHEM_ON_VISUAL=new n("chemOnVisual"),n.COLOR_DEPENDENT=new n("colorDependent"),n.DIAGRAM_ON_VISUAL=new n("diagramOnVisual"),n.MATH_ON_VISUAL=new n("mathOnVisual"),n.MUSIC_ON_VISUAL=new n("musicOnVisual"),n.TACTILE=new n("tactile"),n.TEXT_ON_VISUAL=new n("textOnVisual"),n.TEXTUAL=new n("textual"),n.VISUAL=new n("visual");let w=n;const r=class r{constructor(i){if(typeof i=="string"){if(!r.VALID_MODES.has(i.toLowerCase()))return;this.value=i.toLowerCase()}else{const a=i.filter(e=>r.VALID_MODES.has(e.toLowerCase()));if(a.length===0)return;this.value=Array.from(new Set(a))}}static deserialize(i){if(!i)return;if(typeof i=="string")return new r(i);if(!Array.isArray(i))return;const a=i.filter(e=>e?r.VALID_MODES.has(e.toLowerCase()):!1);if(a.length!==0)return new r(a)}serialize(){return this.value}};r.VALID_MODES=new Set(["auditory","tactile","textual","visual"]),r.AUDITORY=new r("auditory"),r.TACTILE=new r("tactile"),r.TEXTUAL=new r("textual"),r.VISUAL=new r("visual");let o=r;const t=class t{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new t(i)}serialize(){return this.value}};t.NONE=new t("none"),t.ANNOTATIONS=new t("annotations"),t.ARIA=new t("ARIA"),t.INDEX=new t("index"),t.PAGE_BREAK_MARKERS=new t("pageBreakMarkers"),t.PAGE_NAVIGATION=new t("pageNavigation"),t.PRINT_PAGE_NUMBERS=new t("printPageNumbers"),t.READING_ORDER=new t("readingOrder"),t.STRUCTURAL_NAVIGATION=new t("structuralNavigation"),t.TABLE_OF_CONTENTS=new t("tableOfContents"),t.TAGGED_PDF=new t("taggedPDF"),t.ALTERNATIVE_TEXT=new t("alternativeText"),t.AUDIO_DESCRIPTION=new t("audioDescription"),t.CAPTIONS=new t("captions"),t.CLOSED_CAPTIONS=new t("closedCaptions"),t.DESCRIBED_MATH=new t("describedMath"),t.LONG_DESCRIPTION=new t("longDescription"),t.OPEN_CAPTIONS=new t("openCaptions"),t.SIGN_LANGUAGE=new t("signLanguage"),t.TRANSCRIPT=new t("transcript"),t.DISPLAY_TRANSFORMABILITY=new t("displayTransformability"),t.SYNCHRONIZED_AUDIO_TEXT=new t("synchronizedAudioText"),t.TIMING_CONTROL=new t("timingControl"),t.UNLOCKED=new t("unlocked"),t.CHEM_ML=new t("ChemML"),t.LATEX=new t("latex"),t.LATEX_CHEMISTRY=new t("latex-chemistry"),t.MATH_ML=new t("MathML"),t.MATH_ML_CHEMISTRY=new t("MathML-chemistry"),t.TTS_MARKUP=new t("ttsMarkup"),t.HIGH_CONTRAST_AUDIO=new t("highContrastAudio"),t.HIGH_CONTRAST_DISPLAY=new t("highContrastDisplay"),t.LARGE_PRINT=new t("largePrint"),t.BRAILLE=new t("braille"),t.TACTILE_GRAPHIC=new t("tactileGraphic"),t.TACTILE_OBJECT=new t("tactileObject"),t.FULL_RUBY_ANNOTATIONS=new t("fullRubyAnnotations"),t.HORIZONTAL_WRITING=new t("horizontalWriting"),t.RUBY_ANNOTATIONS=new t("rubyAnnotations"),t.VERTICAL_WRITING=new t("verticalWriting"),t.WITH_ADDITIONAL_WORD_SEGMENTATION=new t("withAdditionalWordSegmentation"),t.WITHOUT_ADDITIONAL_WORD_SEGMENTATION=new t("withoutAdditionalWordSegmentation");let T=t;const h=class h{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new h(i)}serialize(){return this.value}};h.FLASHING=new h("flashing"),h.NO_FLASHING_HAZARD=new h("noFlashingHazard"),h.UNKNOWN_FLASHING_HAZARD=new h("unknownFlashingHazard"),h.MOTION_SIMULATION=new h("motionSimulation"),h.NO_MOTION_SIMULATION_HAZARD=new h("noMotionSimulationHazard"),h.UNKNOWN_MOTION_SIMULATION_HAZARD=new h("unknownMotionSimulationHazard"),h.SOUND=new h("sound"),h.NO_SOUND_HAZARD=new h("noSoundHazard"),h.UNKNOWN_SOUND_HAZARD=new h("unknownSoundHazard"),h.UNKNOWN=new h("unknown"),h.NONE=new h("none");let l=h;const A=class A{constructor(i){this.value=i}static deserialize(i){if(!(!i||typeof i!="string"))return new A(i)}serialize(){return this.value}};A.NONE=new A("none"),A.DOCUMENTED=new A("documented"),A.LEGAL=new A("legal"),A.TEMPORARY=new A("temporary"),A.TECHNICAL=new A("technical"),A.EAA_DISPROPORTIONATE_BURDEN=new A("eaa-disproportionate-burden"),A.EAA_FUNDAMENTAL_ALTERATION=new A("eaa-fundamental-alteration"),A.EAA_MICROENTERPRISE=new A("eaa-microenterprise"),A.EAA_TECHNICAL_IMPOSSIBILITY=new A("eaa-technical-impossibility"),A.EAA_TEMPORARY=new A("eaa-temporary");let N=A;export{w as AccessMode,O as Accessibility,c as AccessibilityProfile,I as Certification,N as Exemption,T as Feature,l as Hazard,o as PrimaryAccessMode};
@@ -0,0 +1 @@
1
+ import{Accessibility as L,Feature as m,AccessMode as v,Hazard as f}from"./Accessibility.js";import{Localization as s}from"./Localization.js";import{Layout as _}from"../Layout.js";var U=(d=>(d.Unknown="unknown",d.Modifiable="modifiable",d.Unmodifiable="unmodifiable",d))(U||{}),D=(d=>(d.NoMetadata="noMetadata",d.Readable="readable",d.NotFully="notFully",d.Unreadable="unreadable",d))(D||{}),z=(d=>(d.NoMetadata="noMetadata",d.Synchronized="synchronized",d.AudioOnly="audioOnly",d.AudioComplementary="audioComplementary",d))(z||{});class w{constructor(e="unknown",c="noMetadata",t=!1,i="noMetadata"){this.id="ways-of-reading.title",this.visualAdjustments=e,this.nonvisualReading=c,this.nonvisualReadingAltText=t,this.prerecordedAudio=i,this.shouldDisplay=!0;const n=s.getString(this.id);this.title=n.compact,this.statements=[];const r=e==="modifiable"?"ways-of-reading.visual-adjustments.modifiable":e==="unmodifiable"?"ways-of-reading.visual-adjustments.unmodifiable":"ways-of-reading.visual-adjustments.unknown",l=s.getString(r);this.statements.push({id:r,compactString:l.compact,descriptiveString:l.descriptive});let u="";c==="readable"?u="ways-of-reading.nonvisual-reading.readable":c==="notFully"?u="ways-of-reading.nonvisual-reading.not-fully":c==="unreadable"?u="ways-of-reading.nonvisual-reading.none":c==="noMetadata"&&(u="ways-of-reading.nonvisual-reading.no-metadata");const p=s.getString(u);if(this.statements.push({id:u,compactString:p.compact,descriptiveString:p.descriptive}),t){const S=s.getString("ways-of-reading.nonvisual-reading.alt-text");this.statements.push({id:"ways-of-reading.nonvisual-reading.alt-text",compactString:S.compact,descriptiveString:S.descriptive})}let g="";i==="synchronized"?g="ways-of-reading.prerecorded-audio.synchronized":i==="audioOnly"?g="ways-of-reading.prerecorded-audio.only":i==="audioComplementary"?g="ways-of-reading.prerecorded-audio.complementary":i==="noMetadata"&&(g="ways-of-reading.prerecorded-audio.no-metadata");const o=s.getString(g);this.statements.push({id:g,compactString:o.compact,descriptiveString:o.descriptive})}static fromPublication(e){const c=e.metadata.accessibility??new L,t=c.feature??[],i=e.metadata.layout===_.fixed,n=t.some(a=>a.value===m.DISPLAY_TRANSFORMABILITY.value)?"modifiable":i?"unmodifiable":"unknown",r=c.accessMode??[],l=c.accessModeSufficient??[],u=r.length>0&&r.every(a=>a.value===v.TEXTUAL.value)||l.some(a=>{const h=a.value;return Array.isArray(h)?h.every(y=>y===v.TEXTUAL.value):h===v.TEXTUAL.value}),p=r.some(a=>a.value===v.TEXTUAL.value)||l.some(a=>{const h=a.value;return Array.isArray(h)?h.some(y=>y===v.TEXTUAL.value):h===v.TEXTUAL.value}),g=!(r.length===0&&l.length===0)&&!r.some(a=>a.value===v.TEXTUAL.value)&&!l.some(a=>{const h=a.value;return Array.isArray(h)?h.some(y=>y===v.TEXTUAL.value):h===v.TEXTUAL.value}),o=t.some(a=>[m.LONG_DESCRIPTION.value,m.ALTERNATIVE_TEXT.value,m.DESCRIBED_MATH.value,m.TRANSCRIPT.value].includes(a.value)),S=u?"readable":p||o?"notFully":g?"unreadable":"noMetadata",b=o,A=t.some(a=>a.value===m.SYNCHRONIZED_AUDIO_TEXT.value)?"synchronized":l.some(a=>{const h=a.value;return Array.isArray(h)?h.some(y=>y===v.AUDITORY.value):h===v.AUDITORY.value})?"audioOnly":r.some(a=>a.value===v.AUDITORY.value)?"audioComplementary":"noMetadata";return new w(n,S,b,A)}}class T{constructor(e=!1,c=!1,t=!1,i=!1){this.id="navigation.title",this.tableOfContents=e,this.index=c,this.headings=t,this.page=i,this.noMetadata=!e&&!c&&!t&&!i;const n=s.getString(this.id);if(this.title=n.compact,this.shouldDisplay=!this.noMetadata,this.statements=[],e){const r=s.getString("navigation.toc");this.statements.push({id:"navigation.toc",compactString:r.compact,descriptiveString:r.descriptive})}if(c){const r=s.getString("navigation.index");this.statements.push({id:"navigation.index",compactString:r.compact,descriptiveString:r.descriptive})}if(t){const r=s.getString("navigation.structural");this.statements.push({id:"navigation.structural",compactString:r.compact,descriptiveString:r.descriptive})}if(i){const r=s.getString("navigation.page-navigation");this.statements.push({id:"navigation.page-navigation",compactString:r.compact,descriptiveString:r.descriptive})}if(this.statements.length===0){const r=s.getString("navigation.no-metadata");this.statements.push({id:"navigation.no-metadata",compactString:r.compact,descriptiveString:r.descriptive})}}static fromPublication(e){const t=(e.metadata.accessibility??new L).feature??[];return new T(t.some(i=>i.value===m.TABLE_OF_CONTENTS.value),t.some(i=>i.value===m.INDEX.value),t.some(i=>i.value===m.STRUCTURAL_NAVIGATION.value),t.some(i=>i.value===m.PAGE_NAVIGATION.value))}}var R=(d=>(d.Math="math",d.Chemistry="chemistry",d.Music="music",d.Diagram="diagram",d.Chart="chart",d.Graph="graph",d.Table="table",d.Image="image",d))(R||{});class N{constructor(e=!1,c=!1,t=!1,i=!1,n=!1,r=!1,l=!1,u=!1,p=!1){this.id="rich-content.title",this.extendedAltTextDescriptions=e,this.mathFormula=c,this.mathFormulaAsMathML=t,this.mathFormulaAsLaTeX=i,this.chemicalFormulaAsMathML=n,this.chemicalFormulaAsLaTeX=r,this.closedCaptions=l,this.openCaptions=u,this.transcript=p,this.noMetadata=!e&&!c&&!t&&!i&&!n&&!r&&!l&&!u&&!p,this.shouldDisplay=!this.noMetadata;const g=s.getString(this.id);if(this.title=g.compact,this.statements=[],e){const o=s.getString("rich-content.extended-descriptions");this.statements.push({id:"rich-content.extended-descriptions",compactString:o.compact,descriptiveString:o.descriptive})}if(c){const o=s.getString("rich-content.accessible-math-described");this.statements.push({id:"rich-content.accessible-math-described",compactString:o.compact,descriptiveString:o.descriptive})}if(t){const o=s.getString("rich-content.math-as-mathml");this.statements.push({id:"rich-content.math-as-mathml",compactString:o.compact,descriptiveString:o.descriptive})}if(i){const o=s.getString("rich-content.accessible-math-as-latex");this.statements.push({id:"rich-content.accessible-math-as-latex",compactString:o.compact,descriptiveString:o.descriptive})}if(n){const o=s.getString("rich-content.accessible-chemistry-as-mathml");this.statements.push({id:"rich-content.accessible-chemistry-as-mathml",compactString:o.compact,descriptiveString:o.descriptive})}if(r){const o=s.getString("rich-content.accessible-chemistry-as-latex");this.statements.push({id:"rich-content.accessible-chemistry-as-latex",compactString:o.compact,descriptiveString:o.descriptive})}if(l){const o=s.getString("rich-content.closed-captions");this.statements.push({id:"rich-content.closed-captions",compactString:o.compact,descriptiveString:o.descriptive})}if(u){const o=s.getString("rich-content.open-captions");this.statements.push({id:"rich-content.open-captions",compactString:o.compact,descriptiveString:o.descriptive})}if(p){const o=s.getString("rich-content.transcript");this.statements.push({id:"rich-content.transcript",compactString:o.compact,descriptiveString:o.descriptive})}if(this.statements.length===0){const o=s.getString("rich-content.unknown");this.statements.push({id:"rich-content.unknown",compactString:o.compact,descriptiveString:o.descriptive})}}static fromPublication(e){const t=(e.metadata.accessibility??new L).feature??[];return new N(t.some(i=>i.value===m.LONG_DESCRIPTION.value),t.some(i=>i.value===m.DESCRIBED_MATH.value),t.some(i=>i.value===m.MATH_ML.value),t.some(i=>i.value===m.LATEX.value),t.some(i=>i.value===m.MATH_ML_CHEMISTRY.value),t.some(i=>i.value===m.LATEX_CHEMISTRY.value),t.some(i=>i.value===m.CLOSED_CAPTIONS.value),t.some(i=>i.value===m.OPEN_CAPTIONS.value),t.some(i=>i.value===m.TRANSCRIPT.value))}}class I{constructor(e=!1,c=!1,t=!1,i=!1,n=!1,r=!1,l=!1,u=!1,p=!1,g=!1,o=!1,S=!1,b=!1){this.id="additional-accessibility-information.title",this.pageBreakMarkers=e,this.aria=c,this.audioDescriptions=t,this.braille=i,this.rubyAnnotations=n,this.fullRubyAnnotations=r,this.highAudioContrast=l,this.highDisplayContrast=u,this.largePrint=p,this.signLanguage=g,this.tactileGraphics=o,this.tactileObjects=S,this.textToSpeechHinting=b,this.noMetadata=!e&&!c&&!t&&!i&&!n&&!r&&!l&&!u&&!p&&!g&&!o&&!S&&!b,this.shouldDisplay=!this.noMetadata;const A=s.getString(this.id);if(this.title=A.compact,this.statements=[],e){const a=s.getString("additional-accessibility-information.page-breaks");this.statements.push({id:"additional-accessibility-information.page-breaks",compactString:a.compact,descriptiveString:a.descriptive})}if(c){const a=s.getString("additional-accessibility-information.aria");this.statements.push({id:"additional-accessibility-information.aria",compactString:a.compact,descriptiveString:a.descriptive})}if(t){const a=s.getString("additional-accessibility-information.audio-descriptions");this.statements.push({id:"additional-accessibility-information.audio-descriptions",compactString:a.compact,descriptiveString:a.descriptive})}if(i){const a=s.getString("additional-accessibility-information.braille");this.statements.push({id:"additional-accessibility-information.braille",compactString:a.compact,descriptiveString:a.descriptive})}if(n){const a=s.getString("additional-accessibility-information.ruby-annotations");this.statements.push({id:"additional-accessibility-information.ruby-annotations",compactString:a.compact,descriptiveString:a.descriptive})}if(r){const a=s.getString("additional-accessibility-information.full-ruby-annotations");this.statements.push({id:"additional-accessibility-information.full-ruby-annotations",compactString:a.compact,descriptiveString:a.descriptive})}if(l){const a=s.getString("additional-accessibility-information.high-contrast-between-foreground-and-background-audio");this.statements.push({id:"additional-accessibility-information.high-contrast-between-foreground-and-background-audio",compactString:a.compact,descriptiveString:a.descriptive})}if(u){const a=s.getString("additional-accessibility-information.high-contrast-between-text-and-background");this.statements.push({id:"additional-accessibility-information.high-contrast-between-text-and-background",compactString:a.compact,descriptiveString:a.descriptive})}if(p){const a=s.getString("additional-accessibility-information.large-print");this.statements.push({id:"additional-accessibility-information.large-print",compactString:a.compact,descriptiveString:a.descriptive})}if(g){const a=s.getString("additional-accessibility-information.sign-language");this.statements.push({id:"additional-accessibility-information.sign-language",compactString:a.compact,descriptiveString:a.descriptive})}if(o){const a=s.getString("additional-accessibility-information.tactile-graphics");this.statements.push({id:"additional-accessibility-information.tactile-graphics",compactString:a.compact,descriptiveString:a.descriptive})}if(S){const a=s.getString("additional-accessibility-information.tactile-objects");this.statements.push({id:"additional-accessibility-information.tactile-objects",compactString:a.compact,descriptiveString:a.descriptive})}if(b){const a=s.getString("additional-accessibility-information.text-to-speech-hinting");this.statements.push({id:"additional-accessibility-information.text-to-speech-hinting",compactString:a.compact,descriptiveString:a.descriptive})}}static fromPublication(e){const t=(e.metadata.accessibility??new L).feature??[];return new I(t.some(i=>i.value===m.PAGE_BREAK_MARKERS.value||i.value===m.PRINT_PAGE_NUMBERS.value),t.some(i=>i.value===m.ARIA.value),t.some(i=>i.value===m.AUDIO_DESCRIPTION.value),t.some(i=>i.value===m.BRAILLE.value),t.some(i=>i.value===m.RUBY_ANNOTATIONS.value),t.some(i=>i.value===m.FULL_RUBY_ANNOTATIONS.value),t.some(i=>i.value===m.HIGH_CONTRAST_AUDIO.value),t.some(i=>i.value===m.HIGH_CONTRAST_DISPLAY.value),t.some(i=>i.value===m.LARGE_PRINT.value),t.some(i=>i.value===m.SIGN_LANGUAGE.value),t.some(i=>i.value===m.TACTILE_GRAPHIC.value),t.some(i=>i.value===m.TACTILE_OBJECT.value),t.some(i=>i.value===m.TTS_MARKUP.value))}}var x=(d=>(d.yes="yes",d.no="no",d.unknown="unknown",d.noMetadata="noMetadata",d))(x||{});class O{constructor(e="unknown",c="unknown",t="unknown"){this.id="hazards.title",this.flashing=e,this.motion=c,this.sound=t;const i=s.getString(this.id);if(this.title=i.compact,this.noMetadata=e==="noMetadata"&&c==="noMetadata"&&t==="noMetadata",this.noHazards=e==="no"&&c==="no"&&t==="no",this.unknown=e==="unknown"&&c==="unknown"&&t==="unknown",this.shouldDisplay=!this.noMetadata,this.statements=[],this.noHazards){const n=s.getString("hazards.none");this.statements.push({id:"hazards.none",compactString:n.compact,descriptiveString:n.descriptive})}else if(this.unknown){const n=s.getString("hazards.unknown");this.statements.push({id:"hazards.unknown",compactString:n.compact,descriptiveString:n.descriptive})}else if(this.noMetadata){const n=s.getString("hazards.no-metadata");this.statements.push({id:"hazards.no-metadata",compactString:n.compact,descriptiveString:n.descriptive})}else{if(e==="yes"){const n=s.getString("hazards.flashing");this.statements.push({id:"hazards.flashing",compactString:n.compact,descriptiveString:n.descriptive})}else if(e==="unknown"){const n=s.getString("hazards.flashing-unknown");this.statements.push({id:"hazards.flashing-unknown",compactString:n.compact,descriptiveString:n.descriptive})}else if(e==="no"){const n=s.getString("hazards.flashing-none");this.statements.push({id:"hazards.flashing-none",compactString:n.compact,descriptiveString:n.descriptive})}if(c==="yes"){const n=s.getString("hazards.motion");this.statements.push({id:"hazards.motion",compactString:n.compact,descriptiveString:n.descriptive})}else if(c==="unknown"){const n=s.getString("hazards.motion-unknown");this.statements.push({id:"hazards.motion-unknown",compactString:n.compact,descriptiveString:n.descriptive})}else if(c==="no"){const n=s.getString("hazards.motion-none");this.statements.push({id:"hazards.motion-none",compactString:n.compact,descriptiveString:n.descriptive})}if(t==="yes"){const n=s.getString("hazards.sound");this.statements.push({id:"hazards.sound",compactString:n.compact,descriptiveString:n.descriptive})}else if(t==="unknown"){const n=s.getString("hazards.sound-unknown");this.statements.push({id:"hazards.sound-unknown",compactString:n.compact,descriptiveString:n.descriptive})}else if(t==="no"){const n=s.getString("hazards.sound-none");this.statements.push({id:"hazards.sound-none",compactString:n.compact,descriptiveString:n.descriptive})}}}static fromPublication(e){const c=e.metadata.accessibility?.hazard??[];let t;c.some(l=>l.value===f.NONE.value)?t="no":c.some(l=>l.value===f.UNKNOWN.value)?t="unknown":t="noMetadata";let i;c.some(l=>l.value===f.FLASHING.value)?i="yes":c.some(l=>l.value===f.NO_FLASHING_HAZARD.value)?i="no":c.some(l=>l.value===f.UNKNOWN_FLASHING_HAZARD.value)?i="unknown":i=t;let n;c.some(l=>l.value===f.MOTION_SIMULATION.value)?n="yes":c.some(l=>l.value===f.NO_MOTION_SIMULATION_HAZARD.value)?n="no":c.some(l=>l.value===f.UNKNOWN_MOTION_SIMULATION_HAZARD.value)?n="unknown":n=t;let r;return c.some(l=>l.value===f.SOUND.value)?r="yes":c.some(l=>l.value===f.NO_SOUND_HAZARD.value)?r="no":c.some(l=>l.value===f.UNKNOWN_SOUND_HAZARD.value)?r="unknown":r=t,new O(i,n,r)}}class M{constructor(e=[]){this.id="conformance.title",this.profiles=e,this.shouldDisplay=!0;const c=s.getString(this.id);if(this.title=c.compact,this.statements=[],e.length===0){const t=s.getString("conformance.no");this.statements.push({id:"conformance.no",compactString:t.compact,descriptiveString:t.descriptive});return}if(e.some(t=>t.isWCAGLevelAAA)){const t=s.getString("conformance.aaa");this.statements.push({id:"conformance.aaa",compactString:t.compact,descriptiveString:t.descriptive})}else if(e.some(t=>t.isWCAGLevelAA)){const t=s.getString("conformance.aa");this.statements.push({id:"conformance.aa",compactString:t.compact,descriptiveString:t.descriptive})}else if(e.some(t=>t.isWCAGLevelA)){const t=s.getString("conformance.a");this.statements.push({id:"conformance.a",compactString:t.compact,descriptiveString:t.descriptive})}else{const t=s.getString("conformance.unknown-standard");this.statements.push({id:"conformance.unknown-standard",compactString:t.compact,descriptiveString:t.descriptive})}}static fromPublication(e){const c=e.metadata.accessibility?.conformsTo??[];return new M(c)}}class k{constructor(e=!1){this.id="legal-considerations.title",this.exemption=e,this.shouldDisplay=this.exemption;const c=s.getString(this.id);if(this.title=c.compact,this.statements=[],e){const t=s.getString("legal-considerations.exempt");this.statements.push({id:"legal-considerations.exempt",compactString:t.compact,descriptiveString:t.descriptive})}else{const t=s.getString("legal-considerations.no-metadata");this.statements.push({id:"legal-considerations.no-metadata",compactString:t.compact,descriptiveString:t.descriptive})}}static fromPublication(e){const t=(e.metadata.accessibility?.exemption??[]).length>0;return new k(t)}}class E{constructor(e){this.id="accessibility-summary.title",this.shouldDisplay=!0;const c=s.getString(this.id);this.title=c.compact;const t=e.metadata.accessibility?.summary;if(this.statements=[],this.shouldDisplay&&t)this.statements.push({id:"accessibility-summary.summary",compactString:t,descriptiveString:t});else{const i=s.getString("accessibility-summary.no-metadata");this.statements.push({id:"accessibility-summary.no-metadata",compactString:i.compact,descriptiveString:i.descriptive})}}static fromPublication(e){return new E(e)}}class H{constructor(e){this.waysOfReading=w.fromPublication(e),this.navigation=T.fromPublication(e),this.richContent=N.fromPublication(e),this.additionalInformation=I.fromPublication(e),this.hazards=O.fromPublication(e),this.conformance=M.fromPublication(e),this.legal=k.fromPublication(e),this.accessibilitySummary=E.fromPublication(e),this.fields=[this.waysOfReading,this.navigation,this.richContent,this.additionalInformation,this.hazards,this.conformance,this.legal,this.accessibilitySummary]}}export{H as AccessibilityMetadataDisplayGuide,E as AccessibilitySummary,I as AdditionalInformation,M as Conformance,x as HazardType,O as Hazards,k as Legal,T as Navigation,D as NonvisualReading,z as PrerecordedAudio,N as RichContent,R as RichContentType,U as VisualAdjustments,w as WaysOfReading};
@@ -0,0 +1 @@
1
+ import{__vitePreload as i}from"../../_virtual/preload-helper.js";import{SUPPORTED_LANGUAGES as a}from"./SupportedLanguages.js";import _ from"../../locales/publication-metadata/en.json.js";const n={ar:()=>i(()=>import("../../locales/publication-metadata/ar.json.js"),[]),da:()=>i(()=>import("../../locales/publication-metadata/da.json.js"),[]),el:()=>i(()=>import("../../locales/publication-metadata/el.json.js"),[]),es:()=>i(()=>import("../../locales/publication-metadata/es.json.js"),[]),et:()=>i(()=>import("../../locales/publication-metadata/et.json.js"),[]),fi:()=>i(()=>import("../../locales/publication-metadata/fi.json.js"),[]),fr:()=>i(()=>import("../../locales/publication-metadata/fr.json.js"),[]),it:()=>i(()=>import("../../locales/publication-metadata/it.json.js"),[]),pl:()=>i(()=>import("../../locales/publication-metadata/pl.json.js"),[]),pt_PT:()=>i(()=>import("../../locales/publication-metadata/pt_PT.json.js"),[]),sv:()=>i(()=>import("../../locales/publication-metadata/sv.json.js"),[])},c=_?.publication?.metadata?.accessibility?.["display-guide"]||{};class o{constructor(){this.currentLocaleCode="en",this.locale=c,this.loadedLocales={},this.loadedLocales.en=c}static getInstance(){return o.instance||(o.instance=new o),o.instance}async loadLocale(t){if(!a.includes(t))return console.warn(`Locale '${t}' is not enabled`),!1;if(t in this.loadedLocales)return!0;try{if(!(t in n))return console.warn(`Locale file not found for: ${t}`),!1;const r=(await n[t]()).default?.publication?.metadata?.accessibility?.["display-guide"];return r?(this.loadedLocales[t]=r,!0):(console.warn(`No accessibility strings found in locale ${t}`),!1)}catch(e){return console.warn(`Failed to load locale ${t}:`,e),!1}}registerLocale(t,e){if(!t||typeof t!="string")throw new Error("Locale code must be a non-empty string");this.loadedLocales[t]=e}async setLocale(t){return t in this.loadedLocales||await this.loadLocale(t),t in this.loadedLocales?(this.locale=this.loadedLocales[t],this.currentLocaleCode=t,!0):(console.warn(`Locale '${t}' is not available`),!1)}getCurrentLocale(){return this.currentLocaleCode}getAvailableLocales(){return a}getNestedValue(t,e){const s=e.split(".");let r=t;for(const l of s){if(r==null)return;r=r[l]}return r}getString(t){let e=this.getNestedValue(this.locale,t);return e===void 0&&this.currentLocaleCode!=="en"&&(e=this.getNestedValue(this.loadedLocales.en,t)),e!==void 0?typeof e=="string"?{compact:e,descriptive:e}:e:(console.warn(`Missing localization for key: ${t}`),{compact:"",descriptive:""})}}const f=o.getInstance();export{f as Localization};
@@ -0,0 +1 @@
1
+ const e=["en","ar","da","el","es","et","fi","fr","it","pl","pt_PT","sv"];export{e as SUPPORTED_LANGUAGES};
@@ -0,0 +1 @@
1
+ class e{constructor(i){this.algorithm=i.algorithm,this.compression=i.compression,this.originalLength=i.originalLength,this.profile=i.profile,this.scheme=i.scheme}static deserialize(i){if(i&&i.algorithm)return new e({algorithm:i.algorithm,compression:i.compression,originalLength:i.originalLength,profile:i.profile,scheme:i.scheme})}serialize(){const i={algorithm:this.algorithm};return this.compression!==void 0&&(i.compression=this.compression),this.originalLength!==void 0&&(i.originalLength=this.originalLength),this.profile!==void 0&&(i.profile=this.profile),this.scheme!==void 0&&(i.scheme=this.scheme),i}}export{e as Encryption};
@@ -0,0 +1 @@
1
+ import{Encryption as e}from"./Encryption.js";function n(r){return e.deserialize(r.otherProperties.encrypted)}export{n as getEncryption};
@@ -0,0 +1 @@
1
+ import{Encryption as t}from"./Encryption.js";import{getEncryption as p}from"./Properties.js";export{t as Encryption,p as getEncryption};
@@ -0,0 +1 @@
1
+ class a{constructor(s){this.activeClass=s.activeClass,this.playbackActiveClass=s.playbackActiveClass}static deserialize(s){if(s)return new a({activeClass:s.activeClass,playbackActiveClass:s.playbackActiveClass})}serialize(){const s={};return this.activeClass&&(s.activeClass=this.activeClass),this.playbackActiveClass&&(s.playbackActiveClass=this.playbackActiveClass),s}}export{a as MediaOverlay};
@@ -0,0 +1 @@
1
+ import{MediaOverlay as a}from"./MediaOverlay.js";function i(r){const e=r.otherMetadata?.mediaOverlay;if(e)return a.deserialize(e)}export{i as getMediaOverlay};
@@ -0,0 +1 @@
1
+ function e(t){return new Set(t.otherProperties.contains||[])}export{e as getContains};
@@ -0,0 +1 @@
1
+ function i(t){return t.linksWithRole("pageList")}function n(t){return t.linksWithRole("landmarks")}function e(t){return t.linksWithRole("loa")}function l(t){return t.linksWithRole("loi")}function o(t){return t.linksWithRole("lot")}function s(t){return t.linksWithRole("lov")}export{n as getLandmarks,e as getListOfAudioClips,l as getListOfIllustrations,o as getListOfTables,s as getListOfVideoClips,i as getPageList};
@@ -0,0 +1 @@
1
+ import{MediaOverlay as i}from"./MediaOverlay.js";import{getMediaOverlay as r}from"./Metadata.js";import{getContains as a}from"./Properties.js";import{getLandmarks as f,getListOfAudioClips as l,getListOfIllustrations as p,getListOfTables as L,getListOfVideoClips as O,getPageList as d}from"./Publication.js";export{i as MediaOverlay,a as getContains,f as getLandmarks,l as getListOfAudioClips,p as getListOfIllustrations,L as getListOfTables,O as getListOfVideoClips,r as getMediaOverlay,d as getPageList};
@@ -0,0 +1 @@
1
+ import{DomRangePoint as r}from"./DomRangePoint.js";class i{constructor(t){this.start=t.start,this.end=t.end}static deserialize(t){if(!t)return;let e=r.deserialize(t.start);if(e)return new i({start:e,end:r.deserialize(t.end)})}serialize(){const t={start:this.start.serialize()};return this.end&&(t.end=this.end.serialize()),t}}export{i as DomRange};
@@ -0,0 +1 @@
1
+ import{positiveNumberfromJSON as r}from"../../util/JSONParse.js";class c{constructor(e){this.cssSelector=e.cssSelector,this.textNodeIndex=e.textNodeIndex,this.charOffset=e.charOffset}static deserialize(e){if(!(e&&e.cssSelector))return;let s=r(e.textNodeIndex);if(s===void 0)return;let t=r(e.charOffset);return t===void 0&&(t=r(e.offset)),new c({cssSelector:e.cssSelector,textNodeIndex:s,charOffset:t})}serialize(){const e={cssSelector:this.cssSelector,textNodeIndex:this.textNodeIndex};return this.charOffset!==void 0&&(e.charOffset=this.charOffset),e}}export{c as DomRangePoint};
@@ -0,0 +1 @@
1
+ import{DomRange as u}from"./DomRange.js";import{parseNptTime as h}from"../../util/npt.js";function x(e){return e.otherLocations?.get("cssSelector")}function C(e){return e.otherLocations?.get("partialCfi")}function L(e){return u.deserialize(e.otherLocations?.get("domRange"))}function n(e){return new Map(e.fragments.map(t=>t.startsWith("#")?t.slice(1):t).join("&").split("&").filter(t=>!t.startsWith("#")).map(t=>t.split("=")).filter(t=>t.length===2).map(t=>[t[0].trim().toLowerCase(),t[1].trim()]))}function N(e){if(!e.fragments.length)return;let t=e.fragments.find(r=>r.length&&!r.includes("="));if(!t){const r=n(e);r.has("id")?t=r.get("id"):r.has("name")&&(t=r.get("name"))}return t?.startsWith("#")?t.slice(1):t}function W(e){const t=parseInt(n(e).get("page"));if(!isNaN(t)&&t>=0)return t}function R(e){const t=n(e).get("t");if(t)return h(t)}function y(e){const t=n(e);if(!t.has("xywh"))return;const r=t.get("xywh");let i="pixel",s=r;const o=r.toLowerCase();o.startsWith("pixel:")?s=r.slice(6):o.startsWith("percent:")&&(i="percent",s=r.slice(8));const c=i==="percent"?parseFloat:m=>parseInt(m,10),a=s.split(",").map(c);if(a.length!==4||a.some(isNaN))return;const[g,p,f,l]=a;return{unit:i,x:g,y:p,width:f,height:l}}export{x as getCssSelector,L as getDomRange,n as getFragmentParameters,N as getHtmlId,W as getPage,C as getPartialCfi,y as getSpace,R as getTime};
@@ -0,0 +1 @@
1
+ import{DomRange as g}from"./DomRange.js";import{DomRangePoint as r}from"./DomRangePoint.js";import{getCssSelector as m,getDomRange as n,getFragmentParameters as f,getHtmlId as i,getPage as p,getPartialCfi as P,getSpace as l,getTime as s}from"./Locations.js";export{g as DomRange,r as DomRangePoint,m as getCssSelector,n as getDomRange,f as getFragmentParameters,i as getHtmlId,p as getPage,P as getPartialCfi,l as getSpace,s as getTime};
@@ -0,0 +1 @@
1
+ import{positiveNumberfromJSON as t}from"../../util/JSONParse.js";import{Link as o}from"../Link.js";import{Price as n}from"../../opds/Price.js";import{Acquisition as s}from"../../opds/Acquisition.js";import{Holds as u}from"../../opds/Holds.js";import{Copies as m}from"../../opds/Copies.js";import{Availability as p}from"../../opds/Availability.js";function A(e){return t(e.otherProperties.numberOfItems)}function g(e){return n.deserialize(e.otherProperties.price)}function b(e){const r=e.otherProperties.indirectAcquisition;if(r&&Array.isArray(r))return r.map(i=>s.deserialize(i)).filter(i=>i!==void 0)}function z(e){return u.deserialize(e.otherProperties.holds)}function v(e){return m.deserialize(e.otherProperties.copies)}function y(e){return p.deserialize(e.otherProperties.availability)}function q(e){return o.deserialize(e.otherProperties.authenticate)}export{q as getAuthenticate,y as getAvailability,v as getCopies,z as getHolds,b as getIndirectAcquisitions,A as getNumberOfItems,g as getPrice};
@@ -0,0 +1 @@
1
+ function t(e){return e.linksWithRole("images")}export{t as getImages};
@@ -0,0 +1 @@
1
+ import{getAuthenticate as i,getAvailability as g,getCopies as o,getHolds as r,getIndirectAcquisitions as s,getNumberOfItems as m,getPrice as a}from"./Properties.js";import{getImages as f}from"./Publication.js";export{i as getAuthenticate,g as getAvailability,o as getCopies,r as getHolds,f as getImages,s as getIndirectAcquisitions,m as getNumberOfItems,a as getPrice};
@@ -0,0 +1,2 @@
1
+ class r{text(e=`
2
+ `){return this.elements().map(t=>t?.text).filter(t=>t!==void 0&&t.length>0).join(e)}elements(){const e=[],t=this.iterator();for(;t.hasNext();)e.push(t.next());return e}}export{r as Content};
@@ -0,0 +1 @@
1
+ import{Locator as c,LocatorText as x}from"../../Locator.js";import{DefaultTextContentTokenizer as l}from"../../../util/tokenizer/TextTokenizer.js";import{TextElement as i,TextSegment as h}from"./element/element.js";class p{constructor(t,e,o=50,n=r=>l(r,e)){this.defaultLanguage=t,this.contextSnippetLength=o,this.textTokenizerFactory=n}tokenize(t){return t instanceof i?[new i(t.locator,t.role,t.segments.map(e=>this.tokenizeSegment(e)).flat())]:[t]}tokenizeSegment(t){return this.textTokenizerFactory(t.language??this.defaultLanguage).tokenize(t.text).map(e=>new h(new c({href:t.locator.href,type:t.locator.type,title:t.locator.title,locations:t.locator.locations,text:this.extractTextContextIn(t.text,e)}),t.text.substring(e[0],e[1]),t._attributes))}extractTextContextIn(t,e){const o=t.substring(e[1],e[1]+this.contextSnippetLength),n=t.substring(e[0]-this.contextSnippetLength,e[0]);return new x({after:o.length>0?o:void 0,before:n.length>0?n:void 0,highlight:t.substring(e[0],e[1])})}}export{p as TextContentTokenizer};
@@ -0,0 +1 @@
1
+ class s extends Error{constructor(t){super(t)}}class e{async nextOrNull(){return await this.hasNext()?this.next():null}async previousOrNull(){return await this.hasPrevious()?this.previous():null}}export{s as IllegalStateError,e as Iterator};
@@ -0,0 +1 @@
1
+ class r{constructor(t,e){this.key=t,this.value=e}}var i=(a=>(a.ACCESSIBILITY_LABEL="accessibilityLabel",a.LANGUAGE="language",a))(i||{});class s{constructor(t=[]){this._attributes=t}get language(){return this.attribute("language")}get accessibilityLabel(){return this.attribute("accessibilityLabel")}attribute(t){return this._attributes.find(e=>e.key===t)?.value}attributes(t){return this._attributes.filter(e=>e.key===t).map(e=>e.value)}}export{r as Attribute,i as AttributeKeys,s as AttributesHolder};
@@ -0,0 +1 @@
1
+ import{AttributesHolder as i}from"./attributes.js";class c extends i{constructor(t,e=[]){super(e),this.locator=t}}class r extends c{get text(){return this.accessibilityLabel}}class d extends r{constructor(t,e,s=[]){super(t,s),this.embeddedLink=e}}class u extends r{constructor(t,e,s=[]){super(t,s),this.embeddedLink=e}}class a extends r{constructor(t,e,s,o=[]){super(t,o),this.embeddedLink=e,this.caption=s}get text(){return(this.caption?.length||0)>0?this.caption:super.text}}class x extends i{constructor(t,e,s=[]){super(s),this.locator=t,this.text=e}}class m extends r{constructor(t,e,s,o=[]){super(t,o),this.role=e,this.segments=s}get text(){return this.segments.map(t=>t.text).join("")}}export{d as AudioElement,c as ContentElement,a as ImageElement,m as TextElement,x as TextSegment,r as TextualElement,u as VideoElement};
@@ -0,0 +1 @@
1
+ class r{constructor(e){this.level=e}get role(){return`heading-${this.level}`}}const s={role:"body"},l={role:"footnote"};class n{constructor(e,o){this.referenceUrl=e,this.referenceTitle=o,this.role="quote"}}export{s as Body,l as Footnote,r as Heading,n as TextQuote};
@@ -0,0 +1 @@
1
+ import{Link as h,Links as A}from"../../../Link.js";import{Locator as u,LocatorLocations as p}from"../../../Locator.js";import{Iterator as L,IllegalStateError as d}from"../Iterator.js";import{trimmingTextLocator as w,isInlineTag as b,srcRelativeToHref as m,isBlank as f,elementLanguage as R,appendNormalizedWhitespace as S,trimUnicodeSpaceEnd as T,trimUnicodeSpace as y,trimUnicodeSpaceStart as N}from"./helpers.js";import{getCssSelector as I}from"../../../../node_modules/.pnpm/css-selector-generator@3.8.0/node_modules/css-selector-generator/esm/index.js";import{getCssSelector as C}from"../../../html/Locations.js";import{ImageElement as M,VideoElement as k,AudioElement as v,TextSegment as U,TextElement as H}from"../element/element.js";import{Attribute as x,AttributeKeys as E}from"../element/attributes.js";import{TextQuote as O,Heading as B,Body as D,Footnote as _}from"../element/text_role.js";class $ extends L{constructor(e,t,s=50){super(),this.resource=e,this.locator=t,this.beforeMaxLength=s,this.currentElement=null,this.currentIndex=null,this.parsedElementRecipes=null,this.parser=null}async hasPrevious(){if(this.currentElement?.delta===-1)return!0;const e=await this.elements(),t=(this.currentIndex??e.startIndex)-1,s=e.elements.at(t);return s?(this.currentIndex=t,this.currentElement={delta:-1,element:this.parser.executeRecipe(s)},!0):!1}previous(){if(!this.currentElement||this.currentElement.delta!==-1)throw new d("Called previous() without a successful call to hasPrevious() first");const e=this.currentElement.element;return this.currentElement=null,e}async hasNext(){if(this.currentElement?.delta===1)return!0;const e=await this.elements(),t=(this.currentIndex??e.startIndex-1)+1,s=e.elements.at(t);return s?(this.currentIndex=t,this.currentElement={delta:1,element:this.parser.executeRecipe(s)},!0):!1}next(){if(!this.currentElement||this.currentElement.delta!==1)throw new d("Called next() without a successful call to hasNext() first");const e=this.currentElement.element;return this.currentElement=null,e}async elements(){return this.parsedElementRecipes??=await this.parseElements(),this.parsedElementRecipes}async parseElements(){const e=await this.resource.readAsString(),t=new DOMParser().parseFromString(e,this.locator.type),s=C(this.locator.locations);return this.parser=new P(t,this.locator,s?t.querySelector(s):null,this.beforeMaxLength),G(this.parser,t.body),this.parser.result()}}function G(a,e){let t=e,s=0;for(;t!=null;)if(a.head(t,s),t.firstChild!=null)t=t.firstChild,s++;else{for(;t?.nextSibling==null&&s>0;)t&&a.tail(t,s),t=t?.parentNode||null,s--;if(t&&a.tail(t,s),t===e)break;t=t?.nextSibling||null}}class P{constructor(e,t,s,i){this.doc=e,this.baseLocator=t,this.startElement=s,this.beforeMaxLength=i,this.elementRecipes=[],this.startIndex=0,this.segmentRecipesAcc=[],this.textAcc="",this.wholeRawTextAcc=null,this.elementRawTextAcc="",this.rawTextAcc="",this.currentLanguage=null,this.breadcrumbs=[],this.recipeCssSelectorCache=new WeakMap}result(){return{elements:this.elementRecipes,startIndex:this.baseLocator.locations.progression===1?this.elementRecipes.length:this.startIndex}}executeRecipe(e){const t=e.recipe.cssSelectorNode?this.cssSelector(e.recipe.cssSelectorNode):null;if(e.type===1){const s=e.recipe;return new M(new u({href:this.baseLocator.href,type:this.baseLocator.type,title:this.baseLocator.title,locations:new p(t?{otherLocations:new Map([["cssSelector",t]])}:{})}),new h({href:s.href}),s.caption,s.attributes)}else if(e.type===2||e.type===3){const s=new u({href:this.baseLocator.href,type:this.baseLocator.type,title:this.baseLocator.title,locations:new p(t?{otherLocations:new Map([["cssSelector",t]])}:{})}),i=e.recipe;return e.type===3?new k(s,i.link):new v(s,i.link)}else if(e.type===0){const s=e.recipe,i=s.segments.map(r=>{const o=r.cssSelectorNode?this.cssSelector(r.cssSelectorNode):null;return new U(new u({href:this.baseLocator.href,type:this.baseLocator.type,title:this.baseLocator.title,text:w(r.text,this.wholeRawTextAcc?.substring(r.beforeRange[0],r.beforeRange[1])),locations:new p(o?{otherLocations:new Map([["cssSelector",o]])}:{})}),r.text,r.attributes)});return new H(new u({href:this.baseLocator.href,type:this.baseLocator.type,title:this.baseLocator.title,text:w(s.text,i.length&&i[0].locator.text?.before||""),locations:new p(t?{otherLocations:new Map([["cssSelector",t]])}:{})}),s.role,i)}else throw new Error("Unknown recipe type")}cssSelector(e){const t=e,s=this.recipeCssSelectorCache.get(t);if(s)return s;const i=new Map;let r=t;for(;r&&r!==this.doc.body;){for(let n=0;n<r.attributes.length;n++){const c=r.attributes[n];c.prefix&&(i.has(r)?i.set(r,i.get(r).concat([c])):i.set(r,[c]),r.attributes.removeNamedItem(c.name))}r=r.parentElement}const o=I(t,{root:this.doc});return i.forEach((n,c)=>n.forEach(l=>c.attributes.setNamedItem(l))),this.recipeCssSelectorCache.set(t,o),o}head(e,t){if(e.nodeType==Node.ELEMENT_NODE){const s=!b(e);s&&(this.flushText(),this.breadcrumbs.push(e));const i=e.nodeName.toUpperCase();if(i==="BR")this.flushText();else if(i==="IMG"||i==="AUDIO"||i==="VIDEO")if(this.flushText(),i==="IMG"){const r=e,o=m(r,this.baseLocator.href);let n=r.getAttribute("alt");n?.length||(n=r.getAttribute("title")),o!=null&&this.elementRecipes.push({type:1,recipe:{href:o,caption:void 0,cssSelectorNode:e,attributes:n?.length?[new x(E.ACCESSIBILITY_LABEL,n)]:[]}})}else{const r=e,o=m(r,this.baseLocator.href);let n;if(o!=null)n=new h({href:o});else{const c=[...r.getElementsByTagName("source")].map(l=>{const g=m(l,this.baseLocator.href);return g?new h({href:g,type:l.getAttribute("type")||void 0}):null}).filter(l=>!!l);c.length>0&&(n=new h({href:c[0].href,type:c[0].type,alternates:c.length>1?new A(c.slice(1)):void 0}))}n&&(i==="AUDIO"?this.elementRecipes.push({type:2,recipe:{cssSelectorNode:e,link:n}}):i==="VIDEO"&&this.elementRecipes.push({type:3,recipe:{cssSelectorNode:e,link:n}}))}s&&this.flushText()}}tail(e,t){if(e.nodeType===Node.TEXT_NODE&&!f(e.textContent)){const s=R(e.parentElement);this.currentLanguage!==s&&(this.flushSegment(),this.currentLanguage=s),this.rawTextAcc+=e.textContent,this.textAcc=S(this.textAcc,e.textContent)}else if(e.nodeType===Node.ELEMENT_NODE&&!b(e)){if(!this.breadcrumbs.length||this.breadcrumbs.at(-1)!==e)throw new Error("HTMLContentIterator: breadcrumbs mismatch");this.flushText(),this.breadcrumbs.pop()}}flushText(){if(this.flushSegment(),this.startIndex===0&&this.startElement&&this.breadcrumbs.length&&this.breadcrumbs.at(-1)===this.startElement&&(this.startIndex=this.elementRecipes.length),!this.segmentRecipesAcc.length)return;this.segmentRecipesAcc[this.segmentRecipesAcc.length-1].text=T(this.segmentRecipesAcc[this.segmentRecipesAcc.length-1].text);let e=D;if(this.breadcrumbs.length>0){const t=this.breadcrumbs.at(-1);if(t.getAttributeNS("http://www.idpf.org/2007/ops","type")==="footnote")e=_;else switch(t.nodeName.toUpperCase()){case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":e=new B(parseInt(t.nodeName[1]));break;case"BLOCKQUOTE":case"Q":e=new O(t.getAttribute("cite")?.length?new URL(t.getAttribute("cite")):void 0,t.getAttribute("title")||void 0);break}}this.elementRecipes.push({type:0,recipe:{text:this.elementRawTextAcc,role:e,segments:[...this.segmentRecipesAcc],cssSelectorNode:this.breadcrumbs.at(-1)}}),this.elementRawTextAcc="",this.segmentRecipesAcc=[]}flushSegment(){let e=this.textAcc;const t=y(e);if(!f(t)){if(!this.segmentRecipesAcc.length){e=N(e);const s=e.length&&f(e[e.length-1])?e[e.length-1]:"";e=t+s}this.segmentRecipesAcc.push({text:e,attributes:this.currentLanguage?[new x(E.LANGUAGE,this.currentLanguage)]:[],beforeRange:this.wholeRawTextAcc?[this.wholeRawTextAcc.length-this.beforeMaxLength,this.wholeRawTextAcc.length]:[0,0],cssSelectorNode:this.breadcrumbs.at(-1)})}this.rawTextAcc.length&&(this.wholeRawTextAcc=(this.wholeRawTextAcc||"")+this.rawTextAcc,this.elementRawTextAcc+=this.rawTextAcc),this.rawTextAcc="",this.textAcc=""}}export{$ as HTMLResourceContentIterator};
@@ -0,0 +1 @@
1
+ import{Locator as l}from"../../../Locator.js";import{Iterator as u,IllegalStateError as h}from"../Iterator.js";import{ContentElement as c}from"../element/element.js";class s extends c{constructor(e,t,r=[]){super(e,r),this.element=t}get text(){return this.element.text}}class o{constructor(e,t){this.element=e,this.direction=t}}class m extends u{constructor(e,t){super(),this.pageContent=e,this.startLocator=t,this.pageContentFiltered=[],this.currentElement=null,this.currentProgression=0,this.currentElementIndex=0;const r=this.pageContent.filter(n=>n?.str!==" "&&n?.str!=="");if(this.pageContentFiltered=r.map(n=>new s(n.locator,{index:r.indexOf(n),text:n.str,readingDirection:n.dir})),this.startLocator&&(this.currentProgression=this.startLocator?.locations?.progression||0,this.updateElementIndex()),this.pageContentFiltered.length>0){const n=this.currentElementIndex;(n||n===0)&&(this.currentElement=new o(this.pageContentFiltered[n],1))}}current(){return this.currentElement?this.currentElement.element:null}async hasPrevious(){return this.currentElement?.direction,this.nextIn(-1)!==null}previous(){if(!this.currentElement)throw new h("Called next() without a successful call to hasNext() first");if(this.currentElement=this.nextIn(-1),this.currentElementIndex&&this.currentElementIndex>0){const e=this.currentElementIndex-1;this.currentProgression=e/this.pageContentFiltered.length*100,this.currentElementIndex=e}return this.currentElement?this.currentElement.element:new s(new l({href:"",type:""}),{index:-1,text:""})}async hasNext(){return this.currentElement?.direction,this.nextIn(1)!==null}next(){this.currentElement=this.nextIn(1);const e=this.currentElementIndex;if(e!==null&&e>=0&&e<this.pageContentFiltered.length-1){const t=e+1;this.currentProgression=t/this.pageContentFiltered.length*100,this.currentElementIndex=t}return this.currentElement?this.currentElement.element:new s(new l({href:"",type:""}),{index:-1,text:""})}nextIn(e){const t=this.currentElementIndex;if(t===null||t===this.pageContentFiltered.length-1&&e===1||t===0&&e===-1)return null;const r=this.pageContentFiltered[t+e];return r?new o(r,e):null}updateElementIndex(){return this.currentProgression===0?0:this.currentProgression<0||this.currentProgression>=100?null:Math.floor(this.currentProgression*this.pageContentFiltered.length/100)}}export{s as PDFContentElement,m as PageContentIteratorPDF};
@@ -0,0 +1 @@
1
+ import{Iterator as c,IllegalStateError as o}from"../Iterator.js";class l{constructor(t,r){this.index=t,this.iterator=r}async nextContentIn(t){return t===1?this.iterator.nextOrNull():this.iterator.previousOrNull()}}class h{constructor(t,r){this.element=t,this.direction=r}}class f extends c{constructor(t,r,e){super(),this.publication=t,this.startLocator=r,this.resourceContentIteratorFactories=e,this._currentIterator=null,this.currentElement=null}async hasPrevious(){return this.currentElement=await this.nextIn(-1),this.currentElement!==null}previous(){if(this.currentElement?.direction!==-1)throw new o("Called previous() without a successful call to hasPrevious() first");return this.currentElement.element}async hasNext(){return this.currentElement=await this.nextIn(1),this.currentElement!==null}next(){if(this.currentElement?.direction!==1)throw new o("Called next() without a successful call to hasNext() first");return this.currentElement.element}async nextIn(t){const r=this.currentIterator;if(!r)return null;const e=await r.nextContentIn(t);if(!e){const n=this.nextIteratorIn(t,r.index);return n?(this._currentIterator=n,this.nextIn(t)):null}return new h(e,t)}get currentIterator(){return this._currentIterator||(this._currentIterator=this.initialIterator()),this._currentIterator}initialIterator(){const t=this.startLocator?this.publication.readingOrder.findIndexWithHref(this.startLocator.href):0,r=this.startLocator||0;return this.loadIteratorAt(t,r)??this.nextIteratorIn(1,t)}nextIteratorIn(t,r){const e=r+t;if(e<0||e>=this.publication.manifest.readingOrder.items.length)return null;const n=t===1?0:1;return this.loadIteratorAt(e,n)??this.nextIteratorIn(t,e)}loadIteratorAt(t,r){const e=this.publication.readingOrder.items[t],n=typeof r=="number"?this.publication.manifest.locatorFromLink(e)?.copyWithLocations({progression:r}):r;if(!n)return null;const a=this.publication.get(e);for(const u of this.resourceContentIteratorFactories){const s=u(a,n);if(s)return new l(t,s)}return null}}export{f as PublicationContentIterator};
@@ -0,0 +1 @@
1
+ import{LocatorText as g}from"../../../Locator.js";const A=["OBJECT","BASE","FONT","TT","I","B","U","BIG","SMALL","EM","STRONG","DFN","CODE","SAMP","KBD","VAR","CITE","ABBR","TIME","ACRONYM","MARK","RUBY","RT","RP","RTC","A","IMG","BR","WBR","MAP","Q","SUB","SUP","BDO","IFRAME","EMBED","SPAN","INPUT","SELECT","TEXTAREA","LABEL","BUTTON","OPTGROUP","OPTION","LEGEND","DATALIST","KEYGEN","OUTPUT","PROGRESS","METER","AREA","PARAM","SOURCE","TRACK","SUMMARY","COMMAND","DEVICE","BASEFONT","BGSOUND","MENUITEM","DATA","BDI","S","STRIKE","NOBR","RB"];function p(e){return A.includes(e.nodeName.toUpperCase())}function B(e,t){const n=e.getAttribute("src");if(!n?.length)return null;try{return new URL(n,t).toString()}catch{return n}}const i="[\\s\\u0085\\u00A0\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]",T=new RegExp(`^${i}+$`,"g"),s=new RegExp(`^${i}+|${i}+$/g`,"g"),l=new RegExp(`^${i}+`,"g"),E=new RegExp(`${i}+$`,"g"),R=e=>e?.length?T.test(e):!0,u=e=>e.replace(s,""),N=e=>e.replace(l,""),M=e=>e.replace(E,""),U=(e,t="")=>new g({before:t+(l.exec(e)?.[0]??""),highlight:u(e),after:E.exec(e)?.[0]??""});function h(e){for(;e;){let t=e.getAttribute("lang")||e.getAttributeNS("http://www.w3.org/1999/xhtml","lang")||e.getAttributeNS("http://www.w3.org/XML/1998/namespace","lang");if(t)return t;e=e.parentElement}return null}function O(e,t){const n=e.length>0&&e[e.length-1]===" ";let o=!1,c=!1;for(let r=0;r<t.length;r++)if(R(t[r])){if(n&&!c||o)continue;e+=" ",o=!0}else{const a=t.charCodeAt(r);a!==8203&&a!==173&&(e+=t[r],o=!1,c=!0)}return e}export{O as appendNormalizedWhitespace,h as elementLanguage,R as isBlank,p as isInlineTag,B as srcRelativeToHref,u as trimUnicodeSpace,M as trimUnicodeSpaceEnd,N as trimUnicodeSpaceStart,U as trimmingTextLocator};
@@ -0,0 +1 @@
1
+ import{getTime as g,getHtmlId as k}from"../../html/Locations.js";import{Profile as u}from"../../Profiles.js";import{isNptStartOfResource as v,formatNptTime as I,parseNptTime as T}from"../../../util/npt.js";class l{constructor(e,t,i=[],s=[],n=void 0){this._trimmedLinkMap=new Map,this._allItems=e,this.linkMap=t,this._conformsTo=i,this.tocLinks=s,this._tocDepth=n}static build(e,t={}){const i=e.toc?.items??[],s=e.readingOrder.items,{depth:n}=t,o=e.metadata?.conformsTo??[],r=new Map,c=[];for(let h=0;h<s.length;h++){const f=s[h],a=l.bareHref(f.href),p=f.title??l.findTitleInToc(i,a,n),d=l.collectChildrenFromToc(i,a,n,1,r),m={title:p,references:[f.href],children:d.length>0?d:void 0};r.set(m,f),c.push(m)}return new l(c,r,o,i,n)}augment(e){for(const t of this.flatAll){const i=this.linkFor(t);if(!i)continue;const s=e(t,i);s.position!==void 0&&(t.position=s.position),s.scroll!==void 0&&(t.scroll=s.scroll),s.role!==void 0&&(t.role=s.role)}}get depth(){return this._depth}set depth(e){this._depth!==e&&(this._depth=e,this._tocDepth=e,this._items=void 0,this._flat=void 0,this._toc=void 0)}get items(){return this._items||(this._depth!==void 0?(this._trimmedLinkMap=new Map,this._items=l.trimToDepth(this._allItems,this._depth,this.linkMap,this._trimmedLinkMap)):this._items=this._allItems),this._items}locate(e){const t=e.href.split("#")[0],i=g(e.locations),s=k(e.locations),n=e.locations.progression;if(i!==void 0){let o=-1/0,r;for(const c of this.flat){if(!this.itemMatchesHref(c,t))continue;const h=this.itemStartTime(c,t);h!==void 0&&h<=i&&h>o&&(o=h,r=c)}if(r)return r}if(s){const o=this.flat.find(r=>this.itemMatchesHref(r,t)?r.references.some(c=>c.split("#")[1]===s):!1);if(o)return o}if(n!==void 0){let o=-1/0,r;for(const h of this.flat){if(!this.itemMatchesHref(h,t))continue;const f=this.itemScrollPosition(h);f!==void 0&&f<=n&&f>o&&(o=f,r=h)}if(r)return r;const c=this.items.find(h=>this.itemMatchesHref(h,t));if(c?.children?.length&&!c.children.some(h=>h.scroll!==void 0)){const h=Math.min(Math.floor(n*c.children.length),c.children.length-1);return c.children[h]}}return this.flat.find(o=>this.itemMatchesHref(o,t))}adjacentTo(e){const t=this.flat.indexOf(e);return{previous:t>0?this.flat[t-1]:void 0,next:t>=0&&t<this.flat.length-1?this.flat[t+1]:void 0}}segmentsForHref(e){const t=e.split("#")[0],i=this.items.find(s=>this.itemMatchesHref(s,t));return i?i.children?.length?i.children:[i]:[]}ancestors(e){return this.ancestorPath(this.items,e)??[]}linkFor(e){return this.linkMap.get(e)??this._trimmedLinkMap.get(e)}get contextualizedToc(){return this._toc||(this._toc=this.tocLinks.length>0?this.buildTocEntries(this.tocLinks,this._tocDepth,1):this._allItems.map(e=>this.entryFor(this.linkFor(e),e))),this._toc}tocEntryFor(e){const t=this.linkFor(e);if(!t)return;const i=this.findTocEntryByLink(this.contextualizedToc,t);return i||this.nearestTocEntryForResource(t.href,e)}get flat(){return this._flat||(this._flat=this.flattenItems(this.items)),this._flat}get flatAll(){return this.flattenItems(this._allItems)}static findTitleInToc(e,t,i){const{atStart:s,fragments:n}=l.collectTocCandidates(e,t,i,1);if(s.length>0)return s[0].title;if(n.length===1)return n[0].title}static collectChildrenFromToc(e,t,i,s,n){if(i!==void 0&&s>i)return[];const o=[];for(const r of e){const c=l.bareHref(r.href);if((c===t||c==="")&&r.title&&!l.isStartOfResource(r.href)){const f=c===""?t+r.href:r.href,a={title:r.title,references:[f]};n.set(a,r),o.push(a)}r.children?.items?.length&&o.push(...l.collectChildrenFromToc(r.children.items,t,i,s+1,n))}return o}static collectTocCandidates(e,t,i,s){if(i!==void 0&&s>i)return{atStart:[],fragments:[]};const n=[],o=[];for(const r of e){const c=l.bareHref(r.href);if((c===t||c==="")&&r.title&&(l.isStartOfResource(r.href)?n.push(r):o.push(r)),r.children?.items?.length){const h=l.collectTocCandidates(r.children.items,t,i,s+1);n.push(...h.atStart),o.push(...h.fragments)}}return{atStart:n,fragments:o}}static isStartOfResource(e){const t=e.split("#")[1];if(!t)return!0;const i=t.match(/(?:^|&)t=([^&]+)/);return i!==null&&v(i[1])}get linkToItem(){if(!this._linkToItem){this._linkToItem=new Map;for(const[e,t]of this.linkMap)this._linkToItem.set(t,e)}return this._linkToItem}buildTocEntries(e,t,i){return t!==void 0&&i>t?[]:e.map(s=>{const n=this.linkToItem.get(s)??this.resourceStartItem(s.href),o=s.children?.items?.length?this.buildTocEntries(s.children.items,t,i+1):[];return{...this.entryFor(s,n),children:o.length>0?o:void 0}})}tocLinksFlat(e,t,i){if(t!==void 0&&i>t)return[];const s=[];for(const n of e)s.push(n),n.children?.items?.length&&s.push(...this.tocLinksFlat(n.children.items,t,i+1));return s}entryFor(e,t){const i=this._conformsTo.includes(u.AUDIOBOOK);return{link:e,position:!i&&t?.position!==void 0?String(t.position):void 0,timestamp:i&&t?.position!==void 0?I(t.position):void 0}}resourceStartItem(e){const t=l.bareHref(e);return this._allItems.find(i=>this.itemMatchesHref(i,t))}findTocEntryByLink(e,t){for(const i of e){if(i.link===t)return i;if(i.children){const s=this.findTocEntryByLink(i.children,t);if(s)return s}}}nearestTocEntryForResource(e,t){const i=l.bareHref(e),s=this.tocLinksFlat(this.tocLinks,this._tocDepth,1).filter(f=>l.bareHref(f.href)===i).map(f=>({link:f,item:this.linkToItem.get(f)??this.resourceStartItem(f.href)}));if(s.length===0)return;const n=this._conformsTo.includes(u.AUDIOBOOK),o=n?t.position??0:t.scroll??0;let r,c=-1/0;for(const f of s){const a=n?f.item?.position??0:f.item?.scroll??0;a<=o&&a>c&&(c=a,r=f)}const h=r??s[0];return this.findTocEntryByLink(this.contextualizedToc,h.link)}static trimToDepth(e,t,i,s){return e.map(n=>{const o={...n,children:t>1&&n.children?.length?l.trimToDepth(n.children,t-1,i,s):void 0},r=i.get(n);return r&&s.set(o,r),o})}flattenItems(e){const t=[];for(const i of e)t.push(i),i.children&&t.push(...this.flattenItems(i.children));return t}itemStartTime(e,t){for(const i of e.references){const s=i.indexOf("#"),n=s>=0?i.slice(0,s):i,o=s>=0?i.slice(s+1):void 0;if((n||t)!==t)continue;if(!o)return;const c=o.match(/(?:^|&)t=([^&]+)/);return c?T(c[1]):void 0}}itemMatchesHref(e,t){return e.references.some(i=>{const s=i.split("#")[0];return s===t||s===""})}ancestorPath(e,t){for(const i of e){if(i===t)return[];if(i.children){const s=this.ancestorPath(i.children,t);if(s!==null)return[i,...s]}}return null}itemScrollPosition(e){return e.scroll}static bareHref(e){return e.split("#")[0]}}export{l as Timeline};
@@ -0,0 +1 @@
1
+ import{parseNptTime as p}from"../../../util/npt.js";import{Timeline as g}from"./Timeline.js";function O(s,f){const o=g.build(s,f),r=s.readingOrder.items;if(!(r.length<=1||r.every(t=>t.duration!==void 0)))return o;let c=0;const d=new Map(r.map(t=>{const i=c;return c+=t.duration??0,[t.href,i]}));return o.augment((t,i)=>{const e=i.href,n=e.indexOf("#"),m=n>=0?e.slice(0,n):e,u=n>=0?e.slice(n+1):void 0,l=d.get(m)??0,a=u?.match(/(?:^|&)t=([^&]+)/),h=a?p(a[1]):void 0;return{position:l+(h??0)}}),o}export{O as buildAudioTimeline};
@@ -0,0 +1 @@
1
+ import{Timeline as l}from"./Timeline.js";function n(i,e){return l.build(i,e)}export{n as buildHtmlTimeline};
@@ -0,0 +1 @@
1
+ import{Profile as e}from"../../Profiles.js";import{buildAudioTimeline as m}from"./audio.js";import{buildHtmlTimeline as r}from"./html.js";function f(i,o){return i.metadata?.conformsTo?.includes(e.AUDIOBOOK)??!1?m(i,o):r(i,o)}export{m as buildAudioTimeline,r as buildHtmlTimeline,f as buildTimeline};
@@ -0,0 +1 @@
1
+ function n(r){return r&&Array.isArray(r)?r:void 0}function u(r){return r&&typeof r=="string"?[r]:n(r)}function o(r){return typeof r=="string"?new Date(r):void 0}function e(r){return isNaN(r)?void 0:r}function f(r){return e(r)!==void 0&&Math.sign(r)>=0?r:void 0}function a(r){const t=new Array;return r.forEach(i=>t.push(i)),t}export{n as arrayfromJSON,u as arrayfromJSONorString,o as datefromJSON,e as numberfromJSON,f as positiveNumberfromJSON,a as setToArray};
@@ -0,0 +1 @@
1
+ class i{constructor(t){this.uri=t,this.parameters=this.getParameters(t)}getParameters(t){const n=/\{\??([^}]+)\}/g,a=t.match(n);return a?new Set(a.join(",").replace(n,"$1").split(",").map(e=>e.trim())):new Set}expand(t){const n=e=>e.split(",").map(s=>{const r=t[s];return r?encodeURIComponent(r):""}).join(","),a=e=>"?"+e.split(",").map(s=>{const r=s.split("=")[0],o=t[r];return o?`${r}=${encodeURIComponent(o)}`:""}).join("&");return this.uri.replace(/\{(\??)([^}]+)\}/g,(...e)=>e[1]?a(e[2]):n(e[2]))}}export{i as URITemplate};
@@ -0,0 +1 @@
1
+ class t{constructor(e){let i,o,p=e.mediaType.replace(/\s/g,"").split(";");const s=p[0].split("/");if(s.length===2){if(i=s[0].toLowerCase().trim(),o=s[1].toLowerCase().trim(),i.length===0||o.length===0)throw new Error("Invalid media type")}else throw new Error("Invalid media type");const r={};for(let n=1;n<p.length;n++){const a=p[n].split("=");if(a.length===2){const u=a[0].toLocaleLowerCase(),f=u==="charset"?a[1].toUpperCase():a[1];r[u]=f}}const c={},m=Object.keys(r);m.sort((n,a)=>n.localeCompare(a)),m.forEach(n=>c[n]=r[n]);let l="";for(const n in c){const a=c[n];l+=`;${n}=${a}`}const g=`${i}/${o}${l}`,E=c.encoding;this.string=g,this.type=i,this.subtype=o,this.parameters=c,this.encoding=E,this.name=e.name,this.fileExtension=e.fileExtension}static parse(e){return new t(e)}get structuredSyntaxSuffix(){const e=this.subtype.split("+");return e.length>1?`+${e[e.length-1]}`:void 0}get charset(){return this.parameters.charset}contains(e){const i=typeof e=="string"?t.parse({mediaType:e}):e;if(!((this.type==="*"||this.type===i.type)&&(this.subtype==="*"||this.subtype===i.subtype)))return!1;const o=new Set(Object.entries(this.parameters).map(([s,r])=>`${s}=${r}`)),p=new Set(Object.entries(i.parameters).map(([s,r])=>`${s}=${r}`));for(const s of Array.from(o.values()))if(!p.has(s))return!1;return!0}matches(e){const i=typeof e=="string"?t.parse({mediaType:e}):e;return this.contains(i)||i.contains(this)}matchesAny(...e){for(const i of e)if(this.matches(i))return!0;return!1}equals(e){return this.string===e.string}get isZIP(){return this.matchesAny(t.ZIP,t.LCP_PROTECTED_AUDIOBOOK,t.LCP_PROTECTED_PDF)||this.structuredSyntaxSuffix==="+zip"}get isJSON(){return this.matchesAny(t.JSON)||this.structuredSyntaxSuffix==="+json"}get isOPDS(){return this.matchesAny(t.OPDS1,t.OPDS1_ENTRY,t.OPDS2,t.OPDS2_PUBLICATION,t.OPDS_AUTHENTICATION)||this.structuredSyntaxSuffix==="+json"}get isHTML(){return this.matchesAny(t.HTML,t.XHTML)}get isBitmap(){return this.matchesAny(t.AVIF,t.BMP,t.GIF,t.JPEG,t.PNG,t.TIFF,t.WEBP)}get isAudio(){return this.type==="audio"}get isVideo(){return this.type==="video"}get isRWPM(){return this.matchesAny(t.READIUM_AUDIOBOOK_MANIFEST,t.DIVINA_MANIFEST,t.READIUM_WEBPUB_MANIFEST)}get isPublication(){return this.matchesAny(t.READIUM_AUDIOBOOK,t.READIUM_AUDIOBOOK_MANIFEST,t.CBZ,t.DIVINA,t.DIVINA_MANIFEST,t.EPUB,t.LCP_PROTECTED_AUDIOBOOK,t.LCP_PROTECTED_PDF,t.LPF,t.PDF,t.W3C_WPUB_MANIFEST,t.READIUM_WEBPUB,t.READIUM_WEBPUB_MANIFEST,t.ZAB)}static get AAC(){return t.parse({mediaType:"audio/aac",fileExtension:"aac"})}static get ACSM(){return t.parse({mediaType:"application/vnd.adobe.adept+xml",name:"Adobe Content Server Message",fileExtension:"acsm"})}static get AIFF(){return t.parse({mediaType:"audio/aiff",fileExtension:"aiff"})}static get AVI(){return t.parse({mediaType:"video/x-msvideo",fileExtension:"avi"})}static get AVIF(){return t.parse({mediaType:"image/avif",fileExtension:"avif"})}static get BINARY(){return t.parse({mediaType:"application/octet-stream"})}static get BMP(){return t.parse({mediaType:"image/bmp",fileExtension:"bmp"})}static get CBZ(){return t.parse({mediaType:"application/vnd.comicbook+zip",name:"Comic Book Archive",fileExtension:"cbz"})}static get CSS(){return t.parse({mediaType:"text/css",fileExtension:"css"})}static get DIVINA(){return t.parse({mediaType:"application/divina+zip",name:"Digital Visual Narratives",fileExtension:"divina"})}static get DIVINA_MANIFEST(){return t.parse({mediaType:"application/divina+json",name:"Digital Visual Narratives",fileExtension:"json"})}static get EPUB(){return t.parse({mediaType:"application/epub+zip",name:"EPUB",fileExtension:"epub"})}static get GIF(){return t.parse({mediaType:"image/gif",fileExtension:"gif"})}static get GZ(){return t.parse({mediaType:"application/gzip",fileExtension:"gz"})}static get HTML(){return t.parse({mediaType:"text/html",fileExtension:"html"})}static get JAVASCRIPT(){return t.parse({mediaType:"text/javascript",fileExtension:"js"})}static get JPEG(){return t.parse({mediaType:"image/jpeg",fileExtension:"jpeg"})}static get JSON(){return t.parse({mediaType:"application/json"})}static get LCP_LICENSE_DOCUMENT(){return t.parse({mediaType:"application/vnd.readium.lcp.license.v1.0+json",name:"LCP License",fileExtension:"lcpl"})}static get LCP_PROTECTED_AUDIOBOOK(){return t.parse({mediaType:"application/audiobook+lcp",name:"LCP Protected Audiobook",fileExtension:"lcpa"})}static get LCP_PROTECTED_PDF(){return t.parse({mediaType:"application/pdf+lcp",name:"LCP Protected PDF",fileExtension:"lcpdf"})}static get LCP_STATUS_DOCUMENT(){return t.parse({mediaType:"application/vnd.readium.license.status.v1.0+json"})}static get LPF(){return t.parse({mediaType:"application/lpf+zip",fileExtension:"lpf"})}static get MP3(){return t.parse({mediaType:"audio/mpeg",fileExtension:"mp3"})}static get MPEG(){return t.parse({mediaType:"video/mpeg",fileExtension:"mpeg"})}static get NCX(){return t.parse({mediaType:"application/x-dtbncx+xml",fileExtension:"ncx"})}static get OGG(){return t.parse({mediaType:"audio/ogg",fileExtension:"oga"})}static get OGV(){return t.parse({mediaType:"video/ogg",fileExtension:"ogv"})}static get OPDS1(){return t.parse({mediaType:"application/atom+xml;profile=opds-catalog"})}static get OPDS1_ENTRY(){return t.parse({mediaType:"application/atom+xml;type=entry;profile=opds-catalog"})}static get OPDS2(){return t.parse({mediaType:"application/opds+json"})}static get OPDS2_PUBLICATION(){return t.parse({mediaType:"application/opds-publication+json"})}static get OPDS_AUTHENTICATION(){return t.parse({mediaType:"application/opds-authentication+json"})}static get OPUS(){return t.parse({mediaType:"audio/opus",fileExtension:"opus"})}static get OTF(){return t.parse({mediaType:"font/otf",fileExtension:"otf"})}static get PDF(){return t.parse({mediaType:"application/pdf",name:"PDF",fileExtension:"pdf"})}static get PNG(){return t.parse({mediaType:"image/png",fileExtension:"png"})}static get READIUM_AUDIOBOOK(){return t.parse({mediaType:"application/audiobook+zip",name:"Readium Audiobook",fileExtension:"audiobook"})}static get READIUM_AUDIOBOOK_MANIFEST(){return t.parse({mediaType:"application/audiobook+json",name:"Readium Audiobook",fileExtension:"json"})}static get READIUM_CONTENT_DOCUMENT(){return t.parse({mediaType:"application/vnd.readium.content+json",name:"Readium Content Document",fileExtension:"json"})}static get READIUM_GUIDED_NAVIGATION_DOCUMENT(){return t.parse({mediaType:"application/guided-navigation+json",name:"Readium Guided Navigation Document",fileExtension:"json"})}static get READIUM_POSITION_LIST(){return t.parse({mediaType:"application/vnd.readium.position-list+json",name:"Readium Position List",fileExtension:"json"})}static get READIUM_WEBPUB(){return t.parse({mediaType:"application/webpub+zip",name:"Readium Web Publication",fileExtension:"webpub"})}static get READIUM_WEBPUB_MANIFEST(){return t.parse({mediaType:"application/webpub+json",name:"Readium Web Publication",fileExtension:"json"})}static get SMIL(){return t.parse({mediaType:"application/smil+xml",fileExtension:"smil"})}static get SVG(){return t.parse({mediaType:"image/svg+xml",fileExtension:"svg"})}static get TEXT(){return t.parse({mediaType:"text/plain",fileExtension:"txt"})}static get TIFF(){return t.parse({mediaType:"image/tiff",fileExtension:"tiff"})}static get TTF(){return t.parse({mediaType:"font/ttf",fileExtension:"ttf"})}static get W3C_WPUB_MANIFEST(){return t.parse({mediaType:"application/x.readium.w3c.wpub+json",name:"Web Publication",fileExtension:"json"})}static get WAV(){return t.parse({mediaType:"audio/wav",fileExtension:"wav"})}static get WEBM_AUDIO(){return t.parse({mediaType:"audio/webm",fileExtension:"webm"})}static get WEBM_VIDEO(){return t.parse({mediaType:"video/webm",fileExtension:"webm"})}static get WEBP(){return t.parse({mediaType:"image/webp",fileExtension:"webp"})}static get WOFF(){return t.parse({mediaType:"font/woff",fileExtension:"woff"})}static get WOFF2(){return t.parse({mediaType:"font/woff2",fileExtension:"woff2"})}static get XHTML(){return t.parse({mediaType:"application/xhtml+xml",fileExtension:"xhtml"})}static get XML(){return t.parse({mediaType:"application/xml",fileExtension:"xml"})}static get ZAB(){return t.parse({mediaType:"application/x.readium.zab+zip",name:"Zipped Audio Book",fileExtension:"zab"})}static get ZIP(){return t.parse({mediaType:"application/zip",fileExtension:"zip"})}}export{t as MediaType};
@@ -0,0 +1 @@
1
+ function c(o){const s=o.split(",")[0].trim(),t=(s.toLowerCase().startsWith("npt:")?s.slice(4):s).split(":");if(t.length===1){const n=parseFloat(t[0]);return isNaN(n)?void 0:n}if(t.length===2){const n=parseInt(t[0],10),r=parseFloat(t[1]);return isNaN(n)||isNaN(r)?void 0:n*60+r}if(t.length===3){const n=parseInt(t[0],10),r=parseInt(t[1],10),e=parseFloat(t[2]);return isNaN(n)||isNaN(r)||isNaN(e)?void 0:n*3600+r*60+e}}function p(o){const s=c(o);return s!==void 0&&s===0}function l(o){const s=Math.floor(o),a=Math.floor(s/3600),i=Math.floor(s%3600/60),t=s%60,n=String(i).padStart(2,"0"),r=String(t).padStart(2,"0");return a>0?`${a}:${n}:${r}`:`${i}:${r}`}export{l as formatNptTime,p as isNptStartOfResource,c as parseNptTime};
@@ -0,0 +1 @@
1
+ import a from"./tokenize-english/index.js";import h from"./tokenize-text/index.js";var l=(t=>(t.Word="word",t.Sentence="sentence",t.Paragraph="paragraph",t))(l||{});const p=(t,e)=>"Segmenter"in Intl?new c(t,e):new u(t,e);class c{constructor(e,n){if(this.unit=n,e=e??navigator?.language,!("Segmenter"in Intl))throw new Error("Intl.Segmenter is not supported in this environment");if(n==="paragraph")throw new Error("IntlTextTokenizer does not handle TextUnit.Paragraph");this.segmenter=new Intl.Segmenter(e,{granularity:n})}tokenize(e){const n=this.segmenter.segment(e),i=[];for(let r of n){if(this.unit==="word"&&r.isWordLike===!1)continue;const s=o(r.segment);s!==null&&i.push([r.index,r.index+s.length])}return i}}class u{constructor(e,n){if(this.unit=n,e=e??navigator?.language,this.isEnglish=e.toLowerCase().split("-")[0]==="en",n==="paragraph")throw new Error("NaiveTextTokenizer does not handle TextUnit.Paragraph");this.tokenizer=new h}tokenize(e){let n=[];switch(this.unit){case"word":n=this.tokenizer.words()(e);break;case"sentence":this.isEnglish?n=a(this.tokenizer).sentences()(e):n=this.tokenizer.sections()(e);break;default:n=[]}if(!n)return[];const i=[];return n.forEach(r=>{if(r.value.length===0)return;const s=o(r.value);s!==null&&i.push([r.index,r.index+s.length])}),i}}const g=new RegExp("[\\p{L}\\p{N}]+","u"),o=t=>{const e=t.trimEnd();return e.length===0||e.match(g)===null?null:e};export{p as DefaultTextContentTokenizer,c as IntlTextTokenizer,u as NaiveTextTokenizer,l as TextUnit,o as speakableToken};
@@ -0,0 +1 @@
1
+ const e=["ie","eg","ext","Fig","fig","Figs","figs","et al","Co","Corp","Ave","Inc","Ex","Viz","vs","Vs","repr","Rep","Dem","trans","Vol","pp","rev","est","Ref","Refs","Eq","Eqs","Ch","Sec","Secs","mi","Dept","Univ","Nos","No","Mol","Cell","Miss","Mrs","Mr","Ms","Prof","Dr","Sgt","Col","Gen","Rep","Sen","Gov","Lt","Maj","Capt","St","Sr","Jr","jr","Rev","PhD","MD","BA","MA","MM","BSc","MSc","Jan","Feb","Mar","Apr","Jun","Jul","Aug","Sep","Sept","Oct","Nov","Dec","Sun","Mon","Tu","Tue","Tues","Wed","Th","Thu","Thur","Thurs","Fri","Sat"];export{e as default};
@@ -0,0 +1,2 @@
1
+ import s from"./utils.js";import g from"./abbreviations.js";function v(e){return/^[A-Z][a-z].*/.test(e)||c(e)}function p(e){return v(e)||/``|"|'/.test(e.substring(0,2))}function C(e){return~g.indexOf(e.replace(/\W+/g,""))}function N(e,n){if(e==="a.m."||e==="p.m."){var r=n.replace(/\W+/g,"").slice(-3).toLowerCase();if(r==="day")return!0}return!1}function h(e){var n=e.replace(/[\(\)\[\]\{\}]/g,"").match(/(.\.)*/);return n&&n[0].length>0}function m(e){return e.length<=3?!0:v(e)}function c(e,n){return n&&(e=e.slice(n-1,n+2)),!isNaN(Number(e))}function O(e){return e.match(/^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/)}function z(e){return e.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/)}function W(e){var n=0;if((n=e.indexOf("."))>-1||(n=e.indexOf("!"))>-1||(n=e.indexOf("?"))>-1){var r=e.charAt(n+1);if(r.match(/[a-zA-Z].*/))return[e.slice(0,n),e.charAt(n),e.slice(n+1)]}return!1}function o(e){return e==="."||e==="!"||e==="?"}function y(e,n){n=Object.assign(n||{},{newlineBoundary:n&&n.newlineBoundary||!0});var r=/\s/;return e.serie(e.re(r,{split:!0}),e.splitAndMerge(function(t,Z,S,L,b,A){var u,f=[t,null],i=t,a=A.slice(b+1).find(function(x){return!r.test(x.value)});if(t===`
2
+ `&&n.newlineBoundary||o(t)||s.endsWithChar(t,"?!"))return f;if(s.endsWithChar(t,".")){if(a){if(t.length===2&&isNaN(t.charAt(0))&&t.match(/[a-zA-Z]/)||C(t))return i;if(p(a.value)){if(N(t,a.value)||c(a.value)&&m(t))return i}else if(s.endsWith(t,"..")||h(t)||m(t))return i}return f}let l;return(l=t.indexOf("."))>-1&&(c(t,l)||h(t)||z(t)||O(t))?i:(u=W(t))?[u[0]+u[1],null,u[2]]:i}),e.filter(function(t){return t.trim()!=""}))}const B=(e,...n)=>(...r)=>e(...n,...r);function _(e){return{sentences:B(y,e)}}export{_ as default};
@@ -0,0 +1 @@
1
+ function n(e,t){return t.length>1?t.indexOf(e.slice(-1))>-1:e.slice(-1)===t}function i(e,t){return e.slice(e.length-t.length)===t}const s={endsWith:i,endsWithChar:n};export{s as default};
@@ -0,0 +1 @@
1
+ import g from"./tokens.js";var m=' \r\n  !"#$%&()*+,-.\\/:;<=>?@[\\]^_`{|}~',k=new RegExp("([^"+m+"]+)");function i(u){if(!(this instanceof i))return new i(u);this.opts=Object.assign({cacheGet:function(t){return null},cacheSet:function(t,n){}},u)}i.prototype.split=function(t,n={}){var e=this;return n=Object.assign({preserveProperties:!0,cache:()=>null},n),function(r,c){if(arguments.length===6)return t.apply(null,arguments);var o,a,l;if(r===void 0)return[];if(typeof r=="string"?r=[{value:r,index:0,offset:r.length}]:Array.isArray(r)||(r=[r]),a=g.tokensId(r,n.cache()),a&&(l=e.opts.cacheGet(a),l))return l;var h=r.map(function(s,f){var v=r[f+1],p=t(s.value,Object.assign({},s),o?Object.assign({},o):null,v?Object.assign({},v):null,f,r)||[];if(p=g.normalize(s,p),n.preserveProperties){var y=g.properties(s);p=p.map(function(d){return Object.assign({},d,y)})}return o=s,p}).filter(Boolean).flat();return a&&e.opts.cacheSet(a,h),h}};i.prototype.re=function(t,n={}){return n=Object.assign({split:!1},n),this.split(function(e,r){for(var c=e,o=[],a,l=0;a=t.exec(e);){var h=a.index,s=l+h,f=a[0]||"",v=f.length;if(n.split&&l<s){var p=c.slice(l,s);o.push({value:p,index:l,offset:p.length})}o.push({value:f,index:s,offset:v,match:a}),e=e.slice(h+v),l=s+v}return n.split&&e&&o.push({value:e,index:l,offset:e.length}),o},{cache:function(){return t.toString()}})};i.prototype.splitAndMerge=function(t,n={}){var e=this;return n=Object.assign({mergeWith:""},n),function(r){var c=[],o=[];function a(){if(o.length!=0){var l=g.merge(o,n.mergeWith);c.push(l),o=[]}}return e.split(function(l,h){var s=t.apply(null,arguments);s=g.normalize(h,s),s.forEach(function(f){f===null?a():o.push(f)})})(r),a(),c}};i.prototype.filter=function(t){return this.split(function(n,e){if(t.apply(null,arguments))return{value:e.value,index:0,offset:e.offset}})};i.prototype.extend=function(t){return this.split(function(n,e){var r=typeof t=="function"?t.apply(null,arguments):t;return Object.assign({value:e.value,index:0,offset:e.offset},r)})};i.prototype.ifthen=function(u,t){return this.split(function(n,e){if(u.apply(null,arguments))return t.apply(null,arguments);const{index:r,...c}=e;return c})};i.prototype.test=function(t){return this.filter(function(n,e){return t.test(n)},{cache:t.toString()})};i.prototype.flow=function(...t){const n=t.reduce((e,r)=>(...c)=>r(e(...c)));return this.split(n)};i.prototype.serie=function(...t){return t.reduce((n,e)=>(...r)=>e(n(...r)))};i.prototype.merge=function(){return this.splitAndMerge(u=>[u])};i.prototype.sections=function(){return this.re(/([^\n\.,;!?]+)/i,{split:!1})};i.prototype.words=function(){return this.re(k)};i.prototype.characters=function(){return this.re(/[^\s]/)};export{i as default};
@@ -0,0 +1 @@
1
+ function v(e,i){return i?e.reduce(function(f,r){var n=[r.index,r.offset,r.value].join("-");return[f,n].join(":")},i):null}function u(e){const{index:i,offset:f,value:r,...n}=e;return n}function o(e,i){var f=0;return Array.isArray(i)||(i=[i]),i.map(function(r){return r===null?null:(typeof r=="string"&&(r={value:r,index:f,offset:r.length}),typeof r=="object"&&(r.index=r.index||0,f=f+r.index+r.offset,r.index=e.index+r.index,r.offset=r.offset||r.value.length),r)})}function c(e,i){if(e.length==0)return null;var f="",r=0,n=e[0]?.index;return e.forEach(function(a,t){var l=e[t-1];e[t+1];var x=l?a.index+1-(l.index+l.offset):0;f=f+new Array(x).join(i)+a.value;var d=a.index-n+a.offset;d>r&&(r=d)}),{index:n,value:f,offset:Math.max(r,f.length)}}const g={tokensId:v,normalize:o,properties:u,merge:c};export{g as default};