@inappstory/react-sdk 1.7.9 → 1.7.11

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.
@@ -1,7 +1,5 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_isFunction_js_8e5fd566__ from "lodash/isFunction.js";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE_uuid__ from "uuid";
3
- import * as __WEBPACK_EXTERNAL_MODULE_lodash_isObject_js_84bb7d23__ from "lodash/isObject.js";
4
- import * as __WEBPACK_EXTERNAL_MODULE_lodash_isNil_js_d3a2677a__ from "lodash/isNil.js";
5
3
  import * as __WEBPACK_EXTERNAL_MODULE_mobx__ from "mobx";
6
4
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_isString_js_204e00fb__ from "lodash/isString.js";
7
5
  import * as __WEBPACK_EXTERNAL_MODULE_bowser__ from "bowser";
@@ -12,6 +10,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_lodash_debounce_js_35379ba8__ from "lodash
12
10
  import * as __WEBPACK_EXTERNAL_MODULE__inappstory_slide_api_2e636188__ from "@inappstory/slide-api";
13
11
  import * as __WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__ from "async-mutex";
14
12
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_isEmpty_js_f1e1789b__ from "lodash/isEmpty.js";
13
+ import * as __WEBPACK_EXTERNAL_MODULE_lodash_isObject_js_84bb7d23__ from "lodash/isObject.js";
15
14
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_isNumber_js_09f2ee09__ from "lodash/isNumber.js";
16
15
  import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_179142b8__ from "react/jsx-runtime";
17
16
  import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
@@ -2175,7 +2174,7 @@ function convertModelToFormData(formData, data, previousKey) {
2175
2174
  ;// CONCATENATED MODULE: ../core/src/api/exceptions/apiRequestError.ts
2176
2175
  class ApiRequestError extends Error {
2177
2176
  constructor(networkStatus, networkMessage, response) {
2178
- super();
2177
+ super(networkMessage);
2179
2178
  Object.defineProperty(this, "name", {
2180
2179
  enumerable: true,
2181
2180
  configurable: true,
@@ -2204,7 +2203,7 @@ class ApiRequestError extends Error {
2204
2203
  this.networkStatus = networkStatus;
2205
2204
  this.networkMessage = networkMessage;
2206
2205
  this.response = response !== null && response !== void 0 ? response : null;
2207
- console.error({ name: this.name, networkStatus, networkMessage, response });
2206
+ /* console.error({ name: this.name, networkStatus, networkMessage, response }); */
2208
2207
  }
2209
2208
  static createByRequestError(response) {
2210
2209
  return new ApiRequestError(null, JSON.stringify(response.data), response);
@@ -2212,23 +2211,13 @@ class ApiRequestError extends Error {
2212
2211
  static createByFetchError(error) {
2213
2212
  const isOnline = window.navigator && window.navigator.onLine;
2214
2213
  if (isOnline)
2215
- return new ApiRequestError(null, error.message);
2214
+ return new ApiRequestError(null, error.name === "AbortError"
2215
+ ? "The operation was aborted by the AbortController signal. Make sure you don't destroy the InAppStoryManager while it's running."
2216
+ : error.message);
2216
2217
  return new ApiRequestError(null, "net::ERR_INTERNET_DISCONNECTED");
2217
2218
  }
2218
2219
  }
2219
2220
 
2220
- ;// CONCATENATED MODULE: external "lodash/isObject.js"
2221
- var isObject_js_x = (y) => {
2222
- var x = {}; __webpack_require__.d(x, y); return x
2223
- }
2224
- var isObject_js_y = (x) => (() => (x))
2225
- const isObject_js_namespaceObject = isObject_js_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_lodash_isObject_js_84bb7d23__["default"]) });
2226
- ;// CONCATENATED MODULE: external "lodash/isNil.js"
2227
- var isNil_js_x = (y) => {
2228
- var x = {}; __webpack_require__.d(x, y); return x
2229
- }
2230
- var isNil_js_y = (x) => (() => (x))
2231
- const isNil_js_namespaceObject = isNil_js_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_lodash_isNil_js_d3a2677a__["default"]) });
2232
2221
  ;// CONCATENATED MODULE: ../core/src/helpers/classificators/isNumeric.ts
2233
2222
  function isNumeric(str) {
2234
2223
  if (typeof str != "string")
@@ -3116,6 +3105,41 @@ class DeviceDescriptor {
3116
3105
  }
3117
3106
  const deviceDescriptor = new DeviceDescriptor();
3118
3107
 
3108
+ ;// CONCATENATED MODULE: ../core/src/api/InterceptorManager.ts
3109
+ class InterceptorManager {
3110
+ constructor() {
3111
+ Object.defineProperty(this, "handlers", {
3112
+ enumerable: true,
3113
+ configurable: true,
3114
+ writable: true,
3115
+ value: []
3116
+ });
3117
+ }
3118
+ use(fulfilled, rejected) {
3119
+ this.handlers.push({ fulfilled, rejected });
3120
+ return this.handlers.length - 1;
3121
+ }
3122
+ async run(value) {
3123
+ let current = Promise.resolve(value);
3124
+ for (const h of this.handlers) {
3125
+ current = current.then(h.fulfilled, h.rejected);
3126
+ }
3127
+ return current;
3128
+ }
3129
+ }
3130
+
3131
+ ;// CONCATENATED MODULE: ../core/src/api/exceptions/apiAbortRequestError.ts
3132
+ class IasAbortRequestError extends Error {
3133
+ constructor(url) {
3134
+ super(`The request with URL <${url}> was aborted. Make sure you don't destroy the InAppStoryManager while it's running.`);
3135
+ this.name = "IasAbortRequestError";
3136
+ }
3137
+ }
3138
+
3139
+ ;// CONCATENATED MODULE: ../core/src/api/exceptions/index.ts
3140
+
3141
+
3142
+
3119
3143
  ;// CONCATENATED MODULE: ../core/src/api/api.ts
3120
3144
 
3121
3145
 
@@ -3124,9 +3148,6 @@ const deviceDescriptor = new DeviceDescriptor();
3124
3148
 
3125
3149
 
3126
3150
 
3127
- function mergeObjects(obj1, obj2) {
3128
- return Object.assign(Object.assign({}, obj1), obj2);
3129
- }
3130
3151
  class API {
3131
3152
  constructor(config) {
3132
3153
  var _a;
@@ -3136,54 +3157,101 @@ class API {
3136
3157
  writable: true,
3137
3158
  value: void 0
3138
3159
  });
3139
- Object.defineProperty(this, "_deviceInfoPromise", {
3140
- enumerable: true,
3141
- configurable: true,
3142
- writable: true,
3143
- value: null
3144
- });
3145
3160
  Object.defineProperty(this, "_baseHeaders", {
3146
3161
  enumerable: true,
3147
3162
  configurable: true,
3148
3163
  writable: true,
3149
3164
  value: {}
3150
3165
  });
3151
- Object.defineProperty(this, "requestInterceptors", {
3152
- enumerable: true,
3153
- configurable: true,
3154
- writable: true,
3155
- value: []
3156
- });
3157
3166
  Object.defineProperty(this, "interceptors", {
3158
3167
  enumerable: true,
3159
3168
  configurable: true,
3160
3169
  writable: true,
3161
3170
  value: {
3162
- request: {
3163
- use: (cb) => {
3164
- this.requestInterceptors.push(cb);
3165
- }
3166
- }
3171
+ request: new InterceptorManager(),
3172
+ response: new InterceptorManager()
3167
3173
  }
3168
3174
  });
3169
3175
  this._baseURL = (_a = config === null || config === void 0 ? void 0 : config.baseURL) !== null && _a !== void 0 ? _a : "";
3170
3176
  }
3171
- set deviceInfoPromise(promise) {
3172
- this._deviceInfoPromise = promise;
3173
- }
3174
- set baseHeaders(headers) {
3175
- this._baseHeaders = headers;
3176
- }
3177
3177
  get baseURL() {
3178
3178
  return this._baseURL;
3179
3179
  }
3180
3180
  set baseURL(value) {
3181
3181
  this._baseURL = value;
3182
3182
  }
3183
+ set baseHeaders(headers) {
3184
+ this._baseHeaders = headers;
3185
+ }
3186
+ async request(config) {
3187
+ try {
3188
+ const processedConfig = await this.interceptors.request.run(config);
3189
+ const response = await this.dispatchRequest(processedConfig);
3190
+ return await this.interceptors.response.run(response);
3191
+ }
3192
+ catch (error) {
3193
+ if (error instanceof ApiRequestError)
3194
+ throw error;
3195
+ throw ApiRequestError.createByFetchError(error);
3196
+ }
3197
+ }
3198
+ get(url, config = {}) {
3199
+ return this.request(Object.assign(Object.assign({}, config), { method: "get", url }));
3200
+ }
3201
+ post(url, data, config = {}) {
3202
+ return this.request(Object.assign(Object.assign({}, config), { method: "post", url, data }));
3203
+ }
3204
+ put(url, data, config = {}) {
3205
+ return this.request(Object.assign(Object.assign({}, config), { method: "put", url, data }));
3206
+ }
3207
+ patch(url, data, config = {}) {
3208
+ return this.request(Object.assign(Object.assign({}, config), { method: "patch", url, data }));
3209
+ }
3210
+ async dispatchRequest(config) {
3211
+ const headers = Object.assign(Object.assign({}, this._baseHeaders), config.headers);
3212
+ const url = this.buildURL(config.url, config.params);
3213
+ const method = config.method ? config.method.toUpperCase() : "GET";
3214
+ let body = null;
3215
+ if (config.data) {
3216
+ body = JSON.stringify(this.buildBody(config.data));
3217
+ headers["Content-Type"] = "application/json";
3218
+ }
3219
+ const response = await fetch(url.toString(), {
3220
+ method,
3221
+ body: method === "GET" || method === "HEAD" ? null : body, // If the request method is GET or HEAD and the body is non-null or not undefined <fetch> throws a network error..
3222
+ headers,
3223
+ credentials: "omit",
3224
+ signal: config.signal
3225
+ });
3226
+ let data = {};
3227
+ if (response.status !== 204) {
3228
+ try {
3229
+ data = await response.json();
3230
+ }
3231
+ catch (_a) {
3232
+ data = {};
3233
+ }
3234
+ }
3235
+ const result = {
3236
+ data,
3237
+ status: response.status,
3238
+ statusText: response.statusText,
3239
+ headersRaw: response.headers,
3240
+ headers: Object.fromEntries(response.headers.entries()),
3241
+ ok: response.ok
3242
+ };
3243
+ if (!response.ok)
3244
+ throw ApiRequestError.createByRequestError(result);
3245
+ return result;
3246
+ }
3247
+ buildURL(url, params) {
3248
+ const qs = params ? new URLSearchParams(this.buildQuery(params)).toString() : "";
3249
+ return new URL(`${trimStartSlash(url)}${qs ? "?" + qs : ""}`, this._baseURL);
3250
+ }
3183
3251
  buildQuery(obj, prefix) {
3184
3252
  const pairs = [];
3185
3253
  for (const [key, value] of Object.entries(obj)) {
3186
- if (value == null || value === "")
3254
+ if (value == null || value === "" || Number.isNaN(value))
3187
3255
  continue;
3188
3256
  const fullKey = prefix ? `${prefix}[${key}]` : key;
3189
3257
  if (typeof value === "object" && !Array.isArray(value)) {
@@ -3213,79 +3281,6 @@ class API {
3213
3281
  }
3214
3282
  return result;
3215
3283
  }
3216
- async request(config) {
3217
- return new Promise((resolve, reject) => {
3218
- const cb = async () => {
3219
- try {
3220
- if (!(0,isObject_js_namespaceObject["default"])(config.headers) || config.headers == null) {
3221
- config.headers = {};
3222
- }
3223
- config.headers = mergeObjects(this._baseHeaders, config.headers);
3224
- if (this.requestInterceptors.length) {
3225
- for (const interceptor of this.requestInterceptors) {
3226
- interceptor(config);
3227
- }
3228
- }
3229
- let search = "";
3230
- if (!(0,isNil_js_namespaceObject["default"])(config.params) && (0,isObject_js_namespaceObject["default"])(config.params)) {
3231
- search = new URLSearchParams(this.buildQuery(config.params)).toString();
3232
- }
3233
- let url = new URL(`${trimStartSlash(config.url)}${search ? "?" + search : ""}`, this._baseURL);
3234
- let method = "GET";
3235
- if (!(0,isNil_js_namespaceObject["default"])(config.method)) {
3236
- method = config.method.toUpperCase();
3237
- }
3238
- let headers = {};
3239
- if (!(0,isNil_js_namespaceObject["default"])(config.headers) && (0,isObject_js_namespaceObject["default"])(config.headers)) {
3240
- headers = config.headers;
3241
- }
3242
- let body = null;
3243
- if (!(0,isNil_js_namespaceObject["default"])(config.data) && (0,isObject_js_namespaceObject["default"])(config.data)) {
3244
- body = JSON.stringify(this.buildBody(config.data));
3245
- headers["Content-Type"] = "application/json";
3246
- }
3247
- const response = await fetch(url.toString(), {
3248
- method,
3249
- body: method === "GET" || method === "HEAD" ? null : body, // If the request method is GET or HEAD and the body is non-null or not undefined <fetch> throws a network error..
3250
- headers,
3251
- credentials: "omit"
3252
- });
3253
- let json = {};
3254
- if (response.status !== 204)
3255
- json = await response.json();
3256
- const apiResponse = {
3257
- data: json,
3258
- headersRaw: response.headers,
3259
- // @ts-ignore
3260
- headers: Object.fromEntries([...response.headers]),
3261
- status: response.status,
3262
- statusText: response.statusText,
3263
- ok: response.ok
3264
- };
3265
- if (!response.ok) {
3266
- reject(ApiRequestError.createByRequestError(apiResponse));
3267
- return;
3268
- }
3269
- resolve(apiResponse);
3270
- }
3271
- catch (error) {
3272
- reject(ApiRequestError.createByFetchError(error));
3273
- }
3274
- };
3275
- if (this._deviceInfoPromise) {
3276
- this._deviceInfoPromise.finally(cb);
3277
- }
3278
- else {
3279
- cb();
3280
- }
3281
- });
3282
- }
3283
- async post(path, data, params = {}) {
3284
- return this.request({ method: "post", url: path, data, params });
3285
- }
3286
- async get(path, params = {}) {
3287
- return this.request({ method: "get", url: path, params });
3288
- }
3289
3284
  }
3290
3285
  const APIInstance = new API();
3291
3286
  APIInstance.interceptors.request.use(config => {
@@ -3293,14 +3288,13 @@ APIInstance.interceptors.request.use(config => {
3293
3288
  const storyManagerConfig = storyManager.config;
3294
3289
  const session = storyManager.rootStore.sessionStore.session;
3295
3290
  const sessionId = session === null || session === void 0 ? void 0 : session.id;
3296
- config.headers = mergeObjects((_a = config.headers) !== null && _a !== void 0 ? _a : {}, {
3297
- Authorization: `Bearer ${storyManagerConfig.apiKey}`,
3298
- "Accept-Language": storyManagerConfig.lang.toString(),
3299
- "X-Request-Id": (0,external_uuid_namespaceObject.v4)(),
3300
- "X-User-Agent": storyManager.userAgent
3301
- });
3291
+ if (!storyManagerConfig.apiKey)
3292
+ throw new IasAbortRequestError(config.url);
3293
+ if (!Boolean((_a = config.meta) === null || _a === void 0 ? void 0 : _a.public) && !sessionId)
3294
+ throw new IasAbortRequestError(config.url);
3295
+ config.headers = Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${storyManagerConfig.apiKey}`, "Accept-Language": storyManagerConfig.lang.toString(), "X-Request-Id": (0,external_uuid_namespaceObject.v4)(), "X-User-Agent": storyManager.userAgent });
3302
3296
  if (storyManagerConfig.userId && !storyManagerConfig.anonymous) {
3303
- config.headers["X-User-Id"] = storyManagerConfig.userId;
3297
+ config.headers["X-User-Id"] = storyManagerConfig.userId.toString();
3304
3298
  }
3305
3299
  if (sessionId) {
3306
3300
  config.headers["Auth-Session-Id"] = sessionId;
@@ -3508,20 +3502,24 @@ let IamApi = (() => {
3508
3502
  tags: tags.join(","),
3509
3503
  options
3510
3504
  }, {
3511
- fields: messageFieldsWithPrefix
3505
+ params: {
3506
+ fields: messageFieldsWithPrefix
3507
+ }
3512
3508
  });
3513
3509
  return response.data.messages;
3514
3510
  }
3515
3511
  async fetchContext() {
3516
3512
  const response = await api.get("inappmessaging/message-context", {
3517
- fields: "style,widgetsData"
3513
+ params: { fields: "style,widgetsData" }
3518
3514
  });
3519
3515
  return response.data;
3520
3516
  }
3521
3517
  async fetchById(messageId) {
3522
3518
  const response = await api.get(`inappmessaging/message/${messageId}`, {
3523
- expand: "slides_html",
3524
- fields: messageFields
3519
+ params: {
3520
+ expand: "slides_html",
3521
+ fields: messageFields
3522
+ }
3525
3523
  });
3526
3524
  const messageDto = response.data;
3527
3525
  if (!messageDto)
@@ -3538,7 +3536,9 @@ let IamApi = (() => {
3538
3536
  });
3539
3537
  return;
3540
3538
  }
3541
- await api.post(`/inappmessaging/message/${messageId}/event/${messageEvent.type}`, {}, messageEvent.toQueryParams());
3539
+ await api.post(`/inappmessaging/message/${messageId}/event/${messageEvent.type}`, {}, {
3540
+ params: messageEvent.toQueryParams()
3541
+ });
3542
3542
  }
3543
3543
  catch (error) {
3544
3544
  console.error(error);
@@ -3919,8 +3919,13 @@ class SessionApi {
3919
3919
  async open(payload) {
3920
3920
  const data = await this.getOpenSessionPayload(payload);
3921
3921
  const response = await api.post("session/open", data, {
3922
- expand: "cache",
3923
- fields: openFields
3922
+ params: {
3923
+ expand: "cache",
3924
+ fields: openFields
3925
+ },
3926
+ meta: {
3927
+ public: true
3928
+ }
3924
3929
  });
3925
3930
  return response.data;
3926
3931
  }
@@ -4493,25 +4498,25 @@ class StoriesApi {
4493
4498
  }
4494
4499
  async fetchStorySlides({ id, feedSlug }) {
4495
4500
  const { url, params } = this.getStoryRequestConfig(id, feedSlug);
4496
- const response = await api.get(url, params !== null && params !== void 0 ? params : {});
4501
+ const response = await api.get(url, { params });
4497
4502
  return response.data;
4498
4503
  }
4499
4504
  async fetchStory({ id, feedSlug, fetchShareUrl, once }) {
4500
4505
  const { url, params } = this.getStoryRequestConfig(id, feedSlug, true, fetchShareUrl, once);
4501
- const response = await api.get(url, params !== null && params !== void 0 ? params : {});
4506
+ const response = await api.get(url, { params });
4502
4507
  if (response.status === 204 && once)
4503
4508
  throw new IasStoryAlreadyShownError(id.toString());
4504
4509
  return response.data;
4505
4510
  }
4506
4511
  async fetchStoryContext({ ids }) {
4507
4512
  const { url, params } = this.getStoryContextRequestConfig(ids);
4508
- const response = await api.get(url, params !== null && params !== void 0 ? params : {});
4513
+ const response = await api.get(url, { params });
4509
4514
  return response.data;
4510
4515
  }
4511
4516
  async fetchStoryCSS() {
4512
4517
  var _a;
4513
4518
  const { url, params } = this.getStoryCSSRequestConfig();
4514
- const response = await api.get(url, params !== null && params !== void 0 ? params : {});
4519
+ const response = await api.get(url, { params });
4515
4520
  return (_a = response.data.style) !== null && _a !== void 0 ? _a : "";
4516
4521
  }
4517
4522
  async setStoryLike(storyId, like) {
@@ -4543,7 +4548,7 @@ class StoriesApi {
4543
4548
  localStorageSet(key, data);
4544
4549
  }
4545
4550
  async fetchStorySharePath(storyId) {
4546
- const response = await api.get(`story-share/${storyId}`, {});
4551
+ const response = await api.get(`story-share/${storyId}`);
4547
4552
  if (!response.data.url)
4548
4553
  throw new IasShareUrlUndefinedError(storyId);
4549
4554
  return response.data.url;
@@ -4565,7 +4570,7 @@ class StoriesApi {
4565
4570
  const config = {
4566
4571
  url: `${feedSlug === UGCFeedSlug ? "ugc/" : ""}story/${id}`,
4567
4572
  method: "GET",
4568
- params: { expand: expandFields.join(",") }
4573
+ params: { expand: expandFields.join(",") /* , src_list: "true" */ }
4569
4574
  };
4570
4575
  config.params.once = Number(Boolean(once));
4571
4576
  if (!allFields) {
@@ -4617,7 +4622,7 @@ class StoryFeedsApi {
4617
4622
  f: filter && JSON.stringify(filter),
4618
4623
  options
4619
4624
  };
4620
- const response = await api.get(url, params !== null && params !== void 0 ? params : {});
4625
+ const response = await api.get(url, { params });
4621
4626
  return response.data;
4622
4627
  }
4623
4628
  async fetchDefaultFeed({ feedSlug, tags, testKey, options }) {
@@ -4626,7 +4631,9 @@ class StoryFeedsApi {
4626
4631
  tags: tags.join(","),
4627
4632
  options
4628
4633
  }, {
4629
- test: testKey
4634
+ params: {
4635
+ test: testKey
4636
+ }
4630
4637
  });
4631
4638
  response.data.feedSlug = feedSlug;
4632
4639
  return response.data;
@@ -4634,8 +4641,10 @@ class StoryFeedsApi {
4634
4641
  async fetchFavoriteFeed({ tags }) {
4635
4642
  const url = "story";
4636
4643
  const response = await api.get(url, {
4637
- tags: tags.join(","),
4638
- favorite: 1
4644
+ params: {
4645
+ tags: tags.join(","),
4646
+ favorite: 1
4647
+ }
4639
4648
  });
4640
4649
  return response.data;
4641
4650
  }
@@ -4645,7 +4654,9 @@ class StoryFeedsApi {
4645
4654
  tags: payload.tags.join(","),
4646
4655
  options: payload.options
4647
4656
  }, {
4648
- limit: payload.limit
4657
+ params: {
4658
+ limit: payload.limit
4659
+ }
4649
4660
  });
4650
4661
  response.data.feedSlug = payload.feedSlug;
4651
4662
  return response.data;
@@ -4712,7 +4723,7 @@ class StatisticV2Api {
4712
4723
  }
4713
4724
  async sendFallbackFetch(path, params) {
4714
4725
  const api = new API({ baseURL: domains.apiUrl });
4715
- await api.get(path, params);
4726
+ await api.get(path, { params });
4716
4727
  }
4717
4728
  }
4718
4729
 
@@ -5114,6 +5125,7 @@ let StorySlide = (() => {
5114
5125
  return this._html;
5115
5126
  }
5116
5127
  constructor(storySlideDto) {
5128
+ var _b, _c;
5117
5129
  _StorySlide__html_accessor_storage.set(this, (storySlide_runInitializers(this, _instanceExtraInitializers), storySlide_runInitializers(this, __html_initializers, "")));
5118
5130
  Object.defineProperty(this, "index", {
5119
5131
  enumerable: true,
@@ -5145,6 +5157,18 @@ let StorySlide = (() => {
5145
5157
  writable: true,
5146
5158
  value: void 0
5147
5159
  });
5160
+ Object.defineProperty(this, "resources", {
5161
+ enumerable: true,
5162
+ configurable: true,
5163
+ writable: true,
5164
+ value: []
5165
+ });
5166
+ Object.defineProperty(this, "_resourcesByBlob", {
5167
+ enumerable: true,
5168
+ configurable: true,
5169
+ writable: true,
5170
+ value: {}
5171
+ });
5148
5172
  this.index = storySlideDto.index;
5149
5173
  this.timeline = {
5150
5174
  foreground: storySlideDto.timeline.foreground,
@@ -5153,6 +5177,17 @@ let StorySlide = (() => {
5153
5177
  this.duration = storySlideDto.duration;
5154
5178
  this.screenshotShare = storySlideDto.screenshot_share;
5155
5179
  this.eventPayload = storySlideDto.event_payload;
5180
+ // TODO: don't map in the slide model.
5181
+ // The model should not know anything about the DTO
5182
+ this.resources =
5183
+ (_c = (_b = storySlideDto.resources) === null || _b === void 0 ? void 0 : _b.map(resource => ({
5184
+ type: resource.type,
5185
+ key: resource.key,
5186
+ url: resource.url,
5187
+ rangeStart: resource.range_start,
5188
+ rangeEnd: resource.range_end,
5189
+ contentType: resource.content_type
5190
+ }))) !== null && _c !== void 0 ? _c : [];
5156
5191
  this._html = this.replaceSlideNonce(storySlideDto.html);
5157
5192
  }
5158
5193
  static createEmpty() {
@@ -5167,16 +5202,39 @@ let StorySlide = (() => {
5167
5202
  html: ""
5168
5203
  });
5169
5204
  }
5170
- replaceSlideNonce(slideHtml) {
5171
- var _b;
5172
- return replaceAll(slideHtml, `{{nonce}}`, (_b = getNonce()) !== null && _b !== void 0 ? _b : "");
5173
- }
5174
5205
  updatePlaceholders(placeholders) {
5175
5206
  let slideHtml = this._html;
5176
5207
  for (const placeholder of placeholders)
5177
5208
  slideHtml = replaceAll(slideHtml, `%${placeholder.key}%`, placeholder.value);
5178
5209
  this._html = slideHtml;
5179
5210
  }
5211
+ applyBlobUrls(resourceUrls, resourcesByBlob) {
5212
+ var _b;
5213
+ let updatedHtml = this._html;
5214
+ for (const resourceUrl of resourceUrls) {
5215
+ const blobUrl = (_b = resourcesByBlob[resourceUrl]) === null || _b === void 0 ? void 0 : _b.blobUrl;
5216
+ if (!blobUrl)
5217
+ continue;
5218
+ updatedHtml = replaceAll(updatedHtml, resourceUrl, blobUrl);
5219
+ this._resourcesByBlob[resourceUrl] = blobUrl;
5220
+ }
5221
+ this._html = updatedHtml;
5222
+ }
5223
+ restoreOriginalResourceUrls() {
5224
+ let restoredHtml = this._html;
5225
+ for (const [resourceUrl, blobUrl] of Object.entries(this._resourcesByBlob)) {
5226
+ restoredHtml = replaceAll(restoredHtml, blobUrl, resourceUrl);
5227
+ }
5228
+ this._html = restoredHtml;
5229
+ }
5230
+ parseResources() {
5231
+ const resources = Array.from(this._html.matchAll(/src="([^"]+)"/gi), t => t[1]).filter(src => !src.startsWith("blob:"));
5232
+ return Array.from(new Set(resources));
5233
+ }
5234
+ replaceSlideNonce(slideHtml) {
5235
+ var _b;
5236
+ return replaceAll(slideHtml, `{{nonce}}`, (_b = getNonce()) !== null && _b !== void 0 ? _b : "");
5237
+ }
5180
5238
  },
5181
5239
  _StorySlide__html_accessor_storage = new WeakMap(),
5182
5240
  (() => {
@@ -7777,7 +7835,7 @@ var external_async_mutex_x = (y) => {
7777
7835
  var x = {}; __webpack_require__.d(x, y); return x
7778
7836
  }
7779
7837
  var external_async_mutex_y = (x) => (() => (x))
7780
- const external_async_mutex_namespaceObject = external_async_mutex_x({ ["Mutex"]: () => (__WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__.Mutex) });
7838
+ const external_async_mutex_namespaceObject = external_async_mutex_x({ ["Mutex"]: () => (__WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__.Mutex), ["Semaphore"]: () => (__WEBPACK_EXTERNAL_MODULE_async_mutex_052338b1__.Semaphore) });
7781
7839
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storySlideViewModel/storySlideViewModel.ts
7782
7840
  var storySlideViewModel_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
7783
7841
  var useValue = arguments.length > 2;
@@ -7842,7 +7900,7 @@ let StorySlideViewModel = (() => {
7842
7900
  return _a = class StorySlideViewModel {
7843
7901
  get _disabledNextClick() { return storySlideViewModel_classPrivateFieldGet(this, _StorySlideViewModel__disabledNextClick_accessor_storage, "f"); }
7844
7902
  set _disabledNextClick(value) { storySlideViewModel_classPrivateFieldSet(this, _StorySlideViewModel__disabledNextClick_accessor_storage, value, "f"); }
7845
- constructor(_story, _index, slideApi, slide) {
7903
+ constructor(_story, _index, slideApi, slide, cacheManager) {
7846
7904
  Object.defineProperty(this, "_story", {
7847
7905
  enumerable: true,
7848
7906
  configurable: true,
@@ -7867,6 +7925,12 @@ let StorySlideViewModel = (() => {
7867
7925
  writable: true,
7868
7926
  value: slide
7869
7927
  });
7928
+ Object.defineProperty(this, "cacheManager", {
7929
+ enumerable: true,
7930
+ configurable: true,
7931
+ writable: true,
7932
+ value: cacheManager
7933
+ });
7870
7934
  _StorySlideViewModel__disabledNextClick_accessor_storage.set(this, storySlideViewModel_runInitializers(this, __disabledNextClick_initializers, false));
7871
7935
  Object.defineProperty(this, "mutex", {
7872
7936
  enumerable: true,
@@ -7886,6 +7950,18 @@ let StorySlideViewModel = (() => {
7886
7950
  writable: true,
7887
7951
  value: false
7888
7952
  });
7953
+ Object.defineProperty(this, "preloaded", {
7954
+ enumerable: true,
7955
+ configurable: true,
7956
+ writable: true,
7957
+ value: false
7958
+ });
7959
+ Object.defineProperty(this, "isPreloading", {
7960
+ enumerable: true,
7961
+ configurable: true,
7962
+ writable: true,
7963
+ value: false
7964
+ });
7889
7965
  Object.defineProperty(this, "handleTouchEnd", {
7890
7966
  enumerable: true,
7891
7967
  configurable: true,
@@ -8097,6 +8173,23 @@ let StorySlideViewModel = (() => {
8097
8173
  const { canClickNext } = this.slideApi.slideClickHandler(null, "backward");
8098
8174
  return canClickNext;
8099
8175
  }
8176
+ async preload(priority) {
8177
+ if (!this.cacheManager || this.preloaded || this.isPreloading)
8178
+ return;
8179
+ this.isPreloading = true;
8180
+ const resourceUrls = this.slide.parseResources();
8181
+ const cacheEntries = await this.cacheManager.preload(resourceUrls.map(resourceUrl => ({
8182
+ url: resourceUrl,
8183
+ priority
8184
+ })));
8185
+ const resourcesByUrl = {};
8186
+ for (const cacheEntry of cacheEntries)
8187
+ resourcesByUrl[cacheEntry.url] = cacheEntry;
8188
+ if (!this.cacheManager.isDestroyed)
8189
+ this.slide.applyBlobUrls(resourceUrls, resourcesByUrl);
8190
+ this.preloaded = true;
8191
+ this.isPreloading = false;
8192
+ }
8100
8193
  onClick({ event, currentTarget, preventNavigation = false }) {
8101
8194
  if (!event.target)
8102
8195
  return;
@@ -8117,6 +8210,8 @@ let StorySlideViewModel = (() => {
8117
8210
  this.isStarted = false;
8118
8211
  this.isInited = false;
8119
8212
  this.story.touchController.off(TouchControllerEvent.TouchEnd, this.handleTouchEnd);
8213
+ if (this.cacheManager)
8214
+ this.slide.restoreOriginalResourceUrls();
8120
8215
  await this.slideApi.destroy();
8121
8216
  }
8122
8217
  catch (error) {
@@ -9475,8 +9570,9 @@ var StoryEvent;
9475
9570
  (function (StoryEvent) {
9476
9571
  StoryEvent["ShowToast"] = "showToast";
9477
9572
  })(StoryEvent || (StoryEvent = {}));
9573
+ const ACTIVE_SLIDE_PRELOAD_PRIORITY = 1000;
9478
9574
  let StoryViewModel = (() => {
9479
- var _a, _StoryViewModel__activeSlideIndex_accessor_storage, _StoryViewModel__slides_accessor_storage, _StoryViewModel__needShowErrorScreen_accessor_storage, _StoryViewModel__needShowLoaderScreen_accessor_storage, _StoryViewModel__$root_accessor_storage;
9575
+ var _a, _StoryViewModel__activeSlideIndex_accessor_storage, _StoryViewModel__slides_accessor_storage, _StoryViewModel__needShowErrorScreen_accessor_storage, _StoryViewModel__needShowLoaderScreen_accessor_storage, _StoryViewModel__$root_accessor_storage, _StoryViewModel_isInited_accessor_storage;
9480
9576
  var _b;
9481
9577
  let _classSuper = ViewModel;
9482
9578
  let _instanceExtraInitializers = [];
@@ -9495,6 +9591,9 @@ let StoryViewModel = (() => {
9495
9591
  let __$root_decorators;
9496
9592
  let __$root_initializers = [];
9497
9593
  let __$root_extraInitializers = [];
9594
+ let _isInited_decorators;
9595
+ let _isInited_initializers = [];
9596
+ let _isInited_extraInitializers = [];
9498
9597
  let _get_needShowErrorScreen_decorators;
9499
9598
  let _get_needShowLoaderScreen_decorators;
9500
9599
  let _get_activeSlide_decorators;
@@ -9522,7 +9621,9 @@ let StoryViewModel = (() => {
9522
9621
  set _needShowLoaderScreen(value) { storyViewModel_classPrivateFieldSet(this, _StoryViewModel__needShowLoaderScreen_accessor_storage, value, "f"); }
9523
9622
  get _$root() { return storyViewModel_classPrivateFieldGet(this, _StoryViewModel__$root_accessor_storage, "f"); }
9524
9623
  set _$root(value) { storyViewModel_classPrivateFieldSet(this, _StoryViewModel__$root_accessor_storage, value, "f"); }
9525
- constructor(storyManager, storyReader, story, storySlideApiHandlersFactory, storyReaderStatisticV1Service, storyReaderStatisticV2Service) {
9624
+ get isInited() { return storyViewModel_classPrivateFieldGet(this, _StoryViewModel_isInited_accessor_storage, "f"); }
9625
+ set isInited(value) { storyViewModel_classPrivateFieldSet(this, _StoryViewModel_isInited_accessor_storage, value, "f"); }
9626
+ constructor(storyManager, storyReader, story, storySlideApiHandlersFactory, storyReaderStatisticV1Service, storyReaderStatisticV2Service, cacheManager) {
9526
9627
  super();
9527
9628
  Object.defineProperty(this, "storyManager", {
9528
9629
  enumerable: true,
@@ -9560,22 +9661,23 @@ let StoryViewModel = (() => {
9560
9661
  writable: true,
9561
9662
  value: storyReaderStatisticV2Service
9562
9663
  });
9664
+ Object.defineProperty(this, "cacheManager", {
9665
+ enumerable: true,
9666
+ configurable: true,
9667
+ writable: true,
9668
+ value: cacheManager
9669
+ });
9563
9670
  _StoryViewModel__activeSlideIndex_accessor_storage.set(this, storyViewModel_runInitializers(this, __activeSlideIndex_initializers, 0));
9564
9671
  _StoryViewModel__slides_accessor_storage.set(this, (storyViewModel_runInitializers(this, __activeSlideIndex_extraInitializers), storyViewModel_runInitializers(this, __slides_initializers, [])));
9565
9672
  _StoryViewModel__needShowErrorScreen_accessor_storage.set(this, (storyViewModel_runInitializers(this, __slides_extraInitializers), storyViewModel_runInitializers(this, __needShowErrorScreen_initializers, false)));
9566
9673
  _StoryViewModel__needShowLoaderScreen_accessor_storage.set(this, (storyViewModel_runInitializers(this, __needShowErrorScreen_extraInitializers), storyViewModel_runInitializers(this, __needShowLoaderScreen_initializers, false)));
9567
9674
  _StoryViewModel__$root_accessor_storage.set(this, (storyViewModel_runInitializers(this, __needShowLoaderScreen_extraInitializers), storyViewModel_runInitializers(this, __$root_initializers, null)));
9568
- Object.defineProperty(this, "isInited", {
9569
- enumerable: true,
9570
- configurable: true,
9571
- writable: true,
9572
- value: (storyViewModel_runInitializers(this, __$root_extraInitializers), false)
9573
- });
9675
+ _StoryViewModel_isInited_accessor_storage.set(this, (storyViewModel_runInitializers(this, __$root_extraInitializers), storyViewModel_runInitializers(this, _isInited_initializers, false)));
9574
9676
  Object.defineProperty(this, "isStarted", {
9575
9677
  enumerable: true,
9576
9678
  configurable: true,
9577
9679
  writable: true,
9578
- value: false
9680
+ value: (storyViewModel_runInitializers(this, _isInited_extraInitializers), false)
9579
9681
  });
9580
9682
  Object.defineProperty(this, "_activeSlideStartTime", {
9581
9683
  enumerable: true,
@@ -9651,12 +9753,6 @@ let StoryViewModel = (() => {
9651
9753
  writable: true,
9652
9754
  value: void 0
9653
9755
  });
9654
- Object.defineProperty(this, "initOnce", {
9655
- enumerable: true,
9656
- configurable: true,
9657
- writable: true,
9658
- value: false
9659
- });
9660
9756
  Object.defineProperty(this, "toast", {
9661
9757
  enumerable: true,
9662
9758
  configurable: true,
@@ -9733,7 +9829,7 @@ let StoryViewModel = (() => {
9733
9829
  return this.storyReader.displayStrategy;
9734
9830
  }
9735
9831
  get canBeShown() {
9736
- return this.story.canBeShown && this.slides.length > 0;
9832
+ return this.story.canBeShown && this.slides.length > 0 && Boolean(this._$root);
9737
9833
  }
9738
9834
  get context() {
9739
9835
  return this.story.context;
@@ -9790,6 +9886,9 @@ let StoryViewModel = (() => {
9790
9886
  get dir() {
9791
9887
  return this.storyReader.dir;
9792
9888
  }
9889
+ get isSlideRendered() {
9890
+ return this.isInited;
9891
+ }
9793
9892
  get isNextDisabled() {
9794
9893
  return ((this.storyReader.reachEnd && this.reachEnd) ||
9795
9894
  this.activeSlide.disabledNextClick ||
@@ -9921,15 +10020,24 @@ let StoryViewModel = (() => {
9921
10020
  this.isInited = isInited;
9922
10021
  this.isStarted = isStarted;
9923
10022
  }
10023
+ async preloadSlides(start, end, priority) {
10024
+ if (!this.story.canBeShown)
10025
+ this.showLoaderScreen();
10026
+ await (0,external_mobx_namespaceObject.when)(() => this.story.canBeShown);
10027
+ end = end !== null && end !== void 0 ? end : this._slides.length;
10028
+ priority = priority !== null && priority !== void 0 ? priority : 0;
10029
+ await Promise.all(this._slides.slice(start, end).map((slide, index) => slide.preload(end - index + priority)));
10030
+ }
10031
+ async preloadActiveSlide(priority) {
10032
+ this.preloadSlides(this._activeSlideIndex, this._activeSlideIndex + 1, priority);
10033
+ }
9924
10034
  async init() {
9925
10035
  await this.mutex.runExclusive(async () => {
9926
10036
  if (this.isInited)
9927
10037
  return;
9928
- if (!this.initOnce && !this.story.canBeShown) {
10038
+ if (!this.story.canBeShown)
9929
10039
  this.showLoaderScreen();
9930
- this.initOnce = true;
9931
- }
9932
- await (0,external_mobx_namespaceObject.when)(() => this.canBeShown && Boolean(this._$root));
10040
+ await (0,external_mobx_namespaceObject.when)(() => this.canBeShown);
9933
10041
  await this.activeSlide.init();
9934
10042
  this.isInited = true;
9935
10043
  });
@@ -10043,7 +10151,7 @@ let StoryViewModel = (() => {
10043
10151
  return slideApi;
10044
10152
  }
10045
10153
  async createSlidesViewModels(slides, slideApi) {
10046
- this._slides = slides.map((slide, index) => new StorySlideViewModel(this, index, slideApi, slide));
10154
+ this._slides = slides.map((slide, index) => new StorySlideViewModel(this, index, slideApi, slide, this.cacheManager));
10047
10155
  }
10048
10156
  handleSpaceKeydown(e) {
10049
10157
  if (e.code !== "Space")
@@ -10062,6 +10170,7 @@ let StoryViewModel = (() => {
10062
10170
  this.mute();
10063
10171
  }
10064
10172
  async onSlideChange(index) {
10173
+ var _b;
10065
10174
  try {
10066
10175
  if (!this.isInited || !this.isStarted)
10067
10176
  return;
@@ -10070,6 +10179,8 @@ let StoryViewModel = (() => {
10070
10179
  this._activeSlideIndex = index;
10071
10180
  this.hideErrorScreen();
10072
10181
  this.resumeAll();
10182
+ if (!((_b = this.storyManager.config.cache) === null || _b === void 0 ? void 0 : _b.prefetch))
10183
+ await this.preloadActiveSlide(ACTIVE_SLIDE_PRELOAD_PRIORITY);
10073
10184
  await activeSlide.init();
10074
10185
  await (lastSlide === null || lastSlide === void 0 ? void 0 : lastSlide.stop({ prepareForRestart: 2 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.NOT_PREPARE */ }));
10075
10186
  await activeSlide.start();
@@ -10097,6 +10208,7 @@ let StoryViewModel = (() => {
10097
10208
  _StoryViewModel__needShowErrorScreen_accessor_storage = new WeakMap(),
10098
10209
  _StoryViewModel__needShowLoaderScreen_accessor_storage = new WeakMap(),
10099
10210
  _StoryViewModel__$root_accessor_storage = new WeakMap(),
10211
+ _StoryViewModel_isInited_accessor_storage = new WeakMap(),
10100
10212
  (() => {
10101
10213
  var _b;
10102
10214
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
@@ -10105,6 +10217,7 @@ let StoryViewModel = (() => {
10105
10217
  __needShowErrorScreen_decorators = [external_mobx_namespaceObject.observable];
10106
10218
  __needShowLoaderScreen_decorators = [external_mobx_namespaceObject.observable];
10107
10219
  __$root_decorators = [external_mobx_namespaceObject.observable];
10220
+ _isInited_decorators = [external_mobx_namespaceObject.observable];
10108
10221
  _get_needShowErrorScreen_decorators = [external_mobx_namespaceObject.computed];
10109
10222
  _get_needShowLoaderScreen_decorators = [external_mobx_namespaceObject.computed];
10110
10223
  _get_activeSlide_decorators = [external_mobx_namespaceObject.computed];
@@ -10126,6 +10239,7 @@ let StoryViewModel = (() => {
10126
10239
  storyViewModel_esDecorate(_a, null, __needShowErrorScreen_decorators, { kind: "accessor", name: "_needShowErrorScreen", static: false, private: false, access: { has: obj => "_needShowErrorScreen" in obj, get: obj => obj._needShowErrorScreen, set: (obj, value) => { obj._needShowErrorScreen = value; } }, metadata: _metadata }, __needShowErrorScreen_initializers, __needShowErrorScreen_extraInitializers);
10127
10240
  storyViewModel_esDecorate(_a, null, __needShowLoaderScreen_decorators, { kind: "accessor", name: "_needShowLoaderScreen", static: false, private: false, access: { has: obj => "_needShowLoaderScreen" in obj, get: obj => obj._needShowLoaderScreen, set: (obj, value) => { obj._needShowLoaderScreen = value; } }, metadata: _metadata }, __needShowLoaderScreen_initializers, __needShowLoaderScreen_extraInitializers);
10128
10241
  storyViewModel_esDecorate(_a, null, __$root_decorators, { kind: "accessor", name: "_$root", static: false, private: false, access: { has: obj => "_$root" in obj, get: obj => obj._$root, set: (obj, value) => { obj._$root = value; } }, metadata: _metadata }, __$root_initializers, __$root_extraInitializers);
10242
+ storyViewModel_esDecorate(_a, null, _isInited_decorators, { kind: "accessor", name: "isInited", static: false, private: false, access: { has: obj => "isInited" in obj, get: obj => obj.isInited, set: (obj, value) => { obj.isInited = value; } }, metadata: _metadata }, _isInited_initializers, _isInited_extraInitializers);
10129
10243
  storyViewModel_esDecorate(_a, null, _get_needShowErrorScreen_decorators, { kind: "getter", name: "needShowErrorScreen", static: false, private: false, access: { has: obj => "needShowErrorScreen" in obj, get: obj => obj.needShowErrorScreen }, metadata: _metadata }, null, _instanceExtraInitializers);
10130
10244
  storyViewModel_esDecorate(_a, null, _get_needShowLoaderScreen_decorators, { kind: "getter", name: "needShowLoaderScreen", static: false, private: false, access: { has: obj => "needShowLoaderScreen" in obj, get: obj => obj.needShowLoaderScreen }, metadata: _metadata }, null, _instanceExtraInitializers);
10131
10245
  storyViewModel_esDecorate(_a, null, _get_activeSlide_decorators, { kind: "getter", name: "activeSlide", static: false, private: false, access: { has: obj => "activeSlide" in obj, get: obj => obj.activeSlide }, metadata: _metadata }, null, _instanceExtraInitializers);
@@ -10154,6 +10268,12 @@ var isEmpty_js_x = (y) => {
10154
10268
  }
10155
10269
  var isEmpty_js_y = (x) => (() => (x))
10156
10270
  const isEmpty_js_namespaceObject = isEmpty_js_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_lodash_isEmpty_js_f1e1789b__["default"]) });
10271
+ ;// CONCATENATED MODULE: external "lodash/isObject.js"
10272
+ var isObject_js_x = (y) => {
10273
+ var x = {}; __webpack_require__.d(x, y); return x
10274
+ }
10275
+ var isObject_js_y = (x) => (() => (x))
10276
+ const isObject_js_namespaceObject = isObject_js_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_lodash_isObject_js_84bb7d23__["default"]) });
10157
10277
  ;// CONCATENATED MODULE: ../core/src/readers/gameReader/gameSessionHandlers/gameInstanceLocalDataHandlers/gameInstanceStorage.ts
10158
10278
 
10159
10279
 
@@ -10496,7 +10616,7 @@ class GameCenterApi {
10496
10616
  const body = {};
10497
10617
  if (gameOptions && (0,isObject_js_namespaceObject["default"])(gameOptions) && gameOptions.demoMode != null)
10498
10618
  body.demoMode = Boolean(gameOptions.demoMode);
10499
- const response = await api.post(`game/${gameInstanceId}/launch`, body, params);
10619
+ const response = await api.post(`game/${gameInstanceId}/launch`, body, { params });
10500
10620
  return response.data;
10501
10621
  }
10502
10622
  }
@@ -10589,7 +10709,7 @@ class GameClientConfig {
10589
10709
  value: void 0
10590
10710
  });
10591
10711
  const storyManagerConfig = this.storyManager.config;
10592
- const sdkVersion = "1.7.9";
10712
+ const sdkVersion = "1.7.11";
10593
10713
  const placeholders = this.storyManager.rootStore.placeholderStore.placeholders;
10594
10714
  const session = this.storyManager.rootStore.sessionStore.session;
10595
10715
  this.sessionId = session.id;
@@ -12805,6 +12925,8 @@ var storyReaderNavigationController_classPrivateFieldSet = (undefined && undefin
12805
12925
 
12806
12926
 
12807
12927
  const STORY_INIT_RANGE = 1;
12928
+ const ACTIVE_STORY_PRELOAD_PRIORITY = 1000;
12929
+ const NON_ACTIVE_STORY_PRELOAD_PRIORITY = 0;
12808
12930
  let StoryReaderNavigationController = (() => {
12809
12931
  var _a, _StoryReaderNavigationController__activeStory_accessor_storage, _StoryReaderNavigationController__currentIndex_accessor_storage, _StoryReaderNavigationController__targetTransitionIndex_accessor_storage;
12810
12932
  let _instanceExtraInitializers = [];
@@ -12942,7 +13064,6 @@ let StoryReaderNavigationController = (() => {
12942
13064
  this.currentStoryDisplayStrategy.handleNextStoryByIndex(index);
12943
13065
  this.initStoriesWithinRange(index);
12944
13066
  await this.animatedNavigationController.transitionByIndex(index, this.currentIndex);
12945
- //await Promise.all([p1, p2]);
12946
13067
  await this.handleTransitionEnd(index, action);
12947
13068
  }
12948
13069
  handleStoryReaderReachEnd(action) {
@@ -12986,6 +13107,7 @@ let StoryReaderNavigationController = (() => {
12986
13107
  async runNextStory(prevStory, story) {
12987
13108
  try {
12988
13109
  await (prevStory === null || prevStory === void 0 ? void 0 : prevStory.stop());
13110
+ await this.preloadActiveStory(story);
12989
13111
  await story.init();
12990
13112
  await story.start();
12991
13113
  }
@@ -12994,11 +13116,16 @@ let StoryReaderNavigationController = (() => {
12994
13116
  }
12995
13117
  }
12996
13118
  async initStoriesWithinRange(currentIndex) {
12997
- let stories = this.storyReader.stories;
13119
+ const stories = this.storyReader.stories;
12998
13120
  const start = Math.max(currentIndex - STORY_INIT_RANGE, 0);
12999
13121
  const end = Math.min(currentIndex + STORY_INIT_RANGE, stories.length - 1);
13000
- stories = stories.slice(start, end + 1);
13001
- return Promise.allSettled(stories.map(story => story.init()));
13122
+ const storiesToInit = [];
13123
+ for (let i = start; i <= end; i++) {
13124
+ if (i !== currentIndex)
13125
+ storiesToInit.push(stories[i]);
13126
+ }
13127
+ await this.preloadSiblingStories(storiesToInit);
13128
+ return Promise.allSettled(storiesToInit.map(story => story.init()));
13002
13129
  }
13003
13130
  handleActiveStoryError(story) {
13004
13131
  if (!(story === null || story === void 0 ? void 0 : story.error))
@@ -13014,6 +13141,28 @@ let StoryReaderNavigationController = (() => {
13014
13141
  limitIndex(index) {
13015
13142
  return Math.max(0, Math.min(this.storyReader.stories.length - 1, index));
13016
13143
  }
13144
+ async preloadActiveStory(story) {
13145
+ const cacheConfig = this.storyManager.config.cache;
13146
+ if (!cacheConfig)
13147
+ return;
13148
+ if (cacheConfig.prefetch) {
13149
+ await story.preloadSlides(0, story.slidesCount, ACTIVE_STORY_PRELOAD_PRIORITY);
13150
+ }
13151
+ else {
13152
+ await story.preloadActiveSlide(ACTIVE_STORY_PRELOAD_PRIORITY);
13153
+ }
13154
+ }
13155
+ async preloadSiblingStories(stories) {
13156
+ const cacheConfig = this.storyManager.config.cache;
13157
+ if (!cacheConfig)
13158
+ return;
13159
+ if (cacheConfig.prefetch) {
13160
+ await Promise.all(stories.map(story => story.preloadSlides(0, 2, NON_ACTIVE_STORY_PRELOAD_PRIORITY)));
13161
+ }
13162
+ else {
13163
+ await Promise.all(stories.map(story => story.preloadActiveSlide(NON_ACTIVE_STORY_PRELOAD_PRIORITY)));
13164
+ }
13165
+ }
13017
13166
  },
13018
13167
  _StoryReaderNavigationController__activeStory_accessor_storage = new WeakMap(),
13019
13168
  _StoryReaderNavigationController__currentIndex_accessor_storage = new WeakMap(),
@@ -13051,129 +13200,81 @@ let StoryReaderNavigationController = (() => {
13051
13200
 
13052
13201
 
13053
13202
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/showOnboardingStoriesStrategy.ts
13054
- var showOnboardingStoriesStrategy_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
13055
- var useValue = arguments.length > 2;
13056
- for (var i = 0; i < initializers.length; i++) {
13057
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
13203
+
13204
+ class ShowOnboardingStoriesStrategy {
13205
+ constructor(showMultipleStoriesStrategy, storyManager) {
13206
+ Object.defineProperty(this, "showMultipleStoriesStrategy", {
13207
+ enumerable: true,
13208
+ configurable: true,
13209
+ writable: true,
13210
+ value: showMultipleStoriesStrategy
13211
+ });
13212
+ Object.defineProperty(this, "storyManager", {
13213
+ enumerable: true,
13214
+ configurable: true,
13215
+ writable: true,
13216
+ value: storyManager
13217
+ });
13218
+ Object.defineProperty(this, "_feed", {
13219
+ enumerable: true,
13220
+ configurable: true,
13221
+ writable: true,
13222
+ value: null
13223
+ });
13058
13224
  }
13059
- return useValue ? value : void 0;
13060
- };
13061
- var showOnboardingStoriesStrategy_esDecorate = (undefined && undefined.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
13062
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
13063
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
13064
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13065
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13066
- var _, done = false;
13067
- for (var i = decorators.length - 1; i >= 0; i--) {
13068
- var context = {};
13069
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
13070
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
13071
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13072
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13073
- if (kind === "accessor") {
13074
- if (result === void 0) continue;
13075
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
13076
- if (_ = accept(result.get)) descriptor.get = _;
13077
- if (_ = accept(result.set)) descriptor.set = _;
13078
- if (_ = accept(result.init)) initializers.unshift(_);
13079
- }
13080
- else if (_ = accept(result)) {
13081
- if (kind === "field") initializers.unshift(_);
13082
- else descriptor[key] = _;
13083
- }
13225
+ get feed() {
13226
+ return this._feed;
13084
13227
  }
13085
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
13086
- done = true;
13087
- };
13088
-
13089
-
13090
- let ShowOnboardingStoriesStrategy = (() => {
13091
- var _a;
13092
- let _instanceExtraInitializers = [];
13093
- let _show_decorators;
13094
- return _a = class ShowOnboardingStoriesStrategy {
13095
- constructor(showMultipleStoriesStrategy, storyManager) {
13096
- Object.defineProperty(this, "showMultipleStoriesStrategy", {
13097
- enumerable: true,
13098
- configurable: true,
13099
- writable: true,
13100
- value: (showOnboardingStoriesStrategy_runInitializers(this, _instanceExtraInitializers), showMultipleStoriesStrategy)
13101
- });
13102
- Object.defineProperty(this, "storyManager", {
13103
- enumerable: true,
13104
- configurable: true,
13105
- writable: true,
13106
- value: storyManager
13107
- });
13108
- Object.defineProperty(this, "_feed", {
13109
- enumerable: true,
13110
- configurable: true,
13111
- writable: true,
13112
- value: null
13113
- });
13114
- }
13115
- get feed() {
13116
- return this._feed;
13117
- }
13118
- async show(payload) {
13119
- var _b, _c;
13120
- const storyFeedStore = this.storyManager.rootStore.onboardingFeedStore;
13121
- const onboardingFeed = await storyFeedStore.fetchOnboardingFeed({
13122
- feedSlug: payload.feedSlug,
13123
- tags: (_b = payload.customTags) !== null && _b !== void 0 ? _b : [],
13124
- limit: (_c = payload.limit) !== null && _c !== void 0 ? _c : undefined
13125
- });
13126
- this._feed = onboardingFeed;
13127
- const feedLoadEvent = this.getFeedLoadEvent(onboardingFeed.slug, onboardingFeed.stories);
13128
- this.emitFeedLoad(feedLoadEvent);
13129
- if (!onboardingFeed.stories.length)
13130
- return feedLoadEvent;
13131
- await this.showMultipleStoriesStrategy.show({
13132
- windowReferer: STORY_READER_WINDOW_REFERER.default,
13133
- storyFeed: onboardingFeed,
13134
- storyId: onboardingFeed.stories[0].id
13135
- });
13136
- return feedLoadEvent;
13137
- }
13138
- async handleNextStoryByIndex(nextStoryIndex) {
13139
- this.showMultipleStoriesStrategy.handleNextStoryByIndex(nextStoryIndex);
13140
- }
13141
- emitFeedLoad(event) {
13142
- this.storyManager.emit("feedLoad", event);
13143
- }
13144
- getFeedLoadEvent(feed, onboardingStories) {
13145
- const stories = onboardingStories.map(story => {
13146
- const additionalPayload = {
13147
- title: null,
13148
- slidesCount: null
13149
- };
13150
- if (story) {
13151
- additionalPayload.title = story.statTitle;
13152
- additionalPayload.slidesCount = story.slidesCount;
13153
- }
13154
- return Object.assign({ id: story.id }, additionalPayload);
13155
- });
13156
- const eventData = {
13157
- stories,
13158
- feed: null,
13159
- filter: null
13160
- };
13161
- eventData.feed = feed;
13162
- return eventData;
13163
- }
13164
- async reload(payload) {
13165
- this.showMultipleStoriesStrategy.reload(payload);
13228
+ async show(payload) {
13229
+ var _a, _b;
13230
+ const storyFeedStore = this.storyManager.rootStore.onboardingFeedStore;
13231
+ const onboardingFeed = await storyFeedStore.fetchOnboardingFeed({
13232
+ feedSlug: payload.feedSlug,
13233
+ tags: (_a = payload.customTags) !== null && _a !== void 0 ? _a : [],
13234
+ limit: (_b = payload.limit) !== null && _b !== void 0 ? _b : undefined
13235
+ });
13236
+ this._feed = onboardingFeed;
13237
+ const feedLoadEvent = this.getFeedLoadEvent(onboardingFeed.slug, onboardingFeed.stories);
13238
+ this.emitFeedLoad(feedLoadEvent);
13239
+ if (!onboardingFeed.stories.length)
13240
+ return feedLoadEvent;
13241
+ await this.showMultipleStoriesStrategy.show({
13242
+ windowReferer: STORY_READER_WINDOW_REFERER.default,
13243
+ storyFeed: onboardingFeed,
13244
+ storyId: onboardingFeed.stories[0].id
13245
+ });
13246
+ return feedLoadEvent;
13247
+ }
13248
+ async handleNextStoryByIndex(nextStoryIndex) {
13249
+ this.showMultipleStoriesStrategy.handleNextStoryByIndex(nextStoryIndex);
13250
+ }
13251
+ emitFeedLoad(event) {
13252
+ this.storyManager.emit("feedLoad", event);
13253
+ }
13254
+ getFeedLoadEvent(feed, onboardingStories) {
13255
+ const stories = onboardingStories.map(story => {
13256
+ const additionalPayload = {
13257
+ title: null,
13258
+ slidesCount: null
13259
+ };
13260
+ if (story) {
13261
+ additionalPayload.title = story.statTitle;
13262
+ additionalPayload.slidesCount = story.slidesCount;
13166
13263
  }
13167
- },
13168
- (() => {
13169
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
13170
- _show_decorators = [noConcurrent];
13171
- showOnboardingStoriesStrategy_esDecorate(_a, null, _show_decorators, { kind: "method", name: "show", static: false, private: false, access: { has: obj => "show" in obj, get: obj => obj.show }, metadata: _metadata }, null, _instanceExtraInitializers);
13172
- if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
13173
- })(),
13174
- _a;
13175
- })();
13176
-
13264
+ return Object.assign({ id: story.id }, additionalPayload);
13265
+ });
13266
+ const eventData = {
13267
+ stories,
13268
+ feed: null,
13269
+ filter: null
13270
+ };
13271
+ eventData.feed = feed;
13272
+ return eventData;
13273
+ }
13274
+ async reload(payload) {
13275
+ this.showMultipleStoriesStrategy.reload(payload);
13276
+ }
13277
+ }
13177
13278
 
13178
13279
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/showMultipleStoriesStrategy.ts
13179
13280
  const NUMBER_OF_LAZY_LOADED_STORIES = 2;
@@ -13284,191 +13385,95 @@ class ShowStoryFromSharePageStrategy {
13284
13385
  }
13285
13386
 
13286
13387
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/showStoryOnceStrategy.ts
13287
- var showStoryOnceStrategy_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
13288
- var useValue = arguments.length > 2;
13289
- for (var i = 0; i < initializers.length; i++) {
13290
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
13291
- }
13292
- return useValue ? value : void 0;
13293
- };
13294
- var showStoryOnceStrategy_esDecorate = (undefined && undefined.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
13295
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
13296
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
13297
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13298
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13299
- var _, done = false;
13300
- for (var i = decorators.length - 1; i >= 0; i--) {
13301
- var context = {};
13302
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
13303
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
13304
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13305
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13306
- if (kind === "accessor") {
13307
- if (result === void 0) continue;
13308
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
13309
- if (_ = accept(result.get)) descriptor.get = _;
13310
- if (_ = accept(result.set)) descriptor.set = _;
13311
- if (_ = accept(result.init)) initializers.unshift(_);
13312
- }
13313
- else if (_ = accept(result)) {
13314
- if (kind === "field") initializers.unshift(_);
13315
- else descriptor[key] = _;
13316
- }
13317
- }
13318
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
13319
- done = true;
13320
- };
13321
-
13322
13388
 
13323
13389
 
13324
- let ShowStoryOnceStrategy = (() => {
13325
- var _a;
13326
- let _instanceExtraInitializers = [];
13327
- let _show_decorators;
13328
- return _a = class ShowStoryOnceStrategy {
13329
- constructor(storyManager, storyReaderViewModel) {
13330
- Object.defineProperty(this, "storyManager", {
13331
- enumerable: true,
13332
- configurable: true,
13333
- writable: true,
13334
- value: (showStoryOnceStrategy_runInitializers(this, _instanceExtraInitializers), storyManager)
13335
- });
13336
- Object.defineProperty(this, "storyReaderViewModel", {
13337
- enumerable: true,
13338
- configurable: true,
13339
- writable: true,
13340
- value: storyReaderViewModel
13341
- });
13342
- }
13343
- get feed() {
13344
- return null;
13345
- }
13346
- async show(payload) {
13347
- try {
13348
- const storyStore = this.storyManager.rootStore.storyStore;
13349
- const story = await storyStore.fetchStoryById({
13350
- storyId: payload.storyId,
13351
- feedSlug: "",
13352
- once: true
13353
- });
13354
- if (story.error)
13355
- throw story.error;
13356
- if (story.isOpened)
13357
- throw new IasStoryAlreadyShownError(payload.storyId.toString());
13358
- this.openStoryReader(story);
13359
- }
13360
- catch (error) {
13361
- this.storyReaderViewModel.close();
13362
- throw error;
13363
- }
13364
- }
13365
- openStoryReader(story) {
13366
- this.storyReaderViewModel.open({
13367
- windowReferer: STORY_READER_WINDOW_REFERER.default,
13368
- id: story.id,
13369
- stories: [story]
13370
- });
13371
- }
13372
- async handleNextStoryByIndex(storyIndex) { }
13373
- async reload(payload) { }
13374
- },
13375
- (() => {
13376
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
13377
- _show_decorators = [noConcurrent];
13378
- showStoryOnceStrategy_esDecorate(_a, null, _show_decorators, { kind: "method", name: "show", static: false, private: false, access: { has: obj => "show" in obj, get: obj => obj.show }, metadata: _metadata }, null, _instanceExtraInitializers);
13379
- if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
13380
- })(),
13381
- _a;
13382
- })();
13383
-
13384
-
13385
- ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/showStoryStrategy.ts
13386
- var showStoryStrategy_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
13387
- var useValue = arguments.length > 2;
13388
- for (var i = 0; i < initializers.length; i++) {
13389
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
13390
+ class ShowStoryOnceStrategy {
13391
+ constructor(storyManager, storyReaderViewModel) {
13392
+ Object.defineProperty(this, "storyManager", {
13393
+ enumerable: true,
13394
+ configurable: true,
13395
+ writable: true,
13396
+ value: storyManager
13397
+ });
13398
+ Object.defineProperty(this, "storyReaderViewModel", {
13399
+ enumerable: true,
13400
+ configurable: true,
13401
+ writable: true,
13402
+ value: storyReaderViewModel
13403
+ });
13390
13404
  }
13391
- return useValue ? value : void 0;
13392
- };
13393
- var showStoryStrategy_esDecorate = (undefined && undefined.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
13394
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
13395
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
13396
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13397
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13398
- var _, done = false;
13399
- for (var i = decorators.length - 1; i >= 0; i--) {
13400
- var context = {};
13401
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
13402
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
13403
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13404
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13405
- if (kind === "accessor") {
13406
- if (result === void 0) continue;
13407
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
13408
- if (_ = accept(result.get)) descriptor.get = _;
13409
- if (_ = accept(result.set)) descriptor.set = _;
13410
- if (_ = accept(result.init)) initializers.unshift(_);
13405
+ get feed() {
13406
+ return null;
13407
+ }
13408
+ async show(payload) {
13409
+ try {
13410
+ const storyStore = this.storyManager.rootStore.storyStore;
13411
+ const story = await storyStore.fetchStoryById({
13412
+ storyId: payload.storyId,
13413
+ feedSlug: "",
13414
+ once: true
13415
+ });
13416
+ if (story.error)
13417
+ throw story.error;
13418
+ if (story.isOpened)
13419
+ throw new IasStoryAlreadyShownError(payload.storyId.toString());
13420
+ this.openStoryReader(story);
13411
13421
  }
13412
- else if (_ = accept(result)) {
13413
- if (kind === "field") initializers.unshift(_);
13414
- else descriptor[key] = _;
13422
+ catch (error) {
13423
+ this.storyReaderViewModel.close();
13424
+ throw error;
13415
13425
  }
13416
13426
  }
13417
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
13418
- done = true;
13419
- };
13420
-
13427
+ openStoryReader(story) {
13428
+ this.storyReaderViewModel.open({
13429
+ windowReferer: STORY_READER_WINDOW_REFERER.default,
13430
+ id: story.id,
13431
+ stories: [story]
13432
+ });
13433
+ }
13434
+ async handleNextStoryByIndex(storyIndex) { }
13435
+ async reload(payload) { }
13436
+ }
13421
13437
 
13422
- let ShowStoryStrategy = (() => {
13423
- var _a;
13424
- let _instanceExtraInitializers = [];
13425
- let _show_decorators;
13426
- return _a = class ShowStoryStrategy {
13427
- constructor(storyManager, storyReaderViewModel) {
13428
- Object.defineProperty(this, "storyManager", {
13429
- enumerable: true,
13430
- configurable: true,
13431
- writable: true,
13432
- value: (showStoryStrategy_runInitializers(this, _instanceExtraInitializers), storyManager)
13433
- });
13434
- Object.defineProperty(this, "storyReaderViewModel", {
13435
- enumerable: true,
13436
- configurable: true,
13437
- writable: true,
13438
- value: storyReaderViewModel
13439
- });
13440
- }
13441
- get feed() {
13442
- return null;
13443
- }
13444
- async show(payload) {
13445
- const storyStore = this.storyManager.rootStore.storyStore;
13446
- const story = await storyStore.fetchStoryById({
13447
- storyId: payload.storyId,
13448
- feedSlug: "",
13449
- fetchShareUrl: payload.fetchShareUrl
13450
- });
13451
- this.openStoryReader(story, payload);
13452
- }
13453
- openStoryReader(story, payload) {
13454
- this.storyReaderViewModel.open({
13455
- windowReferer: STORY_READER_WINDOW_REFERER.default,
13456
- id: story.id,
13457
- stories: [story]
13458
- });
13459
- }
13460
- async handleNextStoryByIndex(storyIndex) { }
13461
- async reload(payload) { }
13462
- },
13463
- (() => {
13464
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
13465
- _show_decorators = [noConcurrent];
13466
- showStoryStrategy_esDecorate(_a, null, _show_decorators, { kind: "method", name: "show", static: false, private: false, access: { has: obj => "show" in obj, get: obj => obj.show }, metadata: _metadata }, null, _instanceExtraInitializers);
13467
- if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
13468
- })(),
13469
- _a;
13470
- })();
13438
+ ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/showStoryStrategy.ts
13471
13439
 
13440
+ class ShowStoryStrategy {
13441
+ constructor(storyManager, storyReaderViewModel) {
13442
+ Object.defineProperty(this, "storyManager", {
13443
+ enumerable: true,
13444
+ configurable: true,
13445
+ writable: true,
13446
+ value: storyManager
13447
+ });
13448
+ Object.defineProperty(this, "storyReaderViewModel", {
13449
+ enumerable: true,
13450
+ configurable: true,
13451
+ writable: true,
13452
+ value: storyReaderViewModel
13453
+ });
13454
+ }
13455
+ get feed() {
13456
+ return null;
13457
+ }
13458
+ async show(payload) {
13459
+ const storyStore = this.storyManager.rootStore.storyStore;
13460
+ const story = await storyStore.fetchStoryById({
13461
+ storyId: payload.storyId,
13462
+ feedSlug: "",
13463
+ fetchShareUrl: payload.fetchShareUrl
13464
+ });
13465
+ this.openStoryReader(story, payload);
13466
+ }
13467
+ openStoryReader(story, payload) {
13468
+ this.storyReaderViewModel.open({
13469
+ windowReferer: STORY_READER_WINDOW_REFERER.default,
13470
+ id: story.id,
13471
+ stories: [story]
13472
+ });
13473
+ }
13474
+ async handleNextStoryByIndex(storyIndex) { }
13475
+ async reload(payload) { }
13476
+ }
13472
13477
 
13473
13478
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyDisplayStrategies/storyDisplayStrategyFactory.ts
13474
13479
 
@@ -13623,6 +13628,509 @@ class StoryReaderStatisticsController {
13623
13628
  }
13624
13629
  }
13625
13630
 
13631
+ ;// CONCATENATED MODULE: ../core/src/cache/models/cacheEntry.ts
13632
+ class CacheEntry {
13633
+ constructor(url, blob, lastAccessed = Date.now()) {
13634
+ Object.defineProperty(this, "url", {
13635
+ enumerable: true,
13636
+ configurable: true,
13637
+ writable: true,
13638
+ value: url
13639
+ });
13640
+ Object.defineProperty(this, "blob", {
13641
+ enumerable: true,
13642
+ configurable: true,
13643
+ writable: true,
13644
+ value: blob
13645
+ });
13646
+ Object.defineProperty(this, "lastAccessed", {
13647
+ enumerable: true,
13648
+ configurable: true,
13649
+ writable: true,
13650
+ value: lastAccessed
13651
+ });
13652
+ Object.defineProperty(this, "blobUrl", {
13653
+ enumerable: true,
13654
+ configurable: true,
13655
+ writable: true,
13656
+ value: void 0
13657
+ });
13658
+ }
13659
+ updateLastAccessed() {
13660
+ this.lastAccessed = Date.now();
13661
+ }
13662
+ getOrCreateBlobUrl() {
13663
+ if (!this.blobUrl) {
13664
+ this.blobUrl = URL.createObjectURL(this.blob);
13665
+ }
13666
+ return this.blobUrl;
13667
+ }
13668
+ unlinkBlob() {
13669
+ if (this.blobUrl)
13670
+ URL.revokeObjectURL(this.blobUrl);
13671
+ }
13672
+ destroy() {
13673
+ this.unlinkBlob();
13674
+ }
13675
+ }
13676
+
13677
+ ;// CONCATENATED MODULE: ../core/src/cache/cacheRepository.ts
13678
+
13679
+ class CacheRepository {
13680
+ constructor(driver) {
13681
+ Object.defineProperty(this, "driver", {
13682
+ enumerable: true,
13683
+ configurable: true,
13684
+ writable: true,
13685
+ value: driver
13686
+ });
13687
+ Object.defineProperty(this, "entries", {
13688
+ enumerable: true,
13689
+ configurable: true,
13690
+ writable: true,
13691
+ value: new Map()
13692
+ });
13693
+ }
13694
+ async get(url) {
13695
+ let entry = this.entries.get(url);
13696
+ if (!entry) {
13697
+ const record = await this.driver.get(url);
13698
+ if (!record)
13699
+ return;
13700
+ entry = new CacheEntry(record.url, record.blob, record.lastAccessed);
13701
+ this.entries.set(url, entry);
13702
+ }
13703
+ return entry;
13704
+ }
13705
+ async loadAllEntries() {
13706
+ const records = await this.driver.getAll();
13707
+ const entities = [];
13708
+ for (const record of records) {
13709
+ const entry = new CacheEntry(record.url, record.blob, record.lastAccessed);
13710
+ this.entries.set(record.url, entry);
13711
+ entities.push(entry);
13712
+ }
13713
+ return entities;
13714
+ }
13715
+ async save(entry) {
13716
+ this.entries.set(entry.url, entry);
13717
+ await this.driver.set({
13718
+ url: entry.url,
13719
+ blob: entry.blob,
13720
+ lastAccessed: entry.lastAccessed
13721
+ });
13722
+ }
13723
+ async updateAccessTime(entry) {
13724
+ this.entries.set(entry.url, entry);
13725
+ await this.driver.updateAccessTime(entry.url, entry.lastAccessed);
13726
+ }
13727
+ async delete(url) {
13728
+ this.entries.delete(url);
13729
+ await this.driver.delete(url);
13730
+ }
13731
+ async getAll() {
13732
+ return Array.from(this.entries.values());
13733
+ }
13734
+ async clear() {
13735
+ for (const entry of this.entries.values())
13736
+ entry.destroy();
13737
+ this.entries.clear();
13738
+ //await this.driver.clear();
13739
+ }
13740
+ }
13741
+
13742
+ ;// CONCATENATED MODULE: ../core/src/cache/drivers/indexedDBDriver.ts
13743
+ class IndexedDBCacheDriver {
13744
+ constructor(dbName, storeName) {
13745
+ Object.defineProperty(this, "dbName", {
13746
+ enumerable: true,
13747
+ configurable: true,
13748
+ writable: true,
13749
+ value: void 0
13750
+ });
13751
+ Object.defineProperty(this, "storeName", {
13752
+ enumerable: true,
13753
+ configurable: true,
13754
+ writable: true,
13755
+ value: void 0
13756
+ });
13757
+ this.dbName = dbName;
13758
+ this.storeName = storeName;
13759
+ }
13760
+ async getDB() {
13761
+ return new Promise((resolve, reject) => {
13762
+ const request = indexedDB.open(this.dbName, 1);
13763
+ request.onupgradeneeded = () => {
13764
+ const db = request.result;
13765
+ if (!db.objectStoreNames.contains(this.storeName)) {
13766
+ const store = db.createObjectStore(this.storeName, { keyPath: "url" });
13767
+ store.createIndex("lastAccessed", "lastAccessed");
13768
+ }
13769
+ };
13770
+ request.onsuccess = () => resolve(request.result);
13771
+ request.onerror = () => reject(request.error);
13772
+ });
13773
+ }
13774
+ async get(url) {
13775
+ const db = await this.getDB();
13776
+ return new Promise((resolve, reject) => {
13777
+ const tx = db.transaction(this.storeName, "readonly");
13778
+ const store = tx.objectStore(this.storeName);
13779
+ const request = store.get(url);
13780
+ request.onsuccess = () => {
13781
+ const result = request.result;
13782
+ resolve(result ? { url, lastAccessed: result.lastAccessed, blob: result.blob } : undefined);
13783
+ };
13784
+ request.onerror = () => reject(request.error);
13785
+ });
13786
+ }
13787
+ async set(record) {
13788
+ const db = await this.getDB();
13789
+ return new Promise((resolve, reject) => {
13790
+ const tx = db.transaction(this.storeName, "readwrite");
13791
+ tx.objectStore(this.storeName).put(record);
13792
+ tx.oncomplete = () => resolve();
13793
+ tx.onerror = () => reject(tx.error);
13794
+ });
13795
+ }
13796
+ async updateAccessTime(url, lastAccessed) {
13797
+ const db = await this.getDB();
13798
+ const tx = db.transaction(this.storeName, "readwrite");
13799
+ const store = tx.objectStore(this.storeName);
13800
+ const existing = await new Promise((resolve, reject) => {
13801
+ const req = store.get(url);
13802
+ req.onsuccess = () => resolve(req.result);
13803
+ req.onerror = () => reject(req.error);
13804
+ });
13805
+ if (existing) {
13806
+ existing.lastAccessed = lastAccessed;
13807
+ store.put(existing);
13808
+ }
13809
+ return new Promise((resolve, reject) => {
13810
+ tx.oncomplete = () => resolve();
13811
+ tx.onerror = () => reject(tx.error);
13812
+ });
13813
+ }
13814
+ async delete(url) {
13815
+ const db = await this.getDB();
13816
+ return new Promise((resolve, reject) => {
13817
+ const tx = db.transaction(this.storeName, "readwrite");
13818
+ tx.objectStore(this.storeName).delete(url);
13819
+ tx.oncomplete = () => resolve();
13820
+ tx.onerror = () => reject(tx.error);
13821
+ });
13822
+ }
13823
+ async getAll() {
13824
+ const db = await this.getDB();
13825
+ return new Promise((resolve, reject) => {
13826
+ const tx = db.transaction(this.storeName, "readonly");
13827
+ const store = tx.objectStore(this.storeName);
13828
+ const request = store.getAll();
13829
+ request.onsuccess = () => resolve(request.result);
13830
+ request.onerror = () => reject(request.error);
13831
+ });
13832
+ }
13833
+ async clear() {
13834
+ const db = await this.getDB();
13835
+ return new Promise((resolve, reject) => {
13836
+ const tx = db.transaction(this.storeName, "readwrite");
13837
+ tx.objectStore(this.storeName).clear();
13838
+ tx.oncomplete = () => resolve();
13839
+ tx.onerror = () => reject(tx.error);
13840
+ });
13841
+ }
13842
+ }
13843
+
13844
+ ;// CONCATENATED MODULE: ../core/src/cache/drivers/memoryCacheDriver.ts
13845
+ class MemoryCacheDriver {
13846
+ constructor() {
13847
+ Object.defineProperty(this, "store", {
13848
+ enumerable: true,
13849
+ configurable: true,
13850
+ writable: true,
13851
+ value: new Map()
13852
+ });
13853
+ }
13854
+ async get(url) {
13855
+ return this.store.get(url);
13856
+ }
13857
+ async set(record) {
13858
+ this.store.set(record.url, record);
13859
+ }
13860
+ async delete(url) {
13861
+ this.store.delete(url);
13862
+ }
13863
+ async getAll() {
13864
+ return Array.from(this.store.values());
13865
+ }
13866
+ async clear() {
13867
+ this.store.clear();
13868
+ }
13869
+ async updateAccessTime(url, lastAccessed) {
13870
+ const record = await this.get(url);
13871
+ if (!record)
13872
+ return;
13873
+ record.lastAccessed = lastAccessed;
13874
+ this.set(record);
13875
+ }
13876
+ }
13877
+
13878
+ ;// CONCATENATED MODULE: ../core/src/cache/lruCache.ts
13879
+
13880
+
13881
+ class LRUCache {
13882
+ constructor(repository, loader, options) {
13883
+ var _a, _b;
13884
+ Object.defineProperty(this, "repository", {
13885
+ enumerable: true,
13886
+ configurable: true,
13887
+ writable: true,
13888
+ value: repository
13889
+ });
13890
+ Object.defineProperty(this, "loader", {
13891
+ enumerable: true,
13892
+ configurable: true,
13893
+ writable: true,
13894
+ value: loader
13895
+ });
13896
+ Object.defineProperty(this, "urlLocks", {
13897
+ enumerable: true,
13898
+ configurable: true,
13899
+ writable: true,
13900
+ value: new Map()
13901
+ });
13902
+ Object.defineProperty(this, "options", {
13903
+ enumerable: true,
13904
+ configurable: true,
13905
+ writable: true,
13906
+ value: void 0
13907
+ });
13908
+ this.options = {
13909
+ maxSize: (_a = options === null || options === void 0 ? void 0 : options.maxSize) !== null && _a !== void 0 ? _a : 20,
13910
+ debug: Boolean(options === null || options === void 0 ? void 0 : options.debug),
13911
+ ttl: (_b = options === null || options === void 0 ? void 0 : options.ttl) !== null && _b !== void 0 ? _b : 3600
13912
+ };
13913
+ }
13914
+ async init() {
13915
+ await this.repository.loadAllEntries();
13916
+ await this.tryEvict();
13917
+ }
13918
+ async getAll() {
13919
+ return this.repository.getAll();
13920
+ }
13921
+ async get(url, priority) {
13922
+ const mutex = this.getMutexForUrl(url);
13923
+ const release = await mutex.acquire();
13924
+ try {
13925
+ let entry = await this.repository.get(url);
13926
+ if (!entry)
13927
+ entry = await this.add(url, priority);
13928
+ entry.updateLastAccessed();
13929
+ entry.getOrCreateBlobUrl();
13930
+ if (this.options.debug)
13931
+ console.log("[IAS]: Get from cache", entry);
13932
+ await this.repository.updateAccessTime(entry);
13933
+ return entry;
13934
+ }
13935
+ finally {
13936
+ release();
13937
+ }
13938
+ }
13939
+ async tryEvict() {
13940
+ const expiredEntries = await this.evictExpired();
13941
+ const oldestEntries = await this.evictOldest();
13942
+ return [...expiredEntries, ...oldestEntries];
13943
+ }
13944
+ async evictOldest() {
13945
+ const entries = await this.repository.getAll();
13946
+ if (entries.length <= this.options.maxSize)
13947
+ return [];
13948
+ const evictedEntries = [];
13949
+ const sorted = entries.sort((a, b) => a.lastAccessed - b.lastAccessed);
13950
+ while (sorted.length > this.options.maxSize) {
13951
+ const entry = sorted.shift();
13952
+ if (!entry)
13953
+ continue;
13954
+ if (this.options.debug)
13955
+ console.log("[IAS]: Remove oldest entry from cache", entry);
13956
+ await this.removeEntry(entry);
13957
+ evictedEntries.push(entry);
13958
+ }
13959
+ return evictedEntries;
13960
+ }
13961
+ async wait() {
13962
+ await Promise.all(Array.from(this.urlLocks.values()).map(urlLock => urlLock.waitForUnlock()));
13963
+ }
13964
+ async evictExpired() {
13965
+ if (this.options.ttl === 0)
13966
+ return [];
13967
+ const entries = await this.repository.getAll();
13968
+ const now = Date.now();
13969
+ const evictedEntries = [];
13970
+ for (const entry of entries) {
13971
+ if (entry.lastAccessed + this.options.ttl * 1000 < now) {
13972
+ if (this.options.debug)
13973
+ console.log("[IAS]: Remove expired entry from cache", entry);
13974
+ await this.removeEntry(entry);
13975
+ evictedEntries.push(entry);
13976
+ }
13977
+ }
13978
+ return evictedEntries;
13979
+ }
13980
+ async add(url, priority) {
13981
+ const blob = await this.loader.enqueue(url, priority);
13982
+ const entry = new CacheEntry(url, blob);
13983
+ await this.repository.save(entry);
13984
+ await this.tryEvict();
13985
+ if (this.options.debug)
13986
+ console.log("[IAS]: Add to cache", entry);
13987
+ return entry;
13988
+ }
13989
+ getMutexForUrl(url) {
13990
+ let mutex = this.urlLocks.get(url);
13991
+ if (!mutex) {
13992
+ mutex = new external_async_mutex_namespaceObject.Mutex();
13993
+ this.urlLocks.set(url, mutex);
13994
+ }
13995
+ return mutex;
13996
+ }
13997
+ cleanupLock(url) {
13998
+ this.urlLocks.delete(url);
13999
+ }
14000
+ async removeEntry(entry) {
14001
+ entry.destroy();
14002
+ this.cleanupLock(entry.url);
14003
+ await this.repository.delete(entry.url);
14004
+ }
14005
+ }
14006
+
14007
+ ;// CONCATENATED MODULE: ../core/src/cache/resourceLoader.ts
14008
+
14009
+ class ResourceLoader {
14010
+ constructor(concurrency) {
14011
+ Object.defineProperty(this, "concurrency", {
14012
+ enumerable: true,
14013
+ configurable: true,
14014
+ writable: true,
14015
+ value: concurrency
14016
+ });
14017
+ Object.defineProperty(this, "semaphore", {
14018
+ enumerable: true,
14019
+ configurable: true,
14020
+ writable: true,
14021
+ value: void 0
14022
+ });
14023
+ this.semaphore = new external_async_mutex_namespaceObject.Semaphore(concurrency);
14024
+ }
14025
+ async enqueue(url, priority) {
14026
+ return await this.semaphore.runExclusive(async () => {
14027
+ const response = await fetch(url, { cache: "no-store" });
14028
+ const blob = await response.blob();
14029
+ return blob;
14030
+ }, 1, priority);
14031
+ }
14032
+ wait() {
14033
+ return this.semaphore.waitForUnlock(this.concurrency);
14034
+ }
14035
+ clear() {
14036
+ this.semaphore.cancel();
14037
+ }
14038
+ async destroy() {
14039
+ this.clear();
14040
+ await this.wait();
14041
+ }
14042
+ }
14043
+
14044
+ ;// CONCATENATED MODULE: ../core/src/cache/cacheManager.ts
14045
+
14046
+
14047
+
14048
+
14049
+ const CACHE_VERSION = 1;
14050
+ class CacheManager {
14051
+ get isDestroyed() {
14052
+ return this._isDestroyed;
14053
+ }
14054
+ constructor(options) {
14055
+ var _a, _b, _c, _d, _e;
14056
+ Object.defineProperty(this, "lruCache", {
14057
+ enumerable: true,
14058
+ configurable: true,
14059
+ writable: true,
14060
+ value: void 0
14061
+ });
14062
+ Object.defineProperty(this, "loader", {
14063
+ enumerable: true,
14064
+ configurable: true,
14065
+ writable: true,
14066
+ value: void 0
14067
+ });
14068
+ Object.defineProperty(this, "cacheRepository", {
14069
+ enumerable: true,
14070
+ configurable: true,
14071
+ writable: true,
14072
+ value: void 0
14073
+ });
14074
+ Object.defineProperty(this, "options", {
14075
+ enumerable: true,
14076
+ configurable: true,
14077
+ writable: true,
14078
+ value: void 0
14079
+ });
14080
+ Object.defineProperty(this, "_isDestroyed", {
14081
+ enumerable: true,
14082
+ configurable: true,
14083
+ writable: true,
14084
+ value: false
14085
+ });
14086
+ this.options = {
14087
+ maxSize: (_a = options.maxSize) !== null && _a !== void 0 ? _a : 20,
14088
+ concurrency: (_b = options.concurrency) !== null && _b !== void 0 ? _b : 5,
14089
+ debug: Boolean(options.debug),
14090
+ ttl: (_c = options.ttl) !== null && _c !== void 0 ? _c : 3600,
14091
+ type: (_d = options.type) !== null && _d !== void 0 ? _d : "indexeddb",
14092
+ storeName: (_e = options.storeName) !== null && _e !== void 0 ? _e : "resources"
14093
+ };
14094
+ const driver = this.createCacheDriver();
14095
+ this.cacheRepository = new CacheRepository(driver);
14096
+ this.loader = new ResourceLoader(this.options.concurrency);
14097
+ this.lruCache = new LRUCache(this.cacheRepository, this.loader, {
14098
+ maxSize: this.options.maxSize,
14099
+ debug: this.options.debug,
14100
+ ttl: this.options.ttl
14101
+ });
14102
+ this.lruCache.init().catch(error => console.error("[IAS]: LRU cache init error", error));
14103
+ }
14104
+ async preload(requests) {
14105
+ const results = await Promise.allSettled(requests.map(async (request) => {
14106
+ return await this.lruCache.get(request.url, request.priority);
14107
+ }));
14108
+ return results
14109
+ .filter((r) => r.status === "fulfilled" && r.value !== null)
14110
+ .map(r => r.value);
14111
+ }
14112
+ async destroy() {
14113
+ try {
14114
+ this._isDestroyed = true;
14115
+ await this.loader.destroy();
14116
+ await this.lruCache.wait();
14117
+ }
14118
+ finally {
14119
+ await this.cacheRepository.clear();
14120
+ if (this.options.debug)
14121
+ console.log("[IAS]: Destroy LRU cache");
14122
+ }
14123
+ }
14124
+ createCacheDriver() {
14125
+ if (this.options.type === "indexeddb")
14126
+ return new IndexedDBCacheDriver(`ias-cache-v${CACHE_VERSION}`, this.options.storeName);
14127
+ return new MemoryCacheDriver();
14128
+ }
14129
+ }
14130
+
14131
+ ;// CONCATENATED MODULE: ../core/src/cache/index.ts
14132
+
14133
+
13626
14134
  ;// CONCATENATED MODULE: ../core/src/readers/storyReader/storyReaderViewModel/storyReaderViewModel.ts
13627
14135
  var storyReaderViewModel_runInitializers = (undefined && undefined.__runInitializers) || function (thisArg, initializers, value) {
13628
14136
  var useValue = arguments.length > 2;
@@ -13679,6 +14187,8 @@ var storyReaderViewModel_classPrivateFieldSet = (undefined && undefined.__classP
13679
14187
 
13680
14188
 
13681
14189
 
14190
+
14191
+
13682
14192
  var StoryReaderEvent;
13683
14193
  (function (StoryReaderEvent) {
13684
14194
  StoryReaderEvent["Close"] = "closeStoryReader";
@@ -13711,6 +14221,11 @@ let StoryReaderViewModel = (() => {
13711
14221
  let _get_reachEnd_decorators;
13712
14222
  let _open_decorators;
13713
14223
  let _close_decorators;
14224
+ let _showStory_decorators;
14225
+ let _showStoryOnce_decorators;
14226
+ let _showStoryFromSharePage_decorators;
14227
+ let _showOnboardingStories_decorators;
14228
+ let _showMultipleStories_decorators;
13714
14229
  let _reloadStory_decorators;
13715
14230
  let _nextStory_decorators;
13716
14231
  let _prevStory_decorators;
@@ -13800,6 +14315,12 @@ let StoryReaderViewModel = (() => {
13800
14315
  writable: true,
13801
14316
  value: false
13802
14317
  });
14318
+ Object.defineProperty(this, "cacheManager", {
14319
+ enumerable: true,
14320
+ configurable: true,
14321
+ writable: true,
14322
+ value: null
14323
+ });
13803
14324
  this.handleWindowUnload = this.handleWindowUnload.bind(this);
13804
14325
  this.handleKeydown = this.handleKeydown.bind(this);
13805
14326
  window.addEventListener("beforeunload", this.handleWindowUnload);
@@ -13853,6 +14374,8 @@ let StoryReaderViewModel = (() => {
13853
14374
  var _b, _c;
13854
14375
  if (this.activeStory)
13855
14376
  this.resetReaderToDefaultState(this.activeStory);
14377
+ if (this.storyManager.config.cache)
14378
+ this.cacheManager = new CacheManager(this.storyManager.config.cache);
13856
14379
  this.windowReferer = payload.windowReferer;
13857
14380
  this.setStories(payload.stories);
13858
14381
  const activeStory = this.navigationController.setActiveStoryById(payload.id);
@@ -13890,6 +14413,7 @@ let StoryReaderViewModel = (() => {
13890
14413
  });
13891
14414
  }
13892
14415
  resetReaderToDefaultState(activeStory, closeAction) {
14416
+ var _b;
13893
14417
  const event = new CloseStoryEvent(activeStory, {
13894
14418
  action: closeAction
13895
14419
  });
@@ -13904,6 +14428,7 @@ let StoryReaderViewModel = (() => {
13904
14428
  this._touchController.destroy();
13905
14429
  document.removeEventListener("keydown", this.handleKeydown);
13906
14430
  this.navigationController.destroy();
14431
+ (_b = this.cacheManager) === null || _b === void 0 ? void 0 : _b.destroy();
13907
14432
  }
13908
14433
  canBeClosed() {
13909
14434
  return this.activeStory ? !this.activeStory.disableClose : false;
@@ -13973,12 +14498,14 @@ let StoryReaderViewModel = (() => {
13973
14498
  this.navigationController.navigateStoryWithAnimation(index, action);
13974
14499
  }
13975
14500
  destroy() {
14501
+ var _b;
13976
14502
  if (this.activeStory) {
13977
14503
  this.emitCloseEvents(this.activeStory, CloseStoryReaderAction.AppClose);
13978
14504
  this.resetReaderToDefaultState(this.activeStory);
13979
14505
  }
13980
14506
  this.removeAllListeners();
13981
14507
  window.removeEventListener("beforeunload", this.handleWindowUnload);
14508
+ (_b = this.cacheManager) === null || _b === void 0 ? void 0 : _b.destroy();
13982
14509
  }
13983
14510
  closeGoodsWidget() {
13984
14511
  var _b;
@@ -14049,7 +14576,7 @@ let StoryReaderViewModel = (() => {
14049
14576
  setStories(stories) {
14050
14577
  const slideApiHandlersFactory = new StorySlideApiHandlersFactory(this.storyManager, this, this.storyReaderStatisticV1Service, this.storyReaderStatisticV2Service);
14051
14578
  for (const story of stories) {
14052
- this._stories.push(new StoryViewModel(this.storyManager, this, story, slideApiHandlersFactory, this.storyReaderStatisticV1Service, this.storyReaderStatisticV2Service));
14579
+ this._stories.push(new StoryViewModel(this.storyManager, this, story, slideApiHandlersFactory, this.storyReaderStatisticV1Service, this.storyReaderStatisticV2Service, this.cacheManager));
14053
14580
  }
14054
14581
  }
14055
14582
  handleKeydown(e) {
@@ -14104,6 +14631,11 @@ let StoryReaderViewModel = (() => {
14104
14631
  _get_reachEnd_decorators = [external_mobx_namespaceObject.computed];
14105
14632
  _open_decorators = [external_mobx_namespaceObject.action];
14106
14633
  _close_decorators = [external_mobx_namespaceObject.action];
14634
+ _showStory_decorators = [noConcurrent];
14635
+ _showStoryOnce_decorators = [noConcurrent];
14636
+ _showStoryFromSharePage_decorators = [noConcurrent];
14637
+ _showOnboardingStories_decorators = [noConcurrent];
14638
+ _showMultipleStories_decorators = [noConcurrent];
14107
14639
  _reloadStory_decorators = [external_mobx_namespaceObject.action];
14108
14640
  _nextStory_decorators = [external_mobx_namespaceObject.action];
14109
14641
  _prevStory_decorators = [external_mobx_namespaceObject.action];
@@ -14123,6 +14655,11 @@ let StoryReaderViewModel = (() => {
14123
14655
  storyReaderViewModel_esDecorate(_a, null, _get_reachEnd_decorators, { kind: "getter", name: "reachEnd", static: false, private: false, access: { has: obj => "reachEnd" in obj, get: obj => obj.reachEnd }, metadata: _metadata }, null, _instanceExtraInitializers);
14124
14656
  storyReaderViewModel_esDecorate(_a, null, _open_decorators, { kind: "method", name: "open", static: false, private: false, access: { has: obj => "open" in obj, get: obj => obj.open }, metadata: _metadata }, null, _instanceExtraInitializers);
14125
14657
  storyReaderViewModel_esDecorate(_a, null, _close_decorators, { kind: "method", name: "close", static: false, private: false, access: { has: obj => "close" in obj, get: obj => obj.close }, metadata: _metadata }, null, _instanceExtraInitializers);
14658
+ storyReaderViewModel_esDecorate(_a, null, _showStory_decorators, { kind: "method", name: "showStory", static: false, private: false, access: { has: obj => "showStory" in obj, get: obj => obj.showStory }, metadata: _metadata }, null, _instanceExtraInitializers);
14659
+ storyReaderViewModel_esDecorate(_a, null, _showStoryOnce_decorators, { kind: "method", name: "showStoryOnce", static: false, private: false, access: { has: obj => "showStoryOnce" in obj, get: obj => obj.showStoryOnce }, metadata: _metadata }, null, _instanceExtraInitializers);
14660
+ storyReaderViewModel_esDecorate(_a, null, _showStoryFromSharePage_decorators, { kind: "method", name: "showStoryFromSharePage", static: false, private: false, access: { has: obj => "showStoryFromSharePage" in obj, get: obj => obj.showStoryFromSharePage }, metadata: _metadata }, null, _instanceExtraInitializers);
14661
+ storyReaderViewModel_esDecorate(_a, null, _showOnboardingStories_decorators, { kind: "method", name: "showOnboardingStories", static: false, private: false, access: { has: obj => "showOnboardingStories" in obj, get: obj => obj.showOnboardingStories }, metadata: _metadata }, null, _instanceExtraInitializers);
14662
+ storyReaderViewModel_esDecorate(_a, null, _showMultipleStories_decorators, { kind: "method", name: "showMultipleStories", static: false, private: false, access: { has: obj => "showMultipleStories" in obj, get: obj => obj.showMultipleStories }, metadata: _metadata }, null, _instanceExtraInitializers);
14126
14663
  storyReaderViewModel_esDecorate(_a, null, _reloadStory_decorators, { kind: "method", name: "reloadStory", static: false, private: false, access: { has: obj => "reloadStory" in obj, get: obj => obj.reloadStory }, metadata: _metadata }, null, _instanceExtraInitializers);
14127
14664
  storyReaderViewModel_esDecorate(_a, null, _nextStory_decorators, { kind: "method", name: "nextStory", static: false, private: false, access: { has: obj => "nextStory" in obj, get: obj => obj.nextStory }, metadata: _metadata }, null, _instanceExtraInitializers);
14128
14665
  storyReaderViewModel_esDecorate(_a, null, _prevStory_decorators, { kind: "method", name: "prevStory", static: false, private: false, access: { has: obj => "prevStory" in obj, get: obj => obj.prevStory }, metadata: _metadata }, null, _instanceExtraInitializers);
@@ -15140,8 +15677,12 @@ let StoryManagerConfig = (() => {
15140
15677
  });
15141
15678
  _StoryManagerConfig__anonymous_accessor_storage.set(this, storyManagerConfig_runInitializers(this, __anonymous_initializers, false));
15142
15679
  _StoryManagerConfig__options_accessor_storage.set(this, (storyManagerConfig_runInitializers(this, __anonymous_extraInitializers), storyManagerConfig_runInitializers(this, __options_initializers, {})));
15143
- storyManagerConfig_runInitializers(this, __options_extraInitializers);
15144
- this.storyManager = storyManager;
15680
+ Object.defineProperty(this, "_cache", {
15681
+ enumerable: true,
15682
+ configurable: true,
15683
+ writable: true,
15684
+ value: (storyManagerConfig_runInitializers(this, __options_extraInitializers), null)
15685
+ });
15145
15686
  this.update(configDto);
15146
15687
  this._isInited = true;
15147
15688
  }
@@ -15187,6 +15728,9 @@ let StoryManagerConfig = (() => {
15187
15728
  get options() {
15188
15729
  return this._options;
15189
15730
  }
15731
+ get cache() {
15732
+ return this._cache;
15733
+ }
15190
15734
  disableStatistic() {
15191
15735
  this._isStatisticsDisabled = true;
15192
15736
  }
@@ -15271,7 +15815,7 @@ let StoryManagerConfig = (() => {
15271
15815
  this._options = options;
15272
15816
  }
15273
15817
  update(configDto) {
15274
- var _b, _c, _d, _e, _f;
15818
+ var _b, _c, _d, _e, _f, _g;
15275
15819
  this._appPackageId = (_b = configDto.appPackageId) !== null && _b !== void 0 ? _b : "";
15276
15820
  this._disableDeviceId = Boolean(configDto.disableDeviceId);
15277
15821
  this.setOptions(configDto.options);
@@ -15283,6 +15827,7 @@ let StoryManagerConfig = (() => {
15283
15827
  this.setImagePlaceholders((_e = configDto.imagePlaceholders) !== null && _e !== void 0 ? _e : {});
15284
15828
  this.setTags((_f = configDto.tags) !== null && _f !== void 0 ? _f : []);
15285
15829
  this.setDir(configDto.dir);
15830
+ this._cache = configDto.cache ? Object.assign(Object.assign({}, configDto.cache), { prefetch: (_g = configDto.cache.prefetch) !== null && _g !== void 0 ? _g : true }) : null;
15286
15831
  }
15287
15832
  mapTextPlaceholders(textPlaceholderDtos) {
15288
15833
  const textPlaceholders = [];
@@ -15388,6 +15933,9 @@ class NullStoryManagerConfig {
15388
15933
  get options() {
15389
15934
  return {};
15390
15935
  }
15936
+ get cache() {
15937
+ return null;
15938
+ }
15391
15939
  disableStatistic() { }
15392
15940
  enableStatistic() { }
15393
15941
  async setApiKey(apiKey) { }
@@ -17146,7 +17694,7 @@ let IamReaderViewModel = (() => {
17146
17694
  this.clearActiveMessage();
17147
17695
  this.visibilityObserver.unsubscribe();
17148
17696
  this.touchController.destroy();
17149
- this.scrollbarHelper.enable();
17697
+ this.scrollbarHelper.disable();
17150
17698
  }
17151
17699
  async close() {
17152
17700
  var _b;
@@ -17159,7 +17707,7 @@ let IamReaderViewModel = (() => {
17159
17707
  this.touchController.init(document.body);
17160
17708
  this.setActiveMessage(message);
17161
17709
  this.visibilityObserver.subscribe();
17162
- this.scrollbarHelper.disable();
17710
+ this.scrollbarHelper.enable();
17163
17711
  }
17164
17712
  destroy() { }
17165
17713
  emitWidgetEvent(widgetEvent) {
@@ -20434,7 +20982,7 @@ class UgcEditorStore {
20434
20982
  const session = await this.storyManager.rootStore.sessionStore.open();
20435
20983
  const ugcEditorConfigDto = await this.ugcEditorApi.fetchUgcEditorConfig();
20436
20984
  const storyManagerConfig = this.storyManager.config;
20437
- const sdkVersion = "1.7.9";
20985
+ const sdkVersion = "1.7.11";
20438
20986
  this._config = {
20439
20987
  sessionId: session.id,
20440
20988
  apiKey: storyManagerConfig.apiKey,
@@ -20467,7 +21015,6 @@ class UgcEditorApi {
20467
21015
  const requestConfig = {
20468
21016
  method: "GET",
20469
21017
  url: "ugc/editor-config",
20470
- params: {}
20471
21018
  };
20472
21019
  const response = await api.request(requestConfig);
20473
21020
  return response.data;
@@ -20866,11 +21413,11 @@ class StoryManager extends TypedEventEmitter {
20866
21413
  return this._userAgent;
20867
21414
  }
20868
21415
  get sdkVersionName() {
20869
- const sdkVersionName = "1.7.9";
21416
+ const sdkVersionName = "1.7.11";
20870
21417
  return sdkVersionName || "0.0.0";
20871
21418
  }
20872
21419
  get sdkVersionCode() {
20873
- const sdkVersionCode = 10709;
21420
+ const sdkVersionCode = 10711;
20874
21421
  return sdkVersionCode ? parseInt(sdkVersionCode) : 0;
20875
21422
  }
20876
21423
  get lang() {
@@ -20927,7 +21474,7 @@ class StoryManager extends TypedEventEmitter {
20927
21474
  this.rootStore.storyManagerConfigStore.setConfig(configDto);
20928
21475
  }
20929
21476
  setUserAgent(userAgent) {
20930
- const sdkVersionCode = 10709;
21477
+ const sdkVersionCode = 10711;
20931
21478
  const buildVersion = sdkVersionCode ? parseInt(sdkVersionCode) : 0;
20932
21479
  // According to RFC5987, HTTP header values can legitimately be supplied using the ISO-8859-1 encoding.
20933
21480
  this._userAgent = `${userAgent} ${convertStrToLatin1(navigator.userAgent)}`;
@@ -25047,8 +25594,7 @@ const Story_Story = (0,external_mobx_react_lite_namespaceObject.observer)((_a) =
25047
25594
  const shouldHideHeader = isDesktopGeometry && useModernLayout
25048
25595
  ? !isActiveStory || story.pauseState.isUIPaused
25049
25596
  : story.pauseState.isUIPaused;
25050
- const shouldHideActionPanel = isDesktopGeometry &&
25051
- ((useModernLayout && !isActiveStory) || story.textInput.isOpened);
25597
+ const shouldHideActionPanel = isDesktopGeometry && ((useModernLayout && !isActiveStory) || story.textInput.isOpened);
25052
25598
  (0,external_react_namespaceObject.useLayoutEffect)(() => {
25053
25599
  const bottomOffset = parseFloat(String(storyReaderOptions.actionPanelBottomOffset));
25054
25600
  story.actionPanel.setOptions(commonOptions);
@@ -25072,7 +25618,7 @@ const Story_Story = (0,external_mobx_react_lite_namespaceObject.observer)((_a) =
25072
25618
  story.sharePanel.completeNativeSharing({ result: false });
25073
25619
  }, onTouchStart: () => {
25074
25620
  story.sharePanel.completeNativeSharing({ result: false });
25075
- }, "data-testid": "story", children: [isDesktopGeometry && useModernLayout && ((0,jsx_runtime_namespaceObject.jsx)(StoryBackdrop, { hidden: isActiveStory })), story.canBeShown && ((0,jsx_runtime_namespaceObject.jsx)(StoryHeader, { hidden: shouldHideHeader, story: story, onClose: props.onClose, isDesktopGeometry: isDesktopGeometry })), (0,jsx_runtime_namespaceObject.jsx)(StorySlidesRenderer, { className: Story_story_module["story-slides"], story: story, preventNavigation: useModernLayout && isDesktopGeometry, isActiveStory: isActiveStory, isDesktopGeometry: isDesktopGeometry }), story.actionPanel.needShown && ((0,jsx_runtime_namespaceObject.jsx)(StoryActionPanel, { dir: story.dir, isDesktopGeometry: isDesktopGeometry, hidden: shouldHideActionPanel, actionPanel: story.actionPanel, commonOptions: commonOptions, storyReaderOptions: storyReaderOptions })), props.activeStory === story && ((0,jsx_runtime_namespaceObject.jsx)(GoodsWidgetViewer, { story: story, goodsWidgetOptions: goodsWidgetOptions })), props.activeStory === story && ((0,jsx_runtime_namespaceObject.jsx)(TextInputModal, { story: story, storyRef: storyRef, storyGeometry: geometry })), story.sharePanel.isOpened && ((0,jsx_runtime_namespaceObject.jsx)(SharePanel, { dir: story.dir, className: Story_story_module["share-panel-wrapper"], shareText: story.sharePanel.params.text, shareType: story.sharePanel.params.type, shareLink: story.sharePanel.params.link, onShareCompelete: (result) => story.sharePanel.handleShareComplete(story.sharePanel.params.id, result), sharePanelOptions: storyReaderOptions.sharePanel })), (0,jsx_runtime_namespaceObject.jsx)(Loader, { needShowErrorScreen: story.needShowErrorScreen, needShowLoaderScreen: story.needShowLoaderScreen, onReload: handleReloadStory })] }));
25621
+ }, "data-testid": "story", children: [isDesktopGeometry && useModernLayout && story.isSlideRendered && (0,jsx_runtime_namespaceObject.jsx)(StoryBackdrop, { hidden: isActiveStory }), story.canBeShown && story.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(StoryHeader, { hidden: shouldHideHeader, story: story, onClose: props.onClose, isDesktopGeometry: isDesktopGeometry })), (0,jsx_runtime_namespaceObject.jsx)(StorySlidesRenderer, { className: Story_story_module["story-slides"], story: story, preventNavigation: useModernLayout && isDesktopGeometry, isActiveStory: isActiveStory, isDesktopGeometry: isDesktopGeometry }), story.actionPanel.needShown && story.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(StoryActionPanel, { dir: story.dir, isDesktopGeometry: isDesktopGeometry, hidden: shouldHideActionPanel, actionPanel: story.actionPanel, commonOptions: commonOptions, storyReaderOptions: storyReaderOptions })), props.activeStory === story && ((0,jsx_runtime_namespaceObject.jsx)(GoodsWidgetViewer, { story: story, goodsWidgetOptions: goodsWidgetOptions })), props.activeStory === story && ((0,jsx_runtime_namespaceObject.jsx)(TextInputModal, { story: story, storyRef: storyRef, storyGeometry: geometry })), story.sharePanel.isOpened && ((0,jsx_runtime_namespaceObject.jsx)(SharePanel, { dir: story.dir, className: Story_story_module["share-panel-wrapper"], shareText: story.sharePanel.params.text, shareType: story.sharePanel.params.type, shareLink: story.sharePanel.params.link, onShareCompelete: (result) => story.sharePanel.handleShareComplete(story.sharePanel.params.id, result), sharePanelOptions: storyReaderOptions.sharePanel })), (0,jsx_runtime_namespaceObject.jsx)(Loader, { needShowErrorScreen: story.needShowErrorScreen, needShowLoaderScreen: story.needShowLoaderScreen, onReload: handleReloadStory })] }));
25076
25622
  });
25077
25623
 
25078
25624
  ;// CONCATENATED MODULE: ./src/StoryReader/Story/index.ts
@@ -25419,7 +25965,7 @@ const ModernStoryList = (0,external_mobx_react_lite_namespaceObject.observer)((p
25419
25965
  if (uiDisabled)
25420
25966
  return;
25421
25967
  props.storyReader.toStoryWithAnimationByIndex(index);
25422
- }, children: [(0,jsx_runtime_namespaceObject.jsx)(Story_Story, { index: index, story: story, slideClickDisabled: uiDisabled, activeStory: activeStory, geometry: props.storyGeometry, onClose: props.onCloseStory }), (props.storyReader.stories.length > 1 || story.slidesCount > 1) && ((0,jsx_runtime_namespaceObject.jsx)(ModernStoryListControls, { dir: props.storyReader.dir, display: isActiveStory && activeStory.canBeShown, disabled: uiDisabled, isNextDisabled: isNextDisabled, isPrevDisabled: isPrevDisabled, navigationOptions: storyReaderOptions.navigation, onNext: () => {
25968
+ }, children: [(0,jsx_runtime_namespaceObject.jsx)(Story_Story, { index: index, story: story, slideClickDisabled: uiDisabled, activeStory: activeStory, geometry: props.storyGeometry, onClose: props.onCloseStory }), (props.storyReader.stories.length > 1 || story.slidesCount > 1) && activeStory.isSlideRendered && ((0,jsx_runtime_namespaceObject.jsx)(ModernStoryListControls, { dir: props.storyReader.dir, display: isActiveStory && activeStory.canBeShown, disabled: uiDisabled, isNextDisabled: isNextDisabled, isPrevDisabled: isPrevDisabled, navigationOptions: storyReaderOptions.navigation, onNext: () => {
25423
25969
  props.storyReader.goNext();
25424
25970
  }, onPrev: () => {
25425
25971
  props.storyReader.goPrev();
@@ -26372,7 +26918,7 @@ const messageViewsByType = {
26372
26918
 
26373
26919
  ;// CONCATENATED MODULE: ./src/InAppMessaging/components/BottomSheet/BottomSheet.styles.ts
26374
26920
 
26375
- const bottomSheetStyles = (0,external_lit_namespaceObject.css) `.bottom-sheet{position:fixed;inset:0;left:0;bottom:0;right:0;z-index:999}.bottom-sheet__backdrop{position:fixed;inset:0;left:0;bottom:0;right:0;z-index:-1;background-color:rgba(0,0,0,var(--backdrop-opacity,.5));opacity:0;transition:opacity 225ms cubic-bezier(.4,0,.2,1);pointer-events:none}.bottom-sheet__backdrop--visible{animation:fade-in .3s forwards}.bottom-sheet__backdrop--hidden{animation:fade-out .3s forwards}.bottom-sheet__box{position:absolute;left:0;right:0;bottom:0;will-change:transform;border-top-left-radius:var(--slide-border-top-left-radius,0);border-top-right-radius:var(--slide-border-top-right-radius,0);background-color:transparent;transition:opacity .3s ease,transform .3s ease;transform:translate3d(0,120%,0);pointer-events:all}.bottom-sheet__box-wrapper{position:absolute;inset:0;pointer-events:none}.bottom-sheet__box-wrapper.bottom-sheet__box-wrapper--desktop-mode{position:absolute;bottom:0;left:50%;transform:translate3d(-50%,0,0)}.bottom-sheet__box.bottom-sheet__box--open{opacity:1;transform:translate3d(0,0,0)}.bottom-sheet__backdrop.bottom-sheet__backdrop--open{opacity:1;pointer-events:all}.bottom-sheet__header .close-strip-btn{margin-top:8px;width:32px;height:4px;background-color:#00000080;border-radius:var(--close-strip-btn-border-radius);position:absolute;z-index:10000;left:50%;transform:translate3d(-50%,0,0)}`;
26921
+ const bottomSheetStyles = (0,external_lit_namespaceObject.css) `.bottom-sheet{position:fixed;inset:0;left:0;bottom:0;right:0;z-index:999}.bottom-sheet__backdrop{position:fixed;inset:0;left:0;bottom:0;right:0;z-index:-1;background-color:rgba(0,0,0,var(--backdrop-opacity,.5));opacity:0;transition:opacity 225ms cubic-bezier(.4,0,.2,1);pointer-events:none}.bottom-sheet__backdrop--visible{animation:fade-in .3s forwards}.bottom-sheet__backdrop--hidden{animation:fade-out .3s forwards}.bottom-sheet__box{position:absolute;left:0;right:0;bottom:0;will-change:transform;border-top-left-radius:var(--slide-border-top-left-radius,0);border-top-right-radius:var(--slide-border-top-right-radius,0);background-color:transparent;transition:opacity .3s ease,transform .3s ease;transform:translate3d(0,120%,0);pointer-events:all;overflow:hidden}.bottom-sheet__box-wrapper{position:absolute;inset:0;pointer-events:none}.bottom-sheet__box-wrapper.bottom-sheet__box-wrapper--desktop-mode{position:absolute;bottom:0;left:50%;transform:translate3d(-50%,0,0)}.bottom-sheet__box.bottom-sheet__box--open{opacity:1;transform:translate3d(0,0,0)}.bottom-sheet__backdrop.bottom-sheet__backdrop--open{opacity:1;pointer-events:all}.bottom-sheet__header .close-strip-btn{margin-top:8px;width:32px;height:4px;background-color:#00000080;border-radius:var(--close-strip-btn-border-radius);position:absolute;z-index:10000;left:50%;transform:translate3d(-50%,0,0)}`;
26376
26922
 
26377
26923
  ;// CONCATENATED MODULE: external "lit/directives/style-map.js"
26378
26924
  var style_map_js_x = (y) => {
@@ -28088,7 +28634,7 @@ const IASContainer = (0,external_mobx_react_lite_namespaceObject.observer)((prop
28088
28634
  const gameReader = useGameReaderViewModel({ storyManager: storyManager });
28089
28635
  (0,external_react_namespaceObject.useEffect)(() => {
28090
28636
  if (iasContainerMounted)
28091
- throw new Error("There can only be one instance of <IASContainer /> per application");
28637
+ throw new Error("[IAS]: There can only be one instance of <IASContainer /> per application");
28092
28638
  iasContainerMounted = true;
28093
28639
  return () => {
28094
28640
  iasContainerMounted = false;