@d-i-t-a/reader 2.4.4 → 2.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -5225,7 +5225,7 @@ var require_metadata_encrypted = __commonJS({
5225
5225
  exports2.Encrypted = void 0;
5226
5226
  var tslib_1 = (init_tslib_es62(), __toCommonJS(tslib_es6_exports2));
5227
5227
  var ta_json_x_1 = require_cjs();
5228
- var Encrypted = exports2.Encrypted = class Encrypted {
5228
+ var Encrypted = class Encrypted {
5229
5229
  constructor() {
5230
5230
  this.DecryptedLengthBeforeInflate = -1;
5231
5231
  this.CypherBlockPadding = -1;
@@ -5240,6 +5240,7 @@ var require_metadata_encrypted = __commonJS({
5240
5240
  }
5241
5241
  }
5242
5242
  };
5243
+ exports2.Encrypted = Encrypted;
5243
5244
  tslib_1.__decorate([
5244
5245
  (0, ta_json_x_1.JsonProperty)("scheme"),
5245
5246
  tslib_1.__metadata("design:type", String)
@@ -5312,8 +5313,9 @@ var require_metadata_properties = __commonJS({
5312
5313
  SpreadEnum2["Landscape"] = "landscape";
5313
5314
  })(SpreadEnum || (exports2.SpreadEnum = SpreadEnum = {}));
5314
5315
  exports2.PropertiesSupportedKeys = ["contains", "layout", "orientation", "overflow", "page", "spread", "encrypted", "media-overlay"];
5315
- var Properties = exports2.Properties = class Properties {
5316
+ var Properties = class Properties {
5316
5317
  };
5318
+ exports2.Properties = Properties;
5317
5319
  tslib_1.__decorate([
5318
5320
  (0, ta_json_x_1.JsonProperty)("contains"),
5319
5321
  (0, ta_json_x_1.JsonElementType)(String),
@@ -5358,7 +5360,6 @@ var require_publication_link = __commonJS({
5358
5360
  "node_modules/r2-shared-js/dist/es6-es2015/src/models/publication-link.js"(exports2) {
5359
5361
  "use strict";
5360
5362
  init_polyfills();
5361
- var Link_1;
5362
5363
  Object.defineProperty(exports2, "__esModule", { value: true });
5363
5364
  exports2.Link = void 0;
5364
5365
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
@@ -5369,7 +5370,7 @@ var require_publication_link = __commonJS({
5369
5370
  var PROPERTIES_JSON_PROP = "properties";
5370
5371
  var CHILDREN_JSON_PROP = "children";
5371
5372
  var ALTERNATE_JSON_PROP = "alternate";
5372
- var Link2 = exports2.Link = Link_1 = class Link {
5373
+ var Link2 = class Link {
5373
5374
  get Href() {
5374
5375
  return this.Href1;
5375
5376
  }
@@ -5422,6 +5423,7 @@ var require_publication_link = __commonJS({
5422
5423
  }
5423
5424
  }
5424
5425
  };
5426
+ exports2.Link = Link2;
5425
5427
  tslib_1.__decorate([
5426
5428
  (0, ta_json_x_1.JsonProperty)("type"),
5427
5429
  tslib_1.__metadata("design:type", String)
@@ -5456,12 +5458,12 @@ var require_publication_link = __commonJS({
5456
5458
  ], Link2.prototype, "Templated", void 0);
5457
5459
  tslib_1.__decorate([
5458
5460
  (0, ta_json_x_1.JsonProperty)(CHILDREN_JSON_PROP),
5459
- (0, ta_json_x_1.JsonElementType)(Link_1),
5461
+ (0, ta_json_x_1.JsonElementType)(Link2),
5460
5462
  tslib_1.__metadata("design:type", Array)
5461
5463
  ], Link2.prototype, "Children", void 0);
5462
5464
  tslib_1.__decorate([
5463
5465
  (0, ta_json_x_1.JsonProperty)(ALTERNATE_JSON_PROP),
5464
- (0, ta_json_x_1.JsonElementType)(Link_1),
5466
+ (0, ta_json_x_1.JsonElementType)(Link2),
5465
5467
  tslib_1.__metadata("design:type", Array)
5466
5468
  ], Link2.prototype, "Alternate", void 0);
5467
5469
  tslib_1.__decorate([
@@ -5480,7 +5482,7 @@ var require_publication_link = __commonJS({
5480
5482
  tslib_1.__metadata("design:paramtypes", []),
5481
5483
  tslib_1.__metadata("design:returntype", void 0)
5482
5484
  ], Link2.prototype, "_OnDeserialized", null);
5483
- exports2.Link = Link2 = Link_1 = tslib_1.__decorate([
5485
+ exports2.Link = Link2 = tslib_1.__decorate([
5484
5486
  (0, ta_json_x_1.JsonObject)()
5485
5487
  ], Link2);
5486
5488
  }
@@ -5498,7 +5500,7 @@ var require_metadata_contributor = __commonJS({
5498
5500
  var ta_json_string_converter_1 = require_ta_json_string_converter();
5499
5501
  var publication_link_1 = require_publication_link();
5500
5502
  var LINKS_JSON_PROP = "links";
5501
- var Contributor = exports2.Contributor = class Contributor {
5503
+ var Contributor = class Contributor {
5502
5504
  get SortAs() {
5503
5505
  return this.SortAs2 ? this.SortAs2 : this.SortAs1;
5504
5506
  }
@@ -5514,6 +5516,7 @@ var require_metadata_contributor = __commonJS({
5514
5516
  }
5515
5517
  }
5516
5518
  };
5519
+ exports2.Contributor = Contributor;
5517
5520
  tslib_1.__decorate([
5518
5521
  (0, ta_json_x_1.JsonProperty)("name"),
5519
5522
  tslib_1.__metadata("design:type", Object)
@@ -5624,8 +5627,9 @@ var require_metadata_belongsto = __commonJS({
5624
5627
  var metadata_contributor_json_converter_1 = require_metadata_contributor_json_converter();
5625
5628
  var SERIES_JSON_PROP = "series";
5626
5629
  var COLLECTION_JSON_PROP = "collection";
5627
- var BelongsTo = exports2.BelongsTo = class BelongsTo {
5630
+ var BelongsTo = class BelongsTo {
5628
5631
  };
5632
+ exports2.BelongsTo = BelongsTo;
5629
5633
  tslib_1.__decorate([
5630
5634
  (0, ta_json_x_1.JsonProperty)(SERIES_JSON_PROP),
5631
5635
  (0, ta_json_x_1.JsonElementType)(metadata_contributor_1.Contributor),
@@ -5653,8 +5657,9 @@ var require_metadata_media_overlay = __commonJS({
5653
5657
  exports2.MediaOverlay = void 0;
5654
5658
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
5655
5659
  var ta_json_x_1 = require_cjs();
5656
- var MediaOverlay = exports2.MediaOverlay = class MediaOverlay {
5660
+ var MediaOverlay = class MediaOverlay {
5657
5661
  };
5662
+ exports2.MediaOverlay = MediaOverlay;
5658
5663
  tslib_1.__decorate([
5659
5664
  (0, ta_json_x_1.JsonProperty)("active-class"),
5660
5665
  tslib_1.__metadata("design:type", String)
@@ -5680,7 +5685,7 @@ var require_metadata_subject = __commonJS({
5680
5685
  var ta_json_x_1 = require_cjs();
5681
5686
  var publication_link_1 = require_publication_link();
5682
5687
  var LINKS_JSON_PROP = "links";
5683
- var Subject = exports2.Subject = class Subject {
5688
+ var Subject = class Subject {
5684
5689
  get SortAs() {
5685
5690
  return this.SortAs2 ? this.SortAs2 : this.SortAs1;
5686
5691
  }
@@ -5696,6 +5701,7 @@ var require_metadata_subject = __commonJS({
5696
5701
  }
5697
5702
  }
5698
5703
  };
5704
+ exports2.Subject = Subject;
5699
5705
  tslib_1.__decorate([
5700
5706
  (0, ta_json_x_1.JsonProperty)("name"),
5701
5707
  tslib_1.__metadata("design:type", Object)
@@ -5777,8 +5783,9 @@ var require_metadata_accessibility_certification = __commonJS({
5777
5783
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
5778
5784
  var ta_json_x_1 = require_cjs();
5779
5785
  var ta_json_string_converter_1 = require_ta_json_string_converter();
5780
- var AccessibilityCertification = exports2.AccessibilityCertification = class AccessibilityCertification {
5786
+ var AccessibilityCertification = class AccessibilityCertification {
5781
5787
  };
5788
+ exports2.AccessibilityCertification = AccessibilityCertification;
5782
5789
  tslib_1.__decorate([
5783
5790
  (0, ta_json_x_1.JsonProperty)("certifiedBy"),
5784
5791
  (0, ta_json_x_1.JsonConverter)(ta_json_string_converter_1.JsonStringConverter),
@@ -5814,8 +5821,9 @@ var require_metadata_accessibility = __commonJS({
5814
5821
  var ta_json_x_1 = require_cjs();
5815
5822
  var ta_json_string_converter_1 = require_ta_json_string_converter();
5816
5823
  var metadata_accessibility_certification_1 = require_metadata_accessibility_certification();
5817
- var AccessibilityMetadata = exports2.AccessibilityMetadata = class AccessibilityMetadata {
5824
+ var AccessibilityMetadata = class AccessibilityMetadata {
5818
5825
  };
5826
+ exports2.AccessibilityMetadata = AccessibilityMetadata;
5819
5827
  tslib_1.__decorate([
5820
5828
  (0, ta_json_x_1.JsonProperty)("certification"),
5821
5829
  tslib_1.__metadata("design:type", metadata_accessibility_certification_1.AccessibilityCertification)
@@ -5935,7 +5943,7 @@ var require_metadata = __commonJS({
5935
5943
  "source",
5936
5944
  "subject"
5937
5945
  ];
5938
- var Metadata = exports2.Metadata = class Metadata {
5946
+ var Metadata = class Metadata {
5939
5947
  get SortAs() {
5940
5948
  return this.SortAs2 ? this.SortAs2 : this.SortAs1;
5941
5949
  }
@@ -5969,6 +5977,7 @@ var require_metadata = __commonJS({
5969
5977
  }
5970
5978
  }
5971
5979
  };
5980
+ exports2.Metadata = Metadata;
5972
5981
  tslib_1.__decorate([
5973
5982
  (0, ta_json_x_1.JsonProperty)("accessibility"),
5974
5983
  tslib_1.__metadata("design:type", metadata_accessibility_1.AccessibilityMetadata)
@@ -6241,7 +6250,7 @@ var require_publication = __commonJS({
6241
6250
  var LOA_JSON_PROP = "loa";
6242
6251
  var LOV_JSON_PROP = "lov";
6243
6252
  var LOT_JSON_PROP = "lot";
6244
- var Publication2 = exports2.Publication = class Publication {
6253
+ var Publication2 = class Publication {
6245
6254
  get Spine() {
6246
6255
  return this.Spine2 ? this.Spine2 : this.Spine1;
6247
6256
  }
@@ -6348,6 +6357,7 @@ var require_publication = __commonJS({
6348
6357
  }
6349
6358
  }
6350
6359
  };
6360
+ exports2.Publication = Publication2;
6351
6361
  tslib_1.__decorate([
6352
6362
  (0, ta_json_x_1.JsonProperty)("@context"),
6353
6363
  (0, ta_json_x_1.JsonElementType)(String),
@@ -15309,6 +15319,8 @@ var require_loglevel = __commonJS({
15309
15319
  "warn",
15310
15320
  "error"
15311
15321
  ];
15322
+ var _loggersByName = {};
15323
+ var defaultLogger = null;
15312
15324
  function bindMethod(obj, methodName) {
15313
15325
  var method = obj[methodName];
15314
15326
  if (typeof method.bind === "function") {
@@ -15350,28 +15362,33 @@ var require_loglevel = __commonJS({
15350
15362
  return noop;
15351
15363
  }
15352
15364
  }
15353
- function replaceLoggingMethods(level, loggerName) {
15365
+ function replaceLoggingMethods() {
15366
+ var level = this.getLevel();
15354
15367
  for (var i = 0; i < logMethods.length; i++) {
15355
15368
  var methodName = logMethods[i];
15356
- this[methodName] = i < level ? noop : this.methodFactory(methodName, level, loggerName);
15369
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
15357
15370
  }
15358
15371
  this.log = this.debug;
15372
+ if (typeof console === undefinedType && level < this.levels.SILENT) {
15373
+ return "No console available for logging";
15374
+ }
15359
15375
  }
15360
- function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
15376
+ function enableLoggingWhenConsoleArrives(methodName) {
15361
15377
  return function() {
15362
15378
  if (typeof console !== undefinedType) {
15363
- replaceLoggingMethods.call(this, level, loggerName);
15379
+ replaceLoggingMethods.call(this);
15364
15380
  this[methodName].apply(this, arguments);
15365
15381
  }
15366
15382
  };
15367
15383
  }
15368
- function defaultMethodFactory(methodName, level, loggerName) {
15384
+ function defaultMethodFactory(methodName, _level, _loggerName) {
15369
15385
  return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
15370
15386
  }
15371
- function Logger(name, defaultLevel, factory) {
15387
+ function Logger(name, factory) {
15372
15388
  var self2 = this;
15373
- var currentLevel;
15374
- defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
15389
+ var inheritedLevel;
15390
+ var defaultLevel;
15391
+ var userLevel;
15375
15392
  var storageKey = "loglevel";
15376
15393
  if (typeof name === "string") {
15377
15394
  storageKey += ":" + name;
@@ -15403,11 +15420,12 @@ var require_loglevel = __commonJS({
15403
15420
  if (typeof storedLevel === undefinedType) {
15404
15421
  try {
15405
15422
  var cookie = window.document.cookie;
15406
- var location = cookie.indexOf(
15407
- encodeURIComponent(storageKey) + "="
15408
- );
15423
+ var cookieName = encodeURIComponent(storageKey);
15424
+ var location = cookie.indexOf(cookieName + "=");
15409
15425
  if (location !== -1) {
15410
- storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
15426
+ storedLevel = /^([^;]+)/.exec(
15427
+ cookie.slice(location + cookieName.length + 1)
15428
+ )[1];
15411
15429
  }
15412
15430
  } catch (ignore) {
15413
15431
  }
@@ -15422,7 +15440,6 @@ var require_loglevel = __commonJS({
15422
15440
  return;
15423
15441
  try {
15424
15442
  window.localStorage.removeItem(storageKey);
15425
- return;
15426
15443
  } catch (ignore) {
15427
15444
  }
15428
15445
  try {
@@ -15430,6 +15447,17 @@ var require_loglevel = __commonJS({
15430
15447
  } catch (ignore) {
15431
15448
  }
15432
15449
  }
15450
+ function normalizeLevel(input) {
15451
+ var level = input;
15452
+ if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
15453
+ level = self2.levels[level.toUpperCase()];
15454
+ }
15455
+ if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
15456
+ return level;
15457
+ } else {
15458
+ throw new TypeError("log.setLevel() called with invalid level: " + input);
15459
+ }
15460
+ }
15433
15461
  self2.name = name;
15434
15462
  self2.levels = {
15435
15463
  "TRACE": 0,
@@ -15441,34 +15469,31 @@ var require_loglevel = __commonJS({
15441
15469
  };
15442
15470
  self2.methodFactory = factory || defaultMethodFactory;
15443
15471
  self2.getLevel = function() {
15444
- return currentLevel;
15472
+ if (userLevel != null) {
15473
+ return userLevel;
15474
+ } else if (defaultLevel != null) {
15475
+ return defaultLevel;
15476
+ } else {
15477
+ return inheritedLevel;
15478
+ }
15445
15479
  };
15446
15480
  self2.setLevel = function(level, persist) {
15447
- if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
15448
- level = self2.levels[level.toUpperCase()];
15449
- }
15450
- if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
15451
- currentLevel = level;
15452
- if (persist !== false) {
15453
- persistLevelIfPossible(level);
15454
- }
15455
- replaceLoggingMethods.call(self2, level, name);
15456
- if (typeof console === undefinedType && level < self2.levels.SILENT) {
15457
- return "No console available for logging";
15458
- }
15459
- } else {
15460
- throw "log.setLevel() called with invalid level: " + level;
15481
+ userLevel = normalizeLevel(level);
15482
+ if (persist !== false) {
15483
+ persistLevelIfPossible(userLevel);
15461
15484
  }
15485
+ return replaceLoggingMethods.call(self2);
15462
15486
  };
15463
15487
  self2.setDefaultLevel = function(level) {
15464
- defaultLevel = level;
15488
+ defaultLevel = normalizeLevel(level);
15465
15489
  if (!getPersistedLevel()) {
15466
15490
  self2.setLevel(level, false);
15467
15491
  }
15468
15492
  };
15469
15493
  self2.resetLevel = function() {
15470
- self2.setLevel(defaultLevel, false);
15494
+ userLevel = null;
15471
15495
  clearPersistedLevel();
15496
+ replaceLoggingMethods.call(self2);
15472
15497
  };
15473
15498
  self2.enableAll = function(persist) {
15474
15499
  self2.setLevel(self2.levels.TRACE, persist);
@@ -15476,14 +15501,27 @@ var require_loglevel = __commonJS({
15476
15501
  self2.disableAll = function(persist) {
15477
15502
  self2.setLevel(self2.levels.SILENT, persist);
15478
15503
  };
15504
+ self2.rebuild = function() {
15505
+ if (defaultLogger !== self2) {
15506
+ inheritedLevel = normalizeLevel(defaultLogger.getLevel());
15507
+ }
15508
+ replaceLoggingMethods.call(self2);
15509
+ if (defaultLogger === self2) {
15510
+ for (var childName in _loggersByName) {
15511
+ _loggersByName[childName].rebuild();
15512
+ }
15513
+ }
15514
+ };
15515
+ inheritedLevel = normalizeLevel(
15516
+ defaultLogger ? defaultLogger.getLevel() : "WARN"
15517
+ );
15479
15518
  var initialLevel = getPersistedLevel();
15480
- if (initialLevel == null) {
15481
- initialLevel = defaultLevel;
15519
+ if (initialLevel != null) {
15520
+ userLevel = normalizeLevel(initialLevel);
15482
15521
  }
15483
- self2.setLevel(initialLevel, false);
15522
+ replaceLoggingMethods.call(self2);
15484
15523
  }
15485
- var defaultLogger = new Logger();
15486
- var _loggersByName = {};
15524
+ defaultLogger = new Logger();
15487
15525
  defaultLogger.getLogger = function getLogger(name) {
15488
15526
  if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
15489
15527
  throw new TypeError("You must supply a name when creating a logger.");
@@ -15492,7 +15530,6 @@ var require_loglevel = __commonJS({
15492
15530
  if (!logger) {
15493
15531
  logger = _loggersByName[name] = new Logger(
15494
15532
  name,
15495
- defaultLogger.getLevel(),
15496
15533
  defaultLogger.methodFactory
15497
15534
  );
15498
15535
  }
@@ -21344,7 +21381,6 @@ var require_media_overlay = __commonJS({
21344
21381
  "node_modules/r2-shared-js/dist/es6-es2015/src/models/media-overlay.js"(exports2) {
21345
21382
  "use strict";
21346
21383
  init_polyfills();
21347
- var MediaOverlayNode_1;
21348
21384
  Object.defineProperty(exports2, "__esModule", { value: true });
21349
21385
  exports2.MediaOverlayNode = exports2.timeStrToSeconds = void 0;
21350
21386
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
@@ -21407,11 +21443,12 @@ var require_media_overlay = __commonJS({
21407
21443
  return hours * 3600 + minutes * 60 + seconds;
21408
21444
  }
21409
21445
  exports2.timeStrToSeconds = timeStrToSeconds;
21410
- var MediaOverlayNode2 = exports2.MediaOverlayNode = MediaOverlayNode_1 = class MediaOverlayNode {
21446
+ var MediaOverlayNode2 = class MediaOverlayNode {
21411
21447
  constructor() {
21412
21448
  this.initialized = false;
21413
21449
  }
21414
21450
  };
21451
+ exports2.MediaOverlayNode = MediaOverlayNode2;
21415
21452
  tslib_1.__decorate([
21416
21453
  (0, ta_json_x_1.JsonProperty)("text"),
21417
21454
  tslib_1.__metadata("design:type", String)
@@ -21428,10 +21465,10 @@ var require_media_overlay = __commonJS({
21428
21465
  ], MediaOverlayNode2.prototype, "Role", void 0);
21429
21466
  tslib_1.__decorate([
21430
21467
  (0, ta_json_x_1.JsonProperty)("narration"),
21431
- (0, ta_json_x_1.JsonElementType)(MediaOverlayNode_1),
21468
+ (0, ta_json_x_1.JsonElementType)(MediaOverlayNode2),
21432
21469
  tslib_1.__metadata("design:type", Array)
21433
21470
  ], MediaOverlayNode2.prototype, "Children", void 0);
21434
- exports2.MediaOverlayNode = MediaOverlayNode2 = MediaOverlayNode_1 = tslib_1.__decorate([
21471
+ exports2.MediaOverlayNode = MediaOverlayNode2 = tslib_1.__decorate([
21435
21472
  (0, ta_json_x_1.JsonObject)()
21436
21473
  ], MediaOverlayNode2);
21437
21474
  }
@@ -46067,6 +46104,7 @@ _ReadiumCSS.SCROLL_REF = "scroll";
46067
46104
  // static readonly PUBLISHER_DEFAULT_REF = "advancedSettings";
46068
46105
  _ReadiumCSS.TEXT_ALIGNMENT_REF = "textAlign";
46069
46106
  _ReadiumCSS.COLUMN_COUNT_REF = "colCount";
46107
+ _ReadiumCSS.DIRECTION_REF = "direction";
46070
46108
  _ReadiumCSS.WORD_SPACING_REF = "wordSpacing";
46071
46109
  _ReadiumCSS.LETTER_SPACING_REF = "letterSpacing";
46072
46110
  _ReadiumCSS.PAGE_MARGINS_REF = "pageMargins";
@@ -46080,6 +46118,7 @@ _ReadiumCSS.SCROLL_KEY = "--USER__" + _ReadiumCSS.SCROLL_REF;
46080
46118
  // "--USER__" + ReadiumCSS.PUBLISHER_DEFAULT_REF;
46081
46119
  _ReadiumCSS.TEXT_ALIGNMENT_KEY = "--USER__" + _ReadiumCSS.TEXT_ALIGNMENT_REF;
46082
46120
  _ReadiumCSS.COLUMN_COUNT_KEY = "--USER__" + _ReadiumCSS.COLUMN_COUNT_REF;
46121
+ _ReadiumCSS.DIRECTION_KEY = "--USER__" + _ReadiumCSS.DIRECTION_REF;
46083
46122
  _ReadiumCSS.WORD_SPACING_KEY = "--USER__" + _ReadiumCSS.WORD_SPACING_REF;
46084
46123
  _ReadiumCSS.LETTER_SPACING_KEY = "--USER__" + _ReadiumCSS.LETTER_SPACING_REF;
46085
46124
  _ReadiumCSS.PAGE_MARGINS_KEY = "--USER__" + _ReadiumCSS.PAGE_MARGINS_REF;
@@ -46243,16 +46282,21 @@ var Popup = class {
46243
46282
  return;
46244
46283
  }
46245
46284
  let self2 = this;
46246
- win.onclick = function(ev) {
46247
- if (event.target !== ev.target) {
46248
- if (d2popover.parentElement) {
46249
- self2.hidePopover();
46250
- if (win) {
46251
- win.onclick = null;
46285
+ win.addEventListener(
46286
+ "click",
46287
+ function(ev) {
46288
+ if (event.target !== ev.target) {
46289
+ if (d2popover.parentElement) {
46290
+ self2.hidePopover();
46291
+ ev.stopImmediatePropagation();
46252
46292
  }
46253
46293
  }
46294
+ },
46295
+ {
46296
+ once: true,
46297
+ capture: true
46254
46298
  }
46255
- };
46299
+ );
46256
46300
  }
46257
46301
  } else if (src) {
46258
46302
  let absolute = getAbsoluteHref(src);
@@ -46291,16 +46335,21 @@ var Popup = class {
46291
46335
  return;
46292
46336
  }
46293
46337
  let self2 = this;
46294
- win.onclick = function(ev) {
46295
- if (event.target !== ev.target) {
46296
- if (d2popover.parentElement) {
46297
- self2.hidePopover();
46298
- if (win) {
46299
- win.onclick = null;
46338
+ win.addEventListener(
46339
+ "click",
46340
+ function(ev) {
46341
+ if (event.target !== ev.target) {
46342
+ if (d2popover.parentElement) {
46343
+ self2.hidePopover();
46344
+ ev.stopImmediatePropagation();
46300
46345
  }
46301
46346
  }
46347
+ },
46348
+ {
46349
+ once: true,
46350
+ capture: true
46302
46351
  }
46303
- };
46352
+ );
46304
46353
  }
46305
46354
  }
46306
46355
  }
@@ -46471,7 +46520,7 @@ var EventHandler = class {
46471
46520
  },
46472
46521
  true
46473
46522
  );
46474
- element.addEventListener("click", this.handleLinks.bind(this));
46523
+ element.addEventListener("click", this.handleLinks.bind(this), true);
46475
46524
  } else {
46476
46525
  throw "cannot setup events for null";
46477
46526
  }
@@ -47019,6 +47068,7 @@ var _UserSettings = class _UserSettings {
47019
47068
  // publisherDefaults = true;
47020
47069
  this.textAlignment = 0;
47021
47070
  this.columnCount = 0;
47071
+ this.direction = 0;
47022
47072
  this.wordSpacing = 0;
47023
47073
  this.letterSpacing = 0;
47024
47074
  this.pageMargins = 2;
@@ -47141,6 +47191,17 @@ var _UserSettings = class _UserSettings {
47141
47191
  }
47142
47192
  import_loglevel2.default.log(settings.columnCount);
47143
47193
  }
47194
+ if (initialUserSettings.direction) {
47195
+ settings.direction = _UserSettings.directionValues.findIndex(
47196
+ (el) => el === initialUserSettings.direction
47197
+ );
47198
+ let prop = settings.userProperties.getByRef(ReadiumCSS.DIRECTION_REF);
47199
+ if (prop) {
47200
+ prop.value = settings.direction;
47201
+ await settings.saveProperty(prop);
47202
+ }
47203
+ import_loglevel2.default.log(settings.direction);
47204
+ }
47144
47205
  if (initialUserSettings.wordSpacing) {
47145
47206
  settings.wordSpacing = initialUserSettings.wordSpacing;
47146
47207
  let prop = settings.userProperties.getByRef(
@@ -47216,6 +47277,10 @@ var _UserSettings = class _UserSettings {
47216
47277
  "columnCount",
47217
47278
  ReadiumCSS.COLUMN_COUNT_KEY
47218
47279
  );
47280
+ this.direction = await this.getPropertyAndFallback(
47281
+ "direction",
47282
+ ReadiumCSS.DIRECTION_KEY
47283
+ );
47219
47284
  this.fontSize = await this.getPropertyAndFallback(
47220
47285
  "fontSize",
47221
47286
  ReadiumCSS.FONT_SIZE_KEY
@@ -47246,6 +47311,7 @@ var _UserSettings = class _UserSettings {
47246
47311
  this.fontFamily = 0;
47247
47312
  this.textAlignment = 0;
47248
47313
  this.columnCount = 0;
47314
+ this.direction = 0;
47249
47315
  this.wordSpacing = 0;
47250
47316
  this.letterSpacing = 0;
47251
47317
  this.pageMargins = 2;
@@ -47258,18 +47324,21 @@ var _UserSettings = class _UserSettings {
47258
47324
  "html"
47259
47325
  );
47260
47326
  if (html) {
47261
- const rootElement = document.documentElement;
47262
- const body = findRequiredElement(rootElement, "body");
47327
+ const rootElement = findElement(document, "#root") || document.documentElement;
47328
+ const body = findElement(html, "body");
47263
47329
  html.style.removeProperty(ReadiumCSS.FONT_SIZE_KEY);
47264
47330
  html.style.removeProperty(ReadiumCSS.WORD_SPACING_KEY);
47265
47331
  html.style.removeProperty(ReadiumCSS.LETTER_SPACING_KEY);
47266
47332
  html.style.removeProperty(ReadiumCSS.COLUMN_COUNT_KEY);
47333
+ html.style.removeProperty(ReadiumCSS.DIRECTION_KEY);
47267
47334
  html.style.removeProperty(ReadiumCSS.TEXT_ALIGNMENT_KEY);
47268
47335
  html.style.removeProperty(ReadiumCSS.LINE_HEIGHT_KEY);
47269
47336
  html.style.removeProperty(ReadiumCSS.PAGE_MARGINS_KEY);
47270
47337
  html.style.removeProperty(ReadiumCSS.APPEARANCE_KEY);
47271
- setAttr(rootElement, "data-viewer-theme", "day");
47272
- setAttr(body, "data-viewer-theme", "day");
47338
+ if (rootElement)
47339
+ setAttr(rootElement, "data-viewer-theme", "day");
47340
+ if (body)
47341
+ setAttr(body, "data-viewer-theme", "day");
47273
47342
  html.style.removeProperty(ReadiumCSS.FONT_FAMILY_KEY);
47274
47343
  setAttr(html, "data-viewer-font", "publisher");
47275
47344
  html.style.setProperty(
@@ -47288,7 +47357,7 @@ var _UserSettings = class _UserSettings {
47288
47357
  );
47289
47358
  }
47290
47359
  async applyProperties() {
47291
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
47360
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
47292
47361
  this.userProperties = this.getUserSettings();
47293
47362
  let doc = this.iframe.contentDocument;
47294
47363
  if (doc) {
@@ -47297,8 +47366,8 @@ var _UserSettings = class _UserSettings {
47297
47366
  "html"
47298
47367
  );
47299
47368
  if (html) {
47300
- const rootElement = document.documentElement;
47301
- const body = findRequiredElement(rootElement, "body");
47369
+ const rootElement = findElement(document, "#root") || document.documentElement;
47370
+ const body = findElement(html, "body");
47302
47371
  if ((_a = this.view) == null ? void 0 : _a.navigator.publication.isReflowable) {
47303
47372
  if (await this.getProperty(ReadiumCSS.FONT_SIZE_KEY)) {
47304
47373
  html.style.setProperty(
@@ -47355,42 +47424,57 @@ var _UserSettings = class _UserSettings {
47355
47424
  ((_k = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _k.toString()) ?? null
47356
47425
  );
47357
47426
  if (((_l = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _l.value) === 0) {
47358
- setAttr(rootElement, "data-viewer-theme", "day");
47359
- setAttr(body, "data-viewer-theme", "day");
47427
+ if (rootElement)
47428
+ setAttr(rootElement, "data-viewer-theme", "day");
47429
+ if (body)
47430
+ setAttr(body, "data-viewer-theme", "day");
47360
47431
  } else if (((_m = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _m.value) === 1) {
47361
- setAttr(rootElement, "data-viewer-theme", "sepia");
47362
- setAttr(body, "data-viewer-theme", "sepia");
47432
+ if (rootElement)
47433
+ setAttr(rootElement, "data-viewer-theme", "sepia");
47434
+ if (body)
47435
+ setAttr(body, "data-viewer-theme", "sepia");
47363
47436
  } else if (((_n = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _n.value) === 2) {
47364
- setAttr(rootElement, "data-viewer-theme", "night");
47365
- setAttr(body, "data-viewer-theme", "night");
47437
+ if (rootElement)
47438
+ setAttr(rootElement, "data-viewer-theme", "night");
47439
+ if (body)
47440
+ setAttr(body, "data-viewer-theme", "night");
47366
47441
  }
47367
47442
  } else {
47368
47443
  html.style.setProperty(
47369
47444
  ReadiumCSS.APPEARANCE_KEY,
47370
47445
  ((_o = this.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _o.toString()) ?? null
47371
47446
  );
47372
- setAttr(rootElement, "data-viewer-theme", "day");
47373
- setAttr(body, "data-viewer-theme", "day");
47447
+ if (rootElement)
47448
+ setAttr(rootElement, "data-viewer-theme", "day");
47449
+ if (body)
47450
+ setAttr(body, "data-viewer-theme", "day");
47374
47451
  }
47375
- if ((_p = this.view) == null ? void 0 : _p.navigator.publication.isReflowable) {
47452
+ if ((_p = this.view) == null ? void 0 : _p.navigator.publication.isFixedLayout) {
47453
+ if (await this.getProperty(ReadiumCSS.DIRECTION_KEY)) {
47454
+ let value = ((_q = this.userProperties.getByRef(ReadiumCSS.DIRECTION_REF)) == null ? void 0 : _q.toString()) ?? null;
47455
+ html.style.setProperty(ReadiumCSS.DIRECTION_KEY, value);
47456
+ this.view.navigator.setDirection(value);
47457
+ }
47458
+ }
47459
+ if ((_r = this.view) == null ? void 0 : _r.navigator.publication.isReflowable) {
47376
47460
  if (await this.getProperty(ReadiumCSS.FONT_FAMILY_KEY)) {
47377
47461
  html.style.setProperty(
47378
47462
  ReadiumCSS.FONT_FAMILY_KEY,
47379
- ((_q = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _q.toString()) ?? null
47463
+ ((_s = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _s.toString()) ?? null
47380
47464
  );
47381
- if (((_r = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _r.value) === 0) {
47465
+ if (((_t = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _t.value) === 0) {
47382
47466
  setAttr(html, "data-viewer-font", "publisher");
47383
47467
  html.style.setProperty(
47384
47468
  ReadiumCSS.FONT_OVERRIDE_KEY,
47385
47469
  "readium-font-off"
47386
47470
  );
47387
- } else if (((_s = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _s.value) === 1) {
47471
+ } else if (((_u = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _u.value) === 1) {
47388
47472
  setAttr(html, "data-viewer-font", "serif");
47389
47473
  html.style.setProperty(
47390
47474
  ReadiumCSS.FONT_OVERRIDE_KEY,
47391
47475
  "readium-font-on"
47392
47476
  );
47393
- } else if (((_t = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _t.value) === 2) {
47477
+ } else if (((_v = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _v.value) === 2) {
47394
47478
  setAttr(html, "data-viewer-font", "sans");
47395
47479
  html.style.setProperty(
47396
47480
  ReadiumCSS.FONT_OVERRIDE_KEY,
@@ -47415,7 +47499,7 @@ var _UserSettings = class _UserSettings {
47415
47499
  } else {
47416
47500
  html.style.setProperty(
47417
47501
  ReadiumCSS.FONT_FAMILY_KEY,
47418
- ((_u = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _u.toString()) ?? null
47502
+ ((_w = this.userProperties.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _w.toString()) ?? null
47419
47503
  );
47420
47504
  setAttr(html, "data-viewer-font", "publisher");
47421
47505
  html.style.setProperty(
@@ -47424,7 +47508,7 @@ var _UserSettings = class _UserSettings {
47424
47508
  );
47425
47509
  }
47426
47510
  if (await this.getProperty(ReadiumCSS.SCROLL_KEY)) {
47427
- if (((_v = this.userProperties.getByRef(ReadiumCSS.SCROLL_REF)) == null ? void 0 : _v.value) === true) {
47511
+ if (((_x = this.userProperties.getByRef(ReadiumCSS.SCROLL_REF)) == null ? void 0 : _x.value) === true) {
47428
47512
  html.style.setProperty("--USER__scroll", "readium-scroll-on");
47429
47513
  } else {
47430
47514
  html.style.setProperty("--USER__scroll", "readium-scroll-off");
@@ -47491,24 +47575,25 @@ var _UserSettings = class _UserSettings {
47491
47575
  this.applyProperties();
47492
47576
  }
47493
47577
  async updateUserSettings() {
47494
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
47578
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
47495
47579
  let userSettings = {
47496
47580
  fontFamily: _UserSettings.fontFamilyValues[await ((_b = (_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.FONT_FAMILY_REF)) == null ? void 0 : _b.value)],
47497
47581
  fontSize: (_d = (_c = this.userProperties) == null ? void 0 : _c.getByRef(ReadiumCSS.FONT_SIZE_REF)) == null ? void 0 : _d.value,
47498
47582
  appearance: _UserSettings.appearanceValues[await ((_f = (_e = this.userProperties) == null ? void 0 : _e.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _f.value)],
47499
47583
  textAlignment: _UserSettings.textAlignmentValues[await ((_h = (_g = this.userProperties) == null ? void 0 : _g.getByRef(ReadiumCSS.TEXT_ALIGNMENT_REF)) == null ? void 0 : _h.value)],
47500
47584
  columnCount: _UserSettings.columnCountValues[await ((_j = (_i = this.userProperties) == null ? void 0 : _i.getByRef(ReadiumCSS.COLUMN_COUNT_REF)) == null ? void 0 : _j.value)],
47501
- wordSpacing: (_l = (_k = this.userProperties) == null ? void 0 : _k.getByRef(ReadiumCSS.WORD_SPACING_REF)) == null ? void 0 : _l.value,
47502
- letterSpacing: (_n = (_m = this.userProperties) == null ? void 0 : _m.getByRef(
47585
+ direction: _UserSettings.directionValues[await ((_l = (_k = this.userProperties) == null ? void 0 : _k.getByRef(ReadiumCSS.DIRECTION_REF)) == null ? void 0 : _l.value)],
47586
+ wordSpacing: (_n = (_m = this.userProperties) == null ? void 0 : _m.getByRef(ReadiumCSS.WORD_SPACING_REF)) == null ? void 0 : _n.value,
47587
+ letterSpacing: (_p = (_o = this.userProperties) == null ? void 0 : _o.getByRef(
47503
47588
  ReadiumCSS.LETTER_SPACING_REF
47504
- )) == null ? void 0 : _n.value,
47589
+ )) == null ? void 0 : _p.value,
47505
47590
  // publisherDefault: this.userProperties.getByRef(
47506
47591
  // ReadiumCSS.PUBLISHER_DEFAULT_REF
47507
47592
  // ).value,
47508
- verticalScroll: (_p = (_o = this.userProperties) == null ? void 0 : _o.getByRef(ReadiumCSS.SCROLL_REF)) == null ? void 0 : _p.value
47593
+ verticalScroll: (_r = (_q = this.userProperties) == null ? void 0 : _q.getByRef(ReadiumCSS.SCROLL_REF)) == null ? void 0 : _r.value
47509
47594
  };
47510
- if ((_q = this.api) == null ? void 0 : _q.updateSettings) {
47511
- (_r = this.api) == null ? void 0 : _r.updateSettings(userSettings).then((_) => {
47595
+ if ((_s = this.api) == null ? void 0 : _s.updateSettings) {
47596
+ (_t = this.api) == null ? void 0 : _t.updateSettings(userSettings).then((_) => {
47512
47597
  import_loglevel2.default.log("api updated user settings", JSON.stringify(userSettings));
47513
47598
  });
47514
47599
  }
@@ -47528,6 +47613,12 @@ var _UserSettings = class _UserSettings {
47528
47613
  ReadiumCSS.COLUMN_COUNT_REF,
47529
47614
  ReadiumCSS.COLUMN_COUNT_KEY
47530
47615
  );
47616
+ userProperties.addEnumerable(
47617
+ this.direction,
47618
+ _UserSettings.directionValues,
47619
+ ReadiumCSS.DIRECTION_REF,
47620
+ ReadiumCSS.DIRECTION_KEY
47621
+ );
47531
47622
  userProperties.addEnumerable(
47532
47623
  this.appearance,
47533
47624
  _UserSettings.appearanceValues,
@@ -47642,7 +47733,7 @@ var _UserSettings = class _UserSettings {
47642
47733
  this.settingsChangeCallback();
47643
47734
  }
47644
47735
  get currentSettings() {
47645
- var _a, _b, _c, _d, _e, _f, _g, _h;
47736
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
47646
47737
  return {
47647
47738
  appearance: _UserSettings.appearanceValues[(_b = (_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.APPEARANCE_REF)) == null ? void 0 : _b.value],
47648
47739
  //readium-default-on, readium-night-on, readium-sepia-on
@@ -47652,6 +47743,8 @@ var _UserSettings = class _UserSettings {
47652
47743
  //"auto", "justify", "start"
47653
47744
  columnCount: _UserSettings.columnCountValues[(_h = (_g = this.userProperties) == null ? void 0 : _g.getByRef(ReadiumCSS.COLUMN_COUNT_REF)) == null ? void 0 : _h.value],
47654
47745
  // "auto", "1", "2"
47746
+ direction: _UserSettings.directionValues[(_j = (_i = this.userProperties) == null ? void 0 : _i.getByRef(ReadiumCSS.DIRECTION_REF)) == null ? void 0 : _j.value],
47747
+ // "auto", "ltr", "rtl"
47655
47748
  verticalScroll: this.verticalScroll,
47656
47749
  fontSize: this.fontSize,
47657
47750
  wordSpacing: this.wordSpacing,
@@ -47661,7 +47754,7 @@ var _UserSettings = class _UserSettings {
47661
47754
  };
47662
47755
  }
47663
47756
  async applyUserSettings(userSettings) {
47664
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
47757
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
47665
47758
  if (userSettings.appearance) {
47666
47759
  this.appearance = _UserSettings.parseAppearanceSetting(
47667
47760
  userSettings.appearance
@@ -47717,11 +47810,21 @@ var _UserSettings = class _UserSettings {
47717
47810
  }
47718
47811
  this.settingsColumnsChangeCallback();
47719
47812
  }
47813
+ if (userSettings.direction) {
47814
+ this.direction = _UserSettings.directionValues.findIndex(
47815
+ (el) => el === userSettings.direction
47816
+ );
47817
+ let prop = (_g = this.userProperties) == null ? void 0 : _g.getByRef(ReadiumCSS.DIRECTION_REF);
47818
+ if (prop) {
47819
+ prop.value = this.direction;
47820
+ await this.storeProperty(prop);
47821
+ }
47822
+ }
47720
47823
  if (userSettings.textAlignment) {
47721
47824
  this.textAlignment = _UserSettings.textAlignmentValues.findIndex(
47722
47825
  (el) => el === userSettings.textAlignment
47723
47826
  );
47724
- let prop = (_g = this.userProperties) == null ? void 0 : _g.getByRef(ReadiumCSS.TEXT_ALIGNMENT_REF);
47827
+ let prop = (_h = this.userProperties) == null ? void 0 : _h.getByRef(ReadiumCSS.TEXT_ALIGNMENT_REF);
47725
47828
  if (prop) {
47726
47829
  prop.value = this.textAlignment;
47727
47830
  await this.storeProperty(prop);
@@ -47729,7 +47832,7 @@ var _UserSettings = class _UserSettings {
47729
47832
  }
47730
47833
  if (userSettings.lineHeight) {
47731
47834
  this.lineHeight = userSettings.lineHeight;
47732
- let prop = (_h = this.userProperties) == null ? void 0 : _h.getByRef(ReadiumCSS.LINE_HEIGHT_REF);
47835
+ let prop = (_i = this.userProperties) == null ? void 0 : _i.getByRef(ReadiumCSS.LINE_HEIGHT_REF);
47733
47836
  if (prop) {
47734
47837
  prop.value = this.lineHeight;
47735
47838
  await this.storeProperty(prop);
@@ -47737,25 +47840,25 @@ var _UserSettings = class _UserSettings {
47737
47840
  }
47738
47841
  if (userSettings.pageMargins) {
47739
47842
  this.pageMargins = userSettings.pageMargins;
47740
- let prop = (_i = this.userProperties) == null ? void 0 : _i.getByRef(ReadiumCSS.PAGE_MARGINS_REF);
47843
+ let prop = (_j = this.userProperties) == null ? void 0 : _j.getByRef(ReadiumCSS.PAGE_MARGINS_REF);
47741
47844
  if (prop) {
47742
47845
  prop.value = this.pageMargins;
47743
47846
  await this.storeProperty(prop);
47744
47847
  }
47745
47848
  }
47746
47849
  if (userSettings.verticalScroll !== void 0) {
47747
- const position = (_j = this.view) == null ? void 0 : _j.getCurrentPosition();
47850
+ const position = (_k = this.view) == null ? void 0 : _k.getCurrentPosition();
47748
47851
  this.verticalScroll = _UserSettings.parseScrollSetting(
47749
47852
  userSettings.verticalScroll
47750
47853
  );
47751
- let prop = (_k = this.userProperties) == null ? void 0 : _k.getByRef(ReadiumCSS.SCROLL_REF);
47854
+ let prop = (_l = this.userProperties) == null ? void 0 : _l.getByRef(ReadiumCSS.SCROLL_REF);
47752
47855
  if (prop) {
47753
47856
  prop.value = this.verticalScroll;
47754
47857
  await this.saveProperty(prop);
47755
47858
  }
47756
- (_m = (_l = this.view) == null ? void 0 : _l.setMode) == null ? void 0 : _m.call(_l, this.verticalScroll);
47859
+ (_n = (_m = this.view) == null ? void 0 : _m.setMode) == null ? void 0 : _n.call(_m, this.verticalScroll);
47757
47860
  if (position) {
47758
- (_n = this.view) == null ? void 0 : _n.goToProgression(position);
47861
+ (_o = this.view) == null ? void 0 : _o.goToProgression(position);
47759
47862
  }
47760
47863
  this.viewChangeCallback();
47761
47864
  }
@@ -47916,6 +48019,7 @@ _UserSettings.appearanceValues = [
47916
48019
  _UserSettings.fontFamilyValues = ["Original", "serif", "sans-serif"];
47917
48020
  _UserSettings.textAlignmentValues = ["auto", "justify", "start"];
47918
48021
  _UserSettings.columnCountValues = ["auto", "1", "2"];
48022
+ _UserSettings.directionValues = ["auto", "ltr", "rtl"];
47919
48023
  var UserSettings = _UserSettings;
47920
48024
 
47921
48025
  // src/modules/AnnotationModule.ts
@@ -49649,17 +49753,13 @@ var TextHighlighter = class _TextHighlighter {
49649
49753
  );
49650
49754
  return new Promise((resolve) => resolve(module2));
49651
49755
  }
49652
- async initialize() {
49756
+ async initialize(iframe) {
49653
49757
  var _a;
49654
- let doc = this.navigator.iframes[0].contentDocument;
49758
+ let doc = iframe.contentDocument;
49655
49759
  if (doc) {
49656
49760
  this.dom(doc.body).addClass(this.options.contextClass);
49657
49761
  }
49658
- this.bindEvents(
49659
- (_a = this.navigator.iframes[0].contentDocument) == null ? void 0 : _a.body,
49660
- this,
49661
- this.hasEventListener
49662
- );
49762
+ this.bindEvents((_a = iframe.contentDocument) == null ? void 0 : _a.body, this, this.hasEventListener);
49663
49763
  this.initializeToolbox();
49664
49764
  lastMouseDownX = -1;
49665
49765
  lastMouseDownY = -1;
@@ -49672,7 +49772,7 @@ var TextHighlighter = class _TextHighlighter {
49672
49772
  }
49673
49773
  setTimeout(async () => {
49674
49774
  var _a2;
49675
- let doc2 = this.navigator.iframes[0].contentDocument;
49775
+ let doc2 = iframe.contentDocument;
49676
49776
  if (doc2) {
49677
49777
  await ((_a2 = doc2.body) == null ? void 0 : _a2.addEventListener("click", unselect));
49678
49778
  }
@@ -52301,8 +52401,8 @@ var ConsumptionModule = class {
52301
52401
  import_loglevel7.default.log("Consumption module stop");
52302
52402
  this.endResearchSession();
52303
52403
  }
52304
- initialize() {
52305
- let win = this.navigator.iframes[0].contentWindow;
52404
+ initialize(iframe) {
52405
+ let win = iframe.contentWindow;
52306
52406
  if (win) {
52307
52407
  const self2 = this;
52308
52408
  win.onload = function() {
@@ -52536,7 +52636,7 @@ var AnnotationModule = class _AnnotationModule {
52536
52636
  await this.showHighlights();
52537
52637
  }, 200);
52538
52638
  }
52539
- initialize() {
52639
+ initialize(iframe) {
52540
52640
  return new Promise(async (resolve) => {
52541
52641
  await document.fonts.ready;
52542
52642
  if (this.rights.enableAnnotations) {
@@ -52545,7 +52645,7 @@ var AnnotationModule = class _AnnotationModule {
52545
52645
  this.drawHighlights();
52546
52646
  this.showHighlights();
52547
52647
  addEventListenerOptional(
52548
- (_a = this.navigator.iframes[0].contentDocument) == null ? void 0 : _a.body,
52648
+ (_a = iframe.contentDocument) == null ? void 0 : _a.body,
52549
52649
  "click",
52550
52650
  this.click.bind(this)
52551
52651
  );
@@ -54267,7 +54367,9 @@ var MediaOverlaySettings = class {
54267
54367
  var _a, _b;
54268
54368
  if (incremental === "mo_volume") {
54269
54369
  this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF).increment();
54270
- this.volume = (_a = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF)) == null ? void 0 : _a.value;
54370
+ this.volume = (_a = this.userProperties.getByRef(
54371
+ MEDIAOVERLAYREFS.VOLUME_REF
54372
+ )) == null ? void 0 : _a.value;
54271
54373
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF);
54272
54374
  if (prop) {
54273
54375
  this.storeProperty(prop);
@@ -54275,7 +54377,9 @@ var MediaOverlaySettings = class {
54275
54377
  this.settingsChangeCallback();
54276
54378
  } else if (incremental === "mo_rate") {
54277
54379
  this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF).increment();
54278
- this.rate = (_b = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF)) == null ? void 0 : _b.value;
54380
+ this.rate = (_b = this.userProperties.getByRef(
54381
+ MEDIAOVERLAYREFS.RATE_REF
54382
+ )) == null ? void 0 : _b.value;
54279
54383
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF);
54280
54384
  if (prop) {
54281
54385
  this.storeProperty(prop);
@@ -54287,7 +54391,9 @@ var MediaOverlaySettings = class {
54287
54391
  var _a, _b;
54288
54392
  if (incremental === "mo_volume") {
54289
54393
  this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF).decrement();
54290
- this.volume = (_a = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF)) == null ? void 0 : _a.value;
54394
+ this.volume = (_a = this.userProperties.getByRef(
54395
+ MEDIAOVERLAYREFS.VOLUME_REF
54396
+ )) == null ? void 0 : _a.value;
54291
54397
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.VOLUME_REF);
54292
54398
  if (prop) {
54293
54399
  this.storeProperty(prop);
@@ -54295,7 +54401,9 @@ var MediaOverlaySettings = class {
54295
54401
  this.settingsChangeCallback();
54296
54402
  } else if (incremental === "mo_rate") {
54297
54403
  this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF).decrement();
54298
- this.rate = (_b = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF)) == null ? void 0 : _b.value;
54404
+ this.rate = (_b = this.userProperties.getByRef(
54405
+ MEDIAOVERLAYREFS.RATE_REF
54406
+ )) == null ? void 0 : _b.value;
54299
54407
  let prop = this.userProperties.getByRef(MEDIAOVERLAYREFS.RATE_REF);
54300
54408
  if (prop) {
54301
54409
  this.storeProperty(prop);
@@ -57087,35 +57195,33 @@ var ContentProtectionModule = class {
57087
57195
  this.preventDrag(true);
57088
57196
  }
57089
57197
  }
57090
- async initialize() {
57198
+ async initialize(iframe) {
57091
57199
  var _a;
57092
57200
  if ((_a = this.properties) == null ? void 0 : _a.enableObfuscation) {
57093
57201
  return new Promise(async (resolve) => {
57094
57202
  await document.fonts.ready;
57095
- for (const iframe of this.navigator.iframes) {
57096
- if (iframe.contentDocument) {
57097
- const body = findRequiredIframeElement(
57098
- iframe.contentDocument,
57099
- "body"
57203
+ if (iframe.contentDocument) {
57204
+ const body = findRequiredIframeElement(
57205
+ iframe.contentDocument,
57206
+ "body"
57207
+ );
57208
+ this.observe();
57209
+ setTimeout(() => {
57210
+ this.rects = this.findRects(body);
57211
+ this.rects.forEach(
57212
+ (rect) => this.toggleRect(rect, this.securityContainer, this.isHacked)
57100
57213
  );
57101
- this.observe();
57102
- setTimeout(() => {
57103
- this.rects = this.findRects(body);
57104
- this.rects.forEach(
57105
- (rect) => this.toggleRect(rect, this.securityContainer, this.isHacked)
57214
+ this.setupEvents();
57215
+ if (!this.hasEventListener) {
57216
+ this.hasEventListener = true;
57217
+ addEventListenerOptional(
57218
+ this.wrapper,
57219
+ "scroll",
57220
+ this.handleScroll.bind(this)
57106
57221
  );
57107
- this.setupEvents();
57108
- if (!this.hasEventListener) {
57109
- this.hasEventListener = true;
57110
- addEventListenerOptional(
57111
- this.wrapper,
57112
- "scroll",
57113
- this.handleScroll.bind(this)
57114
- );
57115
- }
57116
- resolve();
57117
- }, 10);
57118
- }
57222
+ }
57223
+ resolve();
57224
+ }, 10);
57119
57225
  }
57120
57226
  });
57121
57227
  }
@@ -58888,6 +58994,8 @@ var KeyboardEventHandler = class {
58888
58994
  };
58889
58995
  this.onForwardSwipe = () => {
58890
58996
  };
58997
+ this.onKeydown = () => {
58998
+ };
58891
58999
  this.setupEvents = (element) => {
58892
59000
  if (element) {
58893
59001
  this.focusin(element);
@@ -58915,6 +59023,7 @@ var KeyboardEventHandler = class {
58915
59023
  // when removing the event listeners
58916
59024
  this.handlers = {};
58917
59025
  this.navigator = navigator2;
59026
+ this.rtl = false;
58918
59027
  }
58919
59028
  onFocusIn(self2) {
58920
59029
  return this.handlers["onFocusIn"] || (this.handlers["onFocusIn"] = function(event) {
@@ -58937,21 +59046,23 @@ var KeyboardEventHandler = class {
58937
59046
  const key = event.key;
58938
59047
  switch (key) {
58939
59048
  case "ArrowRight":
58940
- self2.onForwardSwipe(event);
58941
- break;
59049
+ self2.rtl ? self2.onBackwardSwipe(event) : self2.onForwardSwipe(event);
59050
+ return;
58942
59051
  case "ArrowLeft":
58943
- self2.onBackwardSwipe(event);
58944
- break;
59052
+ self2.rtl ? self2.onForwardSwipe(event) : self2.onBackwardSwipe(event);
59053
+ return;
58945
59054
  }
58946
59055
  switch (event.code) {
58947
59056
  case "Space":
58948
59057
  if (event.ctrlKey) {
58949
59058
  self2.onBackwardSwipe(event);
59059
+ return;
58950
59060
  } else {
58951
59061
  self2.onForwardSwipe(event);
59062
+ return;
58952
59063
  }
58953
- break;
58954
59064
  }
59065
+ self2.onKeydown(event);
58955
59066
  });
58956
59067
  }
58957
59068
  };
@@ -60530,7 +60641,7 @@ var LineFocusModule = class {
60530
60641
  }
60531
60642
  }
60532
60643
  }
60533
- initialize() {
60644
+ initialize(iframe) {
60534
60645
  return new Promise(async (resolve) => {
60535
60646
  await document.fonts.ready;
60536
60647
  if (!this.hasEventListener) {
@@ -60538,12 +60649,12 @@ var LineFocusModule = class {
60538
60649
  addEventListenerOptional(document, "keydown", this.keydown.bind(this));
60539
60650
  addEventListenerOptional(document, "keyup", this.keyup.bind(this));
60540
60651
  addEventListenerOptional(
60541
- this.navigator.iframes[0].contentDocument,
60652
+ iframe.contentDocument,
60542
60653
  "keydown",
60543
60654
  this.keydown.bind(this)
60544
60655
  );
60545
60656
  addEventListenerOptional(
60546
- this.navigator.iframes[0].contentDocument,
60657
+ iframe.contentDocument,
60547
60658
  "keyup",
60548
60659
  this.keyup.bind(this)
60549
60660
  );
@@ -61039,7 +61150,6 @@ var HistoryModule = class {
61039
61150
  }
61040
61151
  }
61041
61152
  async push(locator, history) {
61042
- let lastInHistory;
61043
61153
  if (history && this.annotator) {
61044
61154
  let lastReadingPosition = await this.annotator.getLastReadingPosition();
61045
61155
  if (lastReadingPosition) {
@@ -61054,12 +61164,18 @@ var HistoryModule = class {
61054
61164
  } else if ((lastReadingPosition == null ? void 0 : lastReadingPosition.locations.progression) && (lastReadingPosition == null ? void 0 : lastReadingPosition.locations.progression) > 0) {
61055
61165
  this.history.push(lastReadingPosition);
61056
61166
  this.historyCurrentIndex = this.history.length - 1;
61167
+ } else {
61168
+ const lastInHistory2 = this.history[this.history.length - 1];
61169
+ if (lastInHistory2 && lastInHistory2.href !== locator.href && lastInHistory2.locations !== locator.locations || lastInHistory2 === void 0) {
61170
+ this.history.push(lastReadingPosition);
61171
+ this.historyCurrentIndex = this.history.length - 1;
61172
+ }
61057
61173
  }
61058
61174
  }
61059
61175
  if (this.historyCurrentIndex < this.history.length - 1) {
61060
61176
  this.history = this.history.slice(0, this.historyCurrentIndex);
61061
61177
  }
61062
- lastInHistory = this.history[this.history.length - 1];
61178
+ const lastInHistory = this.history[this.history.length - 1];
61063
61179
  if (lastInHistory && lastInHistory.href !== locator.href || lastInHistory === void 0) {
61064
61180
  this.history.push(locator);
61065
61181
  this.historyCurrentIndex = this.history.length - 1;
@@ -61604,6 +61720,24 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61604
61720
  if (this.didInitKeyboardEventHandler)
61605
61721
  this.keyboardEventHandler.removeEvents(document);
61606
61722
  }
61723
+ setDirection(direction) {
61724
+ var _a, _b;
61725
+ let dir = "";
61726
+ if (direction === "rtl" || direction === "ltr")
61727
+ dir = direction;
61728
+ if (direction === "auto")
61729
+ dir = this.publication.Metadata.Direction2;
61730
+ if (dir) {
61731
+ if (dir === "rtl")
61732
+ this.spreads.style.flexDirection = "row-reverse";
61733
+ if (dir === "ltr")
61734
+ this.spreads.style.flexDirection = "row";
61735
+ this.keyboardEventHandler.rtl = dir === "rtl";
61736
+ if ((_a = this.api) == null ? void 0 : _a.direction)
61737
+ (_b = this.api) == null ? void 0 : _b.direction(dir);
61738
+ this.emit("direction", dir);
61739
+ }
61740
+ }
61607
61741
  async start(mainElement, headerMenu, footerMenu) {
61608
61742
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
61609
61743
  this.headerMenu = headerMenu;
@@ -61643,6 +61777,19 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61643
61777
  this.spreads.appendChild(this.firstSpread);
61644
61778
  this.firstSpread.appendChild(this.iframes[0]);
61645
61779
  wrapper.appendChild(this.spreads);
61780
+ let dir = "";
61781
+ switch (this.settings.direction) {
61782
+ case 0:
61783
+ dir = "auto";
61784
+ break;
61785
+ case 1:
61786
+ dir = "ltr";
61787
+ break;
61788
+ case 2:
61789
+ dir = "rtl";
61790
+ break;
61791
+ }
61792
+ this.setDirection(dir);
61646
61793
  } else {
61647
61794
  iframe3.setAttribute("height", "100%");
61648
61795
  iframe3.setAttribute("width", "100%");
@@ -61914,7 +62061,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61914
62061
  addEventListenerOptional(
61915
62062
  iframe,
61916
62063
  "load",
61917
- this.handleIFrameLoad.bind(this)
62064
+ this.handleIFrameLoad.bind(this, iframe)
61918
62065
  );
61919
62066
  }
61920
62067
  addEventListenerOptional(
@@ -61978,9 +62125,13 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61978
62125
  this.nextChapterBottomAnchorElement.style.display = "none";
61979
62126
  if (this.previousChapterTopAnchorElement)
61980
62127
  this.previousChapterTopAnchorElement.style.display = "none";
62128
+ if (this.eventHandler) {
62129
+ this.eventHandler.onClickThrough = this.handleClickThrough.bind(this);
62130
+ }
61981
62131
  if (this.keyboardEventHandler) {
61982
62132
  this.keyboardEventHandler.onBackwardSwipe = this.handlePreviousChapterClick.bind(this);
61983
62133
  this.keyboardEventHandler.onForwardSwipe = this.handleNextChapterClick.bind(this);
62134
+ this.keyboardEventHandler.onKeydown = this.handleKeydownFallthrough.bind(this);
61984
62135
  }
61985
62136
  if (this.touchEventHandler) {
61986
62137
  this.touchEventHandler.onBackwardSwipe = this.handlePreviousPageClick.bind(this);
@@ -62020,6 +62171,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62020
62171
  if (this.keyboardEventHandler) {
62021
62172
  this.keyboardEventHandler.onBackwardSwipe = this.handlePreviousPageClick.bind(this);
62022
62173
  this.keyboardEventHandler.onForwardSwipe = this.handleNextPageClick.bind(this);
62174
+ this.keyboardEventHandler.onKeydown = this.handleKeydownFallthrough.bind(this);
62023
62175
  }
62024
62176
  } else {
62025
62177
  if (this.infoBottom)
@@ -62123,6 +62275,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62123
62275
  if (this.keyboardEventHandler) {
62124
62276
  this.keyboardEventHandler.onBackwardSwipe = this.handlePreviousPageClick.bind(this);
62125
62277
  this.keyboardEventHandler.onForwardSwipe = this.handleNextPageClick.bind(this);
62278
+ this.keyboardEventHandler.onKeydown = this.handleKeydownFallthrough.bind(this);
62126
62279
  }
62127
62280
  }
62128
62281
  });
@@ -62286,8 +62439,8 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62286
62439
  });
62287
62440
  }
62288
62441
  }
62289
- async handleIFrameLoad() {
62290
- var _a, _b, _c, _d, _e, _f;
62442
+ async handleIFrameLoad(iframe) {
62443
+ var _a, _b, _c, _d, _e, _f, _g;
62291
62444
  if (this.errorMessage)
62292
62445
  this.errorMessage.style.display = "none";
62293
62446
  this.showLoadingMessageAfterDelay();
@@ -62377,54 +62530,52 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62377
62530
  if (this.chapterTitle)
62378
62531
  this.chapterTitle.innerHTML = "(Current Chapter)";
62379
62532
  }
62380
- await this.injectInjectablesIntoIframeHead();
62381
- if (this.highlighter !== void 0) {
62382
- await this.highlighter.initialize();
62533
+ await this.injectInjectablesIntoIframeHead(iframe);
62534
+ if (((_a = this.view) == null ? void 0 : _a.layout) !== "fixed" && this.highlighter !== void 0) {
62535
+ await this.highlighter.initialize(iframe);
62383
62536
  }
62384
- const body = (_a = this.iframes[0].contentDocument) == null ? void 0 : _a.body;
62537
+ const body = (_b = iframe.contentDocument) == null ? void 0 : _b.body;
62385
62538
  let details = body == null ? void 0 : body.querySelector("details");
62386
62539
  if (details) {
62387
62540
  let self2 = this;
62388
62541
  details.addEventListener("toggle", async (_event) => {
62389
62542
  var _a2, _b2;
62390
- await ((_b2 = (_a2 = self2.view) == null ? void 0 : _a2.setIframeHeight) == null ? void 0 : _b2.call(_a2, this.iframes[0]));
62543
+ await ((_b2 = (_a2 = self2.view) == null ? void 0 : _a2.setIframeHeight) == null ? void 0 : _b2.call(_a2, iframe));
62391
62544
  });
62392
62545
  }
62393
62546
  if (this.eventHandler) {
62394
- for (const iframe of this.iframes) {
62395
- this.eventHandler.setupEvents(iframe.contentDocument);
62396
- this.touchEventHandler.setupEvents(iframe.contentDocument);
62397
- this.keyboardEventHandler.setupEvents(iframe.contentDocument);
62398
- }
62547
+ this.eventHandler.setupEvents(iframe.contentDocument);
62548
+ this.touchEventHandler.setupEvents(iframe.contentDocument);
62549
+ this.keyboardEventHandler.setupEvents(iframe.contentDocument);
62399
62550
  this.touchEventHandler.setupEvents(this.errorMessage);
62400
62551
  if (!this.didInitKeyboardEventHandler) {
62401
62552
  this.keyboardEventHandler.keydown(document);
62402
62553
  this.didInitKeyboardEventHandler = true;
62403
62554
  }
62404
62555
  }
62405
- if (((_b = this.view) == null ? void 0 : _b.layout) !== "fixed") {
62406
- if ((_c = this.view) == null ? void 0 : _c.isScrollMode()) {
62407
- this.iframes[0].height = "0";
62408
- (_e = (_d = this.view) == null ? void 0 : _d.setIframeHeight) == null ? void 0 : _e.call(_d, this.iframes[0]);
62556
+ if (((_c = this.view) == null ? void 0 : _c.layout) !== "fixed") {
62557
+ if ((_d = this.view) == null ? void 0 : _d.isScrollMode()) {
62558
+ iframe.height = "0";
62559
+ (_f = (_e = this.view) == null ? void 0 : _e.setIframeHeight) == null ? void 0 : _f.call(_e, iframe);
62409
62560
  }
62410
62561
  }
62411
62562
  if (this.rights.enableContentProtection && this.contentProtectionModule) {
62412
- await this.contentProtectionModule.initialize();
62563
+ await this.contentProtectionModule.initialize(iframe);
62413
62564
  }
62414
62565
  if (this.rights.enableConsumption && this.consumptionModule) {
62415
- await this.consumptionModule.initialize();
62566
+ await this.consumptionModule.initialize(iframe);
62416
62567
  }
62417
62568
  if (this.rights.enableAnnotations && this.annotationModule) {
62418
- await this.annotationModule.initialize();
62569
+ await this.annotationModule.initialize(iframe);
62419
62570
  }
62420
62571
  if (this.rights.enableBookmarks && this.bookmarkModule) {
62421
62572
  await this.bookmarkModule.initialize();
62422
62573
  }
62423
62574
  if (this.rights.enableLineFocus && this.lineFocusModule) {
62424
- await this.lineFocusModule.initialize();
62575
+ await this.lineFocusModule.initialize(iframe);
62425
62576
  }
62426
62577
  if (this.rights.enableTTS && this.ttsModule) {
62427
- const body2 = (_f = this.iframes[0].contentDocument) == null ? void 0 : _f.body;
62578
+ const body2 = (_g = iframe.contentDocument) == null ? void 0 : _g.body;
62428
62579
  const ttsModule = this.ttsModule;
62429
62580
  await ttsModule.initialize(body2);
62430
62581
  }
@@ -62435,9 +62586,11 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62435
62586
  await this.mediaOverlayModule.initialize();
62436
62587
  }
62437
62588
  setTimeout(async () => {
62438
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h;
62589
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h;
62439
62590
  if (this.newElementId) {
62440
- const element = this.iframes[0].contentDocument.getElementById(this.newElementId);
62591
+ const element = iframe.contentDocument.getElementById(
62592
+ this.newElementId
62593
+ );
62441
62594
  (_b2 = (_a2 = this.view) == null ? void 0 : _a2.goToElement) == null ? void 0 : _b2.call(_a2, element);
62442
62595
  this.newElementId = void 0;
62443
62596
  } else if (this.newPosition && this.newPosition.highlight) {
@@ -62455,10 +62608,10 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62455
62608
  }
62456
62609
  }
62457
62610
  this.hideLoadingMessage();
62458
- this.showIframeContents();
62611
+ this.showIframeContents(iframe);
62459
62612
  if (this.rights.enableMediaOverlays && this.mediaOverlayModule && this.hasMediaOverlays) {
62460
62613
  let link = this.currentLink();
62461
- await ((_g = this.mediaOverlayModule) == null ? void 0 : _g.initializeResource(link));
62614
+ await ((_g2 = this.mediaOverlayModule) == null ? void 0 : _g2.initializeResource(link));
62462
62615
  }
62463
62616
  await this.updatePositionInfo();
62464
62617
  await ((_h = this.view) == null ? void 0 : _h.setSize());
@@ -62475,7 +62628,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62475
62628
  return Promise.reject(err);
62476
62629
  }
62477
62630
  }
62478
- async injectInjectablesIntoIframeHead() {
62631
+ async injectInjectablesIntoIframeHead(iframe) {
62479
62632
  var _a, _b;
62480
62633
  const injectablesToLoad = [];
62481
62634
  const addLoadingInjectable = (injectable) => {
@@ -62490,55 +62643,53 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62490
62643
  });
62491
62644
  injectablesToLoad.push(loadPromise);
62492
62645
  };
62493
- for (const iframe of this.iframes) {
62494
- const head = (_a = iframe.contentDocument) == null ? void 0 : _a.head;
62495
- if (head) {
62496
- const bases = iframe.contentDocument.getElementsByTagName("base");
62497
- if (bases.length === 0) {
62498
- head.insertBefore(
62499
- _IFrameNavigator.createBase(this.currentChapterLink.href),
62500
- head.firstChild
62501
- );
62502
- }
62503
- (_b = this.injectables) == null ? void 0 : _b.forEach((injectable) => {
62504
- if (injectable.type === "style") {
62505
- if (injectable.fontFamily) {
62506
- this.settings.initAddedFont();
62507
- if (!injectable.systemFont && injectable.url) {
62508
- const link = _IFrameNavigator.createCssLink(injectable.url);
62509
- head.appendChild(link);
62510
- addLoadingInjectable(link);
62511
- }
62512
- } else if (injectable.r2before && injectable.url) {
62513
- const link = _IFrameNavigator.createCssLink(injectable.url);
62514
- head.insertBefore(link, head.firstChild);
62515
- addLoadingInjectable(link);
62516
- } else if (injectable.r2default && injectable.url) {
62517
- const link = _IFrameNavigator.createCssLink(injectable.url);
62518
- head.insertBefore(link, head.childNodes[1]);
62519
- addLoadingInjectable(link);
62520
- } else if (injectable.r2after && injectable.url) {
62521
- if (injectable.appearance) {
62522
- this.settings.initAddedAppearance();
62523
- }
62524
- const link = _IFrameNavigator.createCssLink(injectable.url);
62525
- head.appendChild(link);
62526
- addLoadingInjectable(link);
62527
- } else if (injectable.url) {
62646
+ const head = (_a = iframe.contentDocument) == null ? void 0 : _a.head;
62647
+ if (head) {
62648
+ const bases = iframe.contentDocument.getElementsByTagName("base");
62649
+ if (bases.length === 0) {
62650
+ head.insertBefore(
62651
+ _IFrameNavigator.createBase(this.currentChapterLink.href),
62652
+ head.firstChild
62653
+ );
62654
+ }
62655
+ (_b = this.injectables) == null ? void 0 : _b.forEach((injectable) => {
62656
+ if (injectable.type === "style") {
62657
+ if (injectable.fontFamily) {
62658
+ this.settings.initAddedFont();
62659
+ if (!injectable.systemFont && injectable.url) {
62528
62660
  const link = _IFrameNavigator.createCssLink(injectable.url);
62529
62661
  head.appendChild(link);
62530
62662
  addLoadingInjectable(link);
62531
62663
  }
62532
- } else if (injectable.type === "script" && injectable.url) {
62533
- const script = _IFrameNavigator.createJavascriptLink(
62534
- injectable.url,
62535
- injectable.async ?? false
62536
- );
62537
- head.appendChild(script);
62538
- addLoadingInjectable(script);
62539
- }
62540
- });
62541
- }
62664
+ } else if (injectable.r2before && injectable.url) {
62665
+ const link = _IFrameNavigator.createCssLink(injectable.url);
62666
+ head.insertBefore(link, head.firstChild);
62667
+ addLoadingInjectable(link);
62668
+ } else if (injectable.r2default && injectable.url) {
62669
+ const link = _IFrameNavigator.createCssLink(injectable.url);
62670
+ head.insertBefore(link, head.childNodes[1]);
62671
+ addLoadingInjectable(link);
62672
+ } else if (injectable.r2after && injectable.url) {
62673
+ if (injectable.appearance) {
62674
+ this.settings.initAddedAppearance();
62675
+ }
62676
+ const link = _IFrameNavigator.createCssLink(injectable.url);
62677
+ head.appendChild(link);
62678
+ addLoadingInjectable(link);
62679
+ } else if (injectable.url) {
62680
+ const link = _IFrameNavigator.createCssLink(injectable.url);
62681
+ head.appendChild(link);
62682
+ addLoadingInjectable(link);
62683
+ }
62684
+ } else if (injectable.type === "script" && injectable.url) {
62685
+ const script = _IFrameNavigator.createJavascriptLink(
62686
+ injectable.url,
62687
+ injectable.async ?? false
62688
+ );
62689
+ head.appendChild(script);
62690
+ addLoadingInjectable(script);
62691
+ }
62692
+ });
62542
62693
  }
62543
62694
  if (injectablesToLoad.length === 0) {
62544
62695
  return;
@@ -62856,21 +63007,21 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62856
63007
  }
62857
63008
  } else {
62858
63009
  this.iframes[0].src = "about:blank";
62859
- }
62860
- if (this.iframes.length === 2) {
62861
- this.currentSpreadLinks.right = {
62862
- href: this.currentChapterLink.href
62863
- };
62864
- if (isSameOrigin) {
62865
- this.iframes[1].src = this.currentChapterLink.href;
62866
- } else {
62867
- fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
62868
- writeIframe2Doc.call(
62869
- this,
62870
- content,
62871
- this.currentChapterLink.href
62872
- );
62873
- });
63010
+ if (this.iframes.length === 2) {
63011
+ this.currentSpreadLinks.right = {
63012
+ href: this.currentChapterLink.href
63013
+ };
63014
+ if (isSameOrigin) {
63015
+ this.iframes[1].src = this.currentChapterLink.href;
63016
+ } else {
63017
+ fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
63018
+ writeIframe2Doc.call(
63019
+ this,
63020
+ content,
63021
+ this.currentChapterLink.href
63022
+ );
63023
+ });
63024
+ }
62874
63025
  }
62875
63026
  }
62876
63027
  }
@@ -63247,7 +63398,11 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
63247
63398
  }
63248
63399
  }
63249
63400
  }
63250
- handleClickThrough(_event) {
63401
+ handleClickThrough(event) {
63402
+ var _a, _b;
63403
+ if ((_a = this.api) == null ? void 0 : _a.clickThrough)
63404
+ (_b = this.api) == null ? void 0 : _b.clickThrough(event);
63405
+ this.emit("click", event);
63251
63406
  }
63252
63407
  handleInternalLink(event) {
63253
63408
  const element = event.target;
@@ -63528,6 +63683,12 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
63528
63683
  event.stopPropagation();
63529
63684
  }
63530
63685
  }
63686
+ handleKeydownFallthrough(event) {
63687
+ var _a, _b;
63688
+ if ((_a = this.api) == null ? void 0 : _a.keydownFallthrough)
63689
+ (_b = this.api) == null ? void 0 : _b.keydownFallthrough(event);
63690
+ this.emit("keydown", event);
63691
+ }
63531
63692
  hideView() {
63532
63693
  var _a, _b;
63533
63694
  if (((_a = this.view) == null ? void 0 : _a.layout) !== "fixed") {
@@ -63797,15 +63958,13 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
63797
63958
  }
63798
63959
  }
63799
63960
  }
63800
- showIframeContents() {
63961
+ showIframeContents(iframe) {
63801
63962
  this.isBeingStyled = false;
63802
63963
  setTimeout(() => {
63803
63964
  if (!this.isBeingStyled) {
63804
- this.iframes.forEach((iframe) => {
63805
- iframe.style.opacity = "1";
63806
- iframe.style.border = "none";
63807
- iframe.style.overflow = "hidden";
63808
- });
63965
+ iframe.style.opacity = "1";
63966
+ iframe.style.border = "none";
63967
+ iframe.style.overflow = "hidden";
63809
63968
  }
63810
63969
  }, 150);
63811
63970
  }
@@ -64426,16 +64585,20 @@ var LocalStorageStore = class {
64426
64585
  constructor(config2) {
64427
64586
  this.prefix = config2.prefix;
64428
64587
  this.useLocalStorage = config2.useLocalStorage;
64588
+ this.useStorageType = config2.useStorageType;
64429
64589
  try {
64430
64590
  const testKey = config2.prefix + "-" + String(Math.random());
64431
- if (this.useLocalStorage) {
64591
+ if (this.useStorageType === "memory") {
64592
+ this.fallbackStore = new MemoryStore();
64593
+ } else if (this.useStorageType === "local" || this.useLocalStorage) {
64432
64594
  window.localStorage.setItem(testKey, "test");
64433
64595
  window.localStorage.removeItem(testKey);
64434
- } else {
64596
+ this.fallbackStore = null;
64597
+ } else if (this.useStorageType === "session" || !this.useLocalStorage) {
64435
64598
  window.sessionStorage.setItem(testKey, "test");
64436
64599
  window.sessionStorage.removeItem(testKey);
64600
+ this.fallbackStore = null;
64437
64601
  }
64438
- this.fallbackStore = null;
64439
64602
  } catch (e) {
64440
64603
  this.fallbackStore = new MemoryStore();
64441
64604
  }
@@ -64446,7 +64609,7 @@ var LocalStorageStore = class {
64446
64609
  get(key) {
64447
64610
  let value;
64448
64611
  if (!this.fallbackStore) {
64449
- if (this.useLocalStorage) {
64612
+ if (this.useStorageType === "local" || this.useLocalStorage) {
64450
64613
  value = window.localStorage.getItem(this.getLocalStorageKey(key));
64451
64614
  } else {
64452
64615
  value = window.sessionStorage.getItem(this.getLocalStorageKey(key));
@@ -64458,7 +64621,7 @@ var LocalStorageStore = class {
64458
64621
  }
64459
64622
  set(key, value) {
64460
64623
  if (!this.fallbackStore) {
64461
- if (this.useLocalStorage) {
64624
+ if (this.useStorageType === "local" || this.useLocalStorage) {
64462
64625
  window.localStorage.setItem(this.getLocalStorageKey(key), value);
64463
64626
  } else {
64464
64627
  window.sessionStorage.setItem(this.getLocalStorageKey(key), value);
@@ -64469,7 +64632,7 @@ var LocalStorageStore = class {
64469
64632
  }
64470
64633
  remove(key) {
64471
64634
  if (!this.fallbackStore) {
64472
- if (this.useLocalStorage) {
64635
+ if (this.useStorageType === "local" || this.useLocalStorage) {
64473
64636
  window.localStorage.removeItem(this.getLocalStorageKey(key));
64474
64637
  } else {
64475
64638
  window.sessionStorage.removeItem(this.getLocalStorageKey(key));
@@ -65416,15 +65579,18 @@ var D2Reader = class _D2Reader {
65416
65579
  }
65417
65580
  const store = new LocalStorageStore({
65418
65581
  prefix: publication.manifestUrl,
65419
- useLocalStorage: initialConfig.useLocalStorage ?? false
65582
+ useLocalStorage: initialConfig.useLocalStorage ?? false,
65583
+ useStorageType: initialConfig.useStorageType
65420
65584
  });
65421
65585
  const settingsStore = new LocalStorageStore({
65422
65586
  prefix: "r2d2bc-reader",
65423
- useLocalStorage: initialConfig.useLocalStorage ?? false
65587
+ useLocalStorage: initialConfig.useLocalStorage ?? false,
65588
+ useStorageType: initialConfig.useStorageType
65424
65589
  });
65425
65590
  const layerStore = new LocalStorageStore({
65426
65591
  prefix: "r2d2bc-layers",
65427
- useLocalStorage: initialConfig.useLocalStorage ?? false
65592
+ useLocalStorage: initialConfig.useLocalStorage ?? false,
65593
+ useStorageType: initialConfig.useStorageType
65428
65594
  });
65429
65595
  const annotator = new LocalAnnotator({ store });
65430
65596
  publication.sample = initialConfig.sample;