@fluid-topics/public-api 1.0.55 → 1.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarnrc +1 -0
- package/build/cjs/index.js +31 -11
- package/build/cjs/types/ft-common/public.js +11 -2
- package/build/mjs/index.d.ts +7 -2
- package/build/mjs/index.js +30 -9
- package/build/mjs/types/ft-common/public.d.ts +8 -0
- package/build/mjs/types/ft-common/public.js +8 -0
- package/build/rollup/fluidtopics.min.js +1 -1
- package/dist/cjs/index.js +31 -11
- package/dist/cjs/types/ft-common/public.js +11 -2
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +7 -2
- package/dist/mjs/index.js +30 -9
- package/dist/mjs/types/ft-common/public.d.ts +8 -0
- package/dist/mjs/types/ft-common/public.js +8 -0
- package/package.json +1 -1
package/.yarnrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--frozen-lockfile false
|
package/build/cjs/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.FluidTopicsApi = exports.HttpError = void 0;
|
|
26
|
+
exports.FluidTopicsApi = exports.HttpErrorEvent = exports.HttpError = void 0;
|
|
27
27
|
require("cross-fetch/polyfill");
|
|
28
28
|
const wnd = (typeof window === "undefined" ? globalThis : window);
|
|
29
29
|
__exportStar(require("./types/ft-common/public"), exports);
|
|
@@ -34,18 +34,36 @@ function toBase64(s) {
|
|
|
34
34
|
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
35
35
|
}
|
|
36
36
|
class HttpError extends Error {
|
|
37
|
-
constructor(status, statusText, body) {
|
|
38
|
-
super(`${status} - ${statusText}: ${body}`);
|
|
37
|
+
constructor(method, endpoint, status, statusText, body) {
|
|
38
|
+
super(`${method} ${endpoint} -> ${status} - ${statusText}: ${body}`);
|
|
39
|
+
this.method = method;
|
|
40
|
+
this.endpoint = endpoint;
|
|
39
41
|
this.status = status;
|
|
40
42
|
this.statusText = statusText;
|
|
41
43
|
this.body = body;
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
exports.HttpError = HttpError;
|
|
45
|
-
|
|
47
|
+
class HttpErrorEvent extends CustomEvent {
|
|
48
|
+
constructor(e) {
|
|
49
|
+
super("ft-api-http-error", { detail: e });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.HttpErrorEvent = HttpErrorEvent;
|
|
53
|
+
function handleError(method, endpoint, response) {
|
|
46
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
55
|
if (!response.ok) {
|
|
48
|
-
|
|
56
|
+
let details = {
|
|
57
|
+
method,
|
|
58
|
+
endpoint,
|
|
59
|
+
status: response.status,
|
|
60
|
+
statusText: response.statusText,
|
|
61
|
+
body: yield response.text()
|
|
62
|
+
};
|
|
63
|
+
if (typeof wnd.dispatchEvent === "function") {
|
|
64
|
+
wnd.dispatchEvent(new HttpErrorEvent(details));
|
|
65
|
+
}
|
|
66
|
+
throw new HttpError(details.method, details.endpoint, details.status, details.statusText, details.body);
|
|
49
67
|
}
|
|
50
68
|
return response;
|
|
51
69
|
});
|
|
@@ -58,7 +76,7 @@ class FluidTopicsApi {
|
|
|
58
76
|
return Object.assign(Object.assign(Object.assign({}, this.authorization), this.searchLabel), { "Ft-Calling-App": this.ftCallingApp });
|
|
59
77
|
}
|
|
60
78
|
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
61
|
-
var _a, _b
|
|
79
|
+
var _a, _b;
|
|
62
80
|
this.endpoints = {
|
|
63
81
|
authentication: {
|
|
64
82
|
login: `api/authentication/login`,
|
|
@@ -156,7 +174,7 @@ class FluidTopicsApi {
|
|
|
156
174
|
},
|
|
157
175
|
};
|
|
158
176
|
//@ts-ignore
|
|
159
|
-
tenantBaseUrl = ((
|
|
177
|
+
tenantBaseUrl = ((_b = (_a = tenantBaseUrl !== null && tenantBaseUrl !== void 0 ? tenantBaseUrl : wnd.fluidTopicsBaseUrl) !== null && _a !== void 0 ? _a : wnd.__gwt_ft_moduleBase) !== null && _b !== void 0 ? _b : "").trim();
|
|
160
178
|
this.tenantBaseUrl = tenantBaseUrl.endsWith("/") ? tenantBaseUrl : tenantBaseUrl + "/";
|
|
161
179
|
if (overrideIdentifierIfOnTenant && typeof wnd.location !== "undefined" && wnd.location.href.startsWith(this.tenantBaseUrl)) {
|
|
162
180
|
this.ftCallingApp = integrationIdentifier;
|
|
@@ -335,7 +353,7 @@ class FluidTopicsApi {
|
|
|
335
353
|
resolve(data);
|
|
336
354
|
}
|
|
337
355
|
else {
|
|
338
|
-
reject(new HttpError(xhr.status, xhr.statusText, xhr.responseText));
|
|
356
|
+
reject(new HttpError("GET", endpoint, xhr.status, xhr.statusText, xhr.responseText));
|
|
339
357
|
}
|
|
340
358
|
};
|
|
341
359
|
xhr.upload.onprogress = (e) => onProgress(e);
|
|
@@ -344,7 +362,9 @@ class FluidTopicsApi {
|
|
|
344
362
|
});
|
|
345
363
|
}
|
|
346
364
|
else {
|
|
347
|
-
return this.fetch(endpoint, { method, body })
|
|
365
|
+
return this.fetch(endpoint, { method, body })
|
|
366
|
+
.then((r) => handleError(method, endpoint, r))
|
|
367
|
+
.then(getBody);
|
|
348
368
|
}
|
|
349
369
|
}
|
|
350
370
|
makeRequest(method, endpoint, data) {
|
|
@@ -354,7 +374,7 @@ class FluidTopicsApi {
|
|
|
354
374
|
body: data != null ? JSON.stringify(data) : undefined,
|
|
355
375
|
credentials: this.authorization == null ? "include" : undefined
|
|
356
376
|
})
|
|
357
|
-
.then(handleError)
|
|
377
|
+
.then((r) => handleError(method, endpoint, r))
|
|
358
378
|
.then(getBody);
|
|
359
379
|
}
|
|
360
380
|
fetchRawData(endpoint, v) {
|
|
@@ -362,7 +382,7 @@ class FluidTopicsApi {
|
|
|
362
382
|
headers: this.defaultHeaders,
|
|
363
383
|
credentials: this.authorization == null ? "include" : undefined
|
|
364
384
|
})
|
|
365
|
-
.then(handleError)
|
|
385
|
+
.then((r) => handleError("GET", endpoint, r))
|
|
366
386
|
.then(response => response.arrayBuffer());
|
|
367
387
|
}
|
|
368
388
|
withVersion(endpoint, v) {
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.isFtUserProfile = exports.isFtSession = exports.isFtSearchPreferences = exports.isFtAuthenticatedSession = exports.isFtAuthenticationIdentifier = exports.isFtUserRole = exports.FtUserRole = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = exports.isFtSearchFacetConf = exports.isFtSearchFacet = exports.isFtSearchScope = exports.FtSearchScope = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtSearchResultTopic = exports.isFtSearchResultMap = exports.isFtSearchResultUnstructuredDocument = exports.isFtSearchResultClusterEntry = exports.isFtSearchResultCluster = exports.isFtSearchRequest = exports.isFtSearchPrior = exports.isFtLabeledSearchFilter = exports.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtVirtualField = exports.FtVirtualField = exports.isFtSearchSortCriterionType = exports.FtSearchSortCriterionType = exports.isFtSearchSortCriterionOrder = exports.FtSearchSortCriterionOrder = exports.isFtSearchPreset = exports.isFtSearchFilter = void 0;
|
|
3
|
+
exports.FtPeriodFilterType = exports.isFtPeriodFilter = exports.isFtPeriod = exports.isFtSearchPreferencesConfiguration = exports.isFtMetadataPreferenceConfiguration = exports.isFtMapResource = exports.isFtTopicsRatingSummary = exports.isFtTopicRating = exports.isFtRatingSummary = exports.isFtRatingCreation = exports.isFtPublicationRatingSummary = exports.isFtPublicationRating = exports.isFtRatingType = exports.FtRatingType = exports.isFtMySearchRequest = exports.isFtMySearch = exports.isFtMetadataDescriptor = exports.isFtMetadataConfiguration = exports.isFtMetadataSortRule = exports.FtMetadataSortRule = exports.isFtMetadata = exports.isFtFacetType = exports.FtFacetType = exports.isFtUiLocale = exports.isFtMessageContext = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtMetadataHomeLayout = exports.FtMetadataHomeLayout = exports.isFtFeedbackCreation = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopicOrigin = exports.isFtTopic = exports.isFtTocNode = exports.isFtMapStyles = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtBookmark = exports.isFtPersonalBookTopicLinkCreation = exports.isFtPersonalBookNodeCreation = exports.isFtPersonalBookMetadataUpdate = exports.isFtPersonalBookCreation = exports.isFtCredentials = exports.isFtTopicOriginType = exports.FtTopicOriginType = exports.isFtMyLibraryColors = exports.FtMyLibraryColors = exports.isFtHttpErrorDetails = void 0;
|
|
4
|
+
exports.isFtUserProfile = exports.isFtSession = exports.isFtSearchPreferences = exports.isFtAuthenticatedSession = exports.isFtAuthenticationIdentifier = exports.isFtUserRole = exports.FtUserRole = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = exports.isFtSearchFacetConf = exports.isFtSearchFacet = exports.isFtSearchScope = exports.FtSearchScope = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtSearchResultTopic = exports.isFtSearchResultMap = exports.isFtSearchResultUnstructuredDocument = exports.isFtSearchResultClusterEntry = exports.isFtSearchResultCluster = exports.isFtSearchRequest = exports.isFtSearchPrior = exports.isFtLabeledSearchFilter = exports.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtVirtualField = exports.FtVirtualField = exports.isFtSearchSortCriterionType = exports.FtSearchSortCriterionType = exports.isFtSearchSortCriterionOrder = exports.FtSearchSortCriterionOrder = exports.isFtSearchPreset = exports.isFtSearchFilter = exports.isFtPeriodFilterType = void 0;
|
|
5
5
|
const isObject = (o) => typeof o === "object" && o != null;
|
|
6
6
|
const isBoolean = (o) => typeof o === "boolean";
|
|
7
7
|
const isNumber = (o) => typeof o === "number";
|
|
8
8
|
const isString = (o) => typeof o === "string";
|
|
9
|
+
const isFtHttpErrorDetails = (o) => {
|
|
10
|
+
return isObject(o)
|
|
11
|
+
&& (isString(o.endpoint))
|
|
12
|
+
&& (isString(o.method))
|
|
13
|
+
&& (isString(o.statusText))
|
|
14
|
+
&& (isString(o.body))
|
|
15
|
+
&& (isNumber(o.status));
|
|
16
|
+
};
|
|
17
|
+
exports.isFtHttpErrorDetails = isFtHttpErrorDetails;
|
|
9
18
|
// From: MyLibraryColors
|
|
10
19
|
var FtMyLibraryColors;
|
|
11
20
|
(function (FtMyLibraryColors) {
|
package/build/mjs/index.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import "cross-fetch/polyfill";
|
|
2
|
-
import { FtAuthenticatedSession, FtBookmark, FtCollectionDocument, FtMap, FtMapResource, FtMessageContext, FtMetadataConfiguration, FtMySearch, FtRatingSummary, FtRatingType, FtRatingTypeKeys, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSession, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUiLocale, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
2
|
+
import { FtAuthenticatedSession, FtBookmark, FtCollectionDocument, FtHttpErrorDetails, FtMap, FtMapResource, FtMessageContext, FtMetadataConfiguration, FtMySearch, FtRatingSummary, FtRatingType, FtRatingTypeKeys, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSession, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUiLocale, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
3
3
|
import { FtMapAttachment, FtPaginatedToc, FtReaderConfiguration } from "./types/ft-server/public";
|
|
4
4
|
export * from "./types/ft-common/public";
|
|
5
5
|
export * from "./types/ft-server/public";
|
|
6
6
|
export * from "./roles/roles";
|
|
7
7
|
export * from "./preferences/unauthenticated-preferences";
|
|
8
8
|
export declare class HttpError extends Error {
|
|
9
|
+
readonly method: string;
|
|
10
|
+
readonly endpoint: string;
|
|
9
11
|
readonly status: number;
|
|
10
12
|
readonly statusText: string;
|
|
11
13
|
readonly body: string;
|
|
12
|
-
constructor(status: number, statusText: string, body: string);
|
|
14
|
+
constructor(method: string, endpoint: string, status: number, statusText: string, body: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class HttpErrorEvent extends CustomEvent<FtHttpErrorDetails> {
|
|
17
|
+
constructor(e: FtHttpErrorDetails);
|
|
13
18
|
}
|
|
14
19
|
export declare class FluidTopicsApi {
|
|
15
20
|
readonly tenantBaseUrl: string;
|
package/build/mjs/index.js
CHANGED
|
@@ -8,19 +8,38 @@ function toBase64(s) {
|
|
|
8
8
|
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
9
9
|
}
|
|
10
10
|
export class HttpError extends Error {
|
|
11
|
+
method;
|
|
12
|
+
endpoint;
|
|
11
13
|
status;
|
|
12
14
|
statusText;
|
|
13
15
|
body;
|
|
14
|
-
constructor(status, statusText, body) {
|
|
15
|
-
super(`${status} - ${statusText}: ${body}`);
|
|
16
|
+
constructor(method, endpoint, status, statusText, body) {
|
|
17
|
+
super(`${method} ${endpoint} -> ${status} - ${statusText}: ${body}`);
|
|
18
|
+
this.method = method;
|
|
19
|
+
this.endpoint = endpoint;
|
|
16
20
|
this.status = status;
|
|
17
21
|
this.statusText = statusText;
|
|
18
22
|
this.body = body;
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
|
|
25
|
+
export class HttpErrorEvent extends CustomEvent {
|
|
26
|
+
constructor(e) {
|
|
27
|
+
super("ft-api-http-error", { detail: e });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function handleError(method, endpoint, response) {
|
|
22
31
|
if (!response.ok) {
|
|
23
|
-
|
|
32
|
+
let details = {
|
|
33
|
+
method,
|
|
34
|
+
endpoint,
|
|
35
|
+
status: response.status,
|
|
36
|
+
statusText: response.statusText,
|
|
37
|
+
body: await response.text()
|
|
38
|
+
};
|
|
39
|
+
if (typeof wnd.dispatchEvent === "function") {
|
|
40
|
+
wnd.dispatchEvent(new HttpErrorEvent(details));
|
|
41
|
+
}
|
|
42
|
+
throw new HttpError(details.method, details.endpoint, details.status, details.statusText, details.body);
|
|
24
43
|
}
|
|
25
44
|
return response;
|
|
26
45
|
}
|
|
@@ -137,7 +156,7 @@ export class FluidTopicsApi {
|
|
|
137
156
|
}
|
|
138
157
|
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
139
158
|
//@ts-ignore
|
|
140
|
-
tenantBaseUrl = (tenantBaseUrl ?? wnd.
|
|
159
|
+
tenantBaseUrl = (tenantBaseUrl ?? wnd.fluidTopicsBaseUrl ?? wnd.__gwt_ft_moduleBase ?? "").trim();
|
|
141
160
|
this.tenantBaseUrl = tenantBaseUrl.endsWith("/") ? tenantBaseUrl : tenantBaseUrl + "/";
|
|
142
161
|
if (overrideIdentifierIfOnTenant && typeof wnd.location !== "undefined" && wnd.location.href.startsWith(this.tenantBaseUrl)) {
|
|
143
162
|
this.ftCallingApp = integrationIdentifier;
|
|
@@ -319,7 +338,7 @@ export class FluidTopicsApi {
|
|
|
319
338
|
resolve(data);
|
|
320
339
|
}
|
|
321
340
|
else {
|
|
322
|
-
reject(new HttpError(xhr.status, xhr.statusText, xhr.responseText));
|
|
341
|
+
reject(new HttpError("GET", endpoint, xhr.status, xhr.statusText, xhr.responseText));
|
|
323
342
|
}
|
|
324
343
|
};
|
|
325
344
|
xhr.upload.onprogress = (e) => onProgress(e);
|
|
@@ -328,7 +347,9 @@ export class FluidTopicsApi {
|
|
|
328
347
|
});
|
|
329
348
|
}
|
|
330
349
|
else {
|
|
331
|
-
return this.fetch(endpoint, { method, body })
|
|
350
|
+
return this.fetch(endpoint, { method, body })
|
|
351
|
+
.then((r) => handleError(method, endpoint, r))
|
|
352
|
+
.then(getBody);
|
|
332
353
|
}
|
|
333
354
|
}
|
|
334
355
|
makeRequest(method, endpoint, data) {
|
|
@@ -340,7 +361,7 @@ export class FluidTopicsApi {
|
|
|
340
361
|
body: data != null ? JSON.stringify(data) : undefined,
|
|
341
362
|
credentials: this.authorization == null ? "include" : undefined
|
|
342
363
|
})
|
|
343
|
-
.then(handleError)
|
|
364
|
+
.then((r) => handleError(method, endpoint, r))
|
|
344
365
|
.then(getBody);
|
|
345
366
|
}
|
|
346
367
|
fetchRawData(endpoint, v) {
|
|
@@ -348,7 +369,7 @@ export class FluidTopicsApi {
|
|
|
348
369
|
headers: this.defaultHeaders,
|
|
349
370
|
credentials: this.authorization == null ? "include" : undefined
|
|
350
371
|
})
|
|
351
|
-
.then(handleError)
|
|
372
|
+
.then((r) => handleError("GET", endpoint, r))
|
|
352
373
|
.then(response => response.arrayBuffer());
|
|
353
374
|
}
|
|
354
375
|
withVersion(endpoint, v) {
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export interface FtHttpErrorDetails {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
method: string;
|
|
4
|
+
statusText: string;
|
|
5
|
+
body: string;
|
|
6
|
+
status: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const isFtHttpErrorDetails: (o: any) => o is FtHttpErrorDetails;
|
|
1
9
|
export declare enum FtMyLibraryColors {
|
|
2
10
|
black = "black",
|
|
3
11
|
green = "green",
|
|
@@ -2,6 +2,14 @@ const isObject = (o) => typeof o === "object" && o != null;
|
|
|
2
2
|
const isBoolean = (o) => typeof o === "boolean";
|
|
3
3
|
const isNumber = (o) => typeof o === "number";
|
|
4
4
|
const isString = (o) => typeof o === "string";
|
|
5
|
+
export const isFtHttpErrorDetails = (o) => {
|
|
6
|
+
return isObject(o)
|
|
7
|
+
&& (isString(o.endpoint))
|
|
8
|
+
&& (isString(o.method))
|
|
9
|
+
&& (isString(o.statusText))
|
|
10
|
+
&& (isString(o.body))
|
|
11
|
+
&& (isNumber(o.status));
|
|
12
|
+
};
|
|
5
13
|
// From: MyLibraryColors
|
|
6
14
|
export var FtMyLibraryColors;
|
|
7
15
|
(function (FtMyLibraryColors) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function n(e){return"string"!=typeof e&&(e=String(e)),e}function o(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function u(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function d(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||a(e))?this._bodyArrayBuffer=p(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,i=u(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=n(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=n(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),o(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),o(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),o(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function f(e,t){var r,i,a=(t=t||{}).body;if(e instanceof f){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,a||null==e._bodyInit||(a=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),y.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(a)}function A(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),a=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(a))}})),t}function m(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}f.prototype.clone=function(){return new f(this,{body:this._bodyInit})},h.call(f.prototype),h.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},m.error=function(){var e=new m(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];m.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new m(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function g(e,i){return new Promise((function(a,s){var n=new f(e,i);if(n.signal&&n.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),i=r.shift().trim();if(i){var a=r.join(":").trim();t.append(i,a)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;a(new m(i,r))},o.onerror=function(){s(new TypeError("Network request failed"))},o.ontimeout=function(){s(new TypeError("Network request failed"))},o.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},o.open(n.method,n.url,!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),n.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),n.signal&&(n.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",u)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}g.polyfill=!0,e.fetch||(e.fetch=g,e.Headers=l,e.Request=f,e.Response=m),t.Headers=l,t.Request=f,t.Response=m,t.fetch=g,Object.defineProperty(t,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:t);const r=e=>"object"==typeof e&&null!=e,i=e=>"boolean"==typeof e,a=e=>"number"==typeof e,s=e=>"string"==typeof e;var n;e.FtMyLibraryColors=void 0,(n=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",n.green="green",n.blue="blue",n.purple="purple",n.red="red",n.orange="orange",n.yellow="yellow";const o=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var l;e.FtTopicOriginType=void 0,(l=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",l.PERSONAL="PERSONAL",l.SHARED="SHARED";const u=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),c=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>s(e)))))&&s(e.key),d=e=>r(e)&&s(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>d(e)))&&(null==e.topicLink||p(e.topicLink))&&s(e.title)&&(null==e.htmlContent||s(e.htmlContent)),p=e=>r(e)&&s(e.tocId)&&s(e.contentId)&&s(e.mapId),h=e=>r(e)&&s(e.topicStylesheetUrl)&&s(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>s(e))),y=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&(null==e.hasRating||i(e.hasRating))&&s(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>y(e)))&&(null==e.origin||f(e.origin))&&s(e.contentId)&&s(e.title),f=e=>r(e)&&s(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.contentId)&&s(e.mapId)&&u(e.type);var A;e.FtTopicContentTarget=void 0,(A=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",A.OFF_THE_GRID="OFF_THE_GRID",A.CONTENT_PACKAGER="CONTENT_PACKAGER",A.PAGES="PAGES",A.DESIGNED_READER="DESIGNED_READER";var m;e.FtMetadataHomeLayout=void 0,(m=e.FtMetadataHomeLayout||(e.FtMetadataHomeLayout={})).CLASSIC="CLASSIC",m.CUSTOM="CUSTOM",m.DESIGNER="DESIGNER";const E=e=>r(e)&&a(e.count)&&s(e.label)&&(null==e.lang||s(e.lang));var g;e.FtFacetType=void 0,(g=e.FtFacetType||(e.FtFacetType={})).AND="AND",g.OR="OR",g.MONOVALUED="MONOVALUED";const S=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>s(e))))))&&s(e.label)&&s(e.key);var b;e.FtMetadataSortRule=void 0,(b=e.FtMetadataSortRule||(e.FtMetadataSortRule={})).NONE="NONE",b.ALPHABET="ALPHABET",b.VERSION="VERSION";const T=e=>["NONE","ALPHABET","VERSION"].includes(e),R=e=>r(e)&&T(e.sortRule)&&i(e.reverseSort)&&s(e.key),F=e=>r(e)&&(null==e.periodFilter||P(e.periodFilter))&&s(e.query)&&(null==e.scope||oe(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>J(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.virtualField||K(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale));var O;e.FtRatingType=void 0,(O=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",O.LIKE="LIKE",O.DICHOTOMOUS="DICHOTOMOUS",O.NO_RATING="NO_RATING";const U=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),I=e=>r(e)&&s(e.date)&&U(e.type)&&a(e.value),v=e=>r(e)&&(null==e.rating||I(e.rating))&&U(e.type),_=e=>r(e)&&s(e.date)&&s(e.tocId)&&U(e.type)&&a(e.value),C=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>_(e)))&&U(e.type),L=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>s(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>s(e))),D=e=>r(e)&&s(e.from)&&s(e.to),P=e=>r(e)&&(null==e.period||D(e.period))&&M(e.periodType);var N;e.FtPeriodFilterType=void 0,(N=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",N.LAST_MONTH="LAST_MONTH",N.LAST_YEAR="LAST_YEAR",N.CUSTOM="CUSTOM";const M=e=>["LAST_WEEK","LAST_MONTH","LAST_YEAR","CUSTOM"].includes(e),k=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.key);var w;e.FtSearchSortCriterionOrder=void 0,(w=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",w.DESC="DESC";const B=e=>["ASC","DESC"].includes(e);var H;e.FtSearchSortCriterionType=void 0,(H=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",H.NATURAL="NATURAL";const x=e=>["ALPHA","NATURAL"].includes(e);var V;e.FtVirtualField=void 0,(V=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",V.TITLE_ONLY="TITLE_ONLY",V.NONE="NONE";const K=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),$=e=>r(e)&&a(e.totalResultsCount)&&i(e.isLastPage)&&a(e.currentPage)&&a(e.totalClustersCount);var j;e.FtEditorialType=void 0,(j=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",j.BOOK="BOOK",j.SHARED_BOOK="SHARED_BOOK";const G=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var q;e.FtOpenMode=void 0,(q=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",q.EXTERNAL="EXTERNAL";const X=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),Y=e=>r(e)&&(null==e.perPage||a(e.perPage))&&a(e.page);var z;e.FtCollectionDocumentType=void 0,(z=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",z.DOCUMENT="DOCUMENT",z.TOPIC="TOPIC",z.PERSONAL_BOOK="PERSONAL_BOOK",z.SHARED_BOOK="SHARED_BOOK";const W=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),J=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.label)&&s(e.key),Q=e=>r(e)&&a(e.weight)&&s(e.value)&&s(e.key),Z=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>ee(e)))&&(null==e.metadataVariableAxis||s(e.metadataVariableAxis)),ee=e=>r(e)&&(null==e.document||te(e.document))&&(null==e.topic||ie(e.topic))&&se(e.type)&&(null==e.map||re(e.map)),te=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&X(e.openMode)&&s(e.documentUrl)&&s(e.mimeType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.viewerUrl)&&s(e.contentUrl)&&s(e.filename)&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.documentId)&&s(e.lastEditionDate)&&s(e.htmlExcerpt),re=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&(null==e.openMode||X(e.openMode))&&G(e.editorialType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.mapUrl)&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt),ie=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&X(e.openMode)&&s(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>he(e)))&&s(e.title)&&s(e.mapTitle)&&s(e.topicUrl)&&s(e.contentUrl)&&s(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&(null==e.originUrl||s(e.originUrl))&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt);var ae;e.FtSearchResultType=void 0,(ae=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",ae.DOCUMENT="DOCUMENT",ae.TOPIC="TOPIC";const se=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var ne;e.FtSearchScope=void 0,(ne=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",ne.DOCUMENTS="DOCUMENTS",ne.ALL_TOPICS="ALL_TOPICS";const oe=e=>["DEFAULT","DOCUMENTS","ALL_TOPICS"].includes(e),le=e=>r(e)&&i(e.hierarchical)&&s(e.label)&&i(e.multiSelectionable)&&s(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>ce(e))),ue=e=>r(e)&&(null==e.maxDepth||a(e.maxDepth))&&s(e.id),ce=e=>r(e)&&a(e.totalResultsCount)&&i(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>ce(e)))&&s(e.label)&&s(e.value)&&i(e.selected),de=e=>r(e)&&x(e.type)&&s(e.key)&&B(e.order),pe=e=>r(e)&&s(e.suggestedQuery)&&s(e.htmlSuggestedQuery),he=e=>r(e)&&s(e.filename)&&s(e.resourceUrl)&&s(e.id)&&s(e.mimeType)&&s(e.resourceContentUrl)&&s(e.viewerUrl),ye=e=>r(e)&&(null==e.filenameExtension||s(e.filenameExtension))&&(null==e.editorialType||G(e.editorialType))&&(null==e.mimeType||s(e.mimeType))&&se(e.type)&&s(e.value);var fe;e.FtUserRole=void 0,(fe=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",fe.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",fe.HTML_EXPORT_USER="HTML_EXPORT_USER",fe.PDF_EXPORT_USER="PDF_EXPORT_USER",fe.SAVED_SEARCH_USER="SAVED_SEARCH_USER",fe.COLLECTION_USER="COLLECTION_USER",fe.OFFLINE_USER="OFFLINE_USER",fe.ANALYTICS_USER="ANALYTICS_USER",fe.BETA_USER="BETA_USER",fe.DEBUG_USER="DEBUG_USER",fe.PRINT_USER="PRINT_USER",fe.RATING_USER="RATING_USER",fe.FEEDBACK_USER="FEEDBACK_USER",fe.CONTENT_PUBLISHER="CONTENT_PUBLISHER",fe.KHUB_ADMIN="KHUB_ADMIN",fe.USERS_ADMIN="USERS_ADMIN",fe.PORTAL_ADMIN="PORTAL_ADMIN",fe.ADMIN="ADMIN",fe.DEVELOPER="DEVELOPER";const Ae=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),me=e=>r(e)&&s(e.identifier)&&s(e.realm),Ee=e=>r(e)&&Array.isArray(e.defaultFilters)&&e.defaultFilters.every((e=>k(e))),ge=e=>r(e)&&(null==e.emailAddress||s(e.emailAddress))&&(null==e.displayName||s(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>Ae(e)))&&(null==e.userId||s(e.userId)),Se=e=>"object"==typeof e&&null!=e,be=e=>"boolean"==typeof e,Te=e=>"number"==typeof e,Re=e=>"string"==typeof e;var Fe;e.FtConfigurationHistoryEntryStatus=void 0,(Fe=e.FtConfigurationHistoryEntryStatus||(e.FtConfigurationHistoryEntryStatus={})).VALID="VALID",Fe.INVALID="INVALID";const Oe=e=>Se(e)&&be(e.mailsSentByFluidTopics)&&be(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>Re(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>Re(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>Re(e))),Ue=e=>Se(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>be(e))))&&be(e.isVisible),Ie=e=>Se(e)&&(null==e.prettyUrl||Re(e.prettyUrl))&&(null==e.hasRating||be(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||Re(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>Ie(e)))&&(null==e.pageConfiguration||Ue(e.pageConfiguration))&&(null==e.contentId||Re(e.contentId))&&(null==e.title||Re(e.title)),ve=e=>Se(e)&&be(e.splitCurrentPageToc),_e={[e.FtUserRole.PERSONAL_BOOK_SHARE_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.HTML_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.PDF_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.KHUB_ADMIN]:[e.FtUserRole.CONTENT_PUBLISHER],[e.FtUserRole.ADMIN]:[e.FtUserRole.KHUB_ADMIN,e.FtUserRole.USERS_ADMIN,e.FtUserRole.PORTAL_ADMIN],[e.FtUserRole.DEVELOPER]:[e.FtUserRole.BETA_USER,e.FtUserRole.DEBUG_USER]};function Ce(e,t){return e===t||(_e[e]??[]).some((e=>Ce(e,t)))}const Le="undefined"==typeof window?globalThis:window;function De(e){let t={};for(let r in e){let i=e[r];("object"!=typeof i||Array.isArray(i))&&(i={prior:i});for(let e of["prior","filter"])i[e]=Array.isArray(i[e])?i[e]:[i[e]],i[e]=i[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=i}return t}function Pe(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const Ne="undefined"==typeof window?globalThis:window;class Me extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function ke(e){if(!e.ok)throw new Me(e.status,e.statusText,await e.text());return e}function we(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class Be{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})},searches:{list:`api/users/${e}/searches`},bookmarks:{list:`api/users/${e}/bookmarks`}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader",metadata:"api/configuration/metadata"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??Ne.__gwt_ft_moduleBase??Ne.fluidtopicsclient?.__moduleBase??Ne.__gwt_activeModules?.fluidtopicsclient?.moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",r&&void 0!==Ne.location&&Ne.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e,t){return this.get(this.endpoints.khub.maps.mapId(e).info,t)}getTableOfContent(e,t){return this.get(this.endpoints.khub.maps.mapId(e).toc,t)}getPages(e,t){return this.get(this.endpoints.khub.maps.mapId(e).pages,t)}getTopic(e,t,r){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info,r)}getTopicHTMLContent(e,t,r,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(r?"?target="+r:""),i)}getMapAttachments(e,t){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list,t)}getMapAttachmentContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content,r)}getMapResources(e,t){return this.get(this.endpoints.khub.maps.mapId(e).resources.list,t)}getMapResourceContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content,r)}getUnstructuredDocument(e,t){return this.get(this.endpoints.khub.documents.documentId(e).info,t)}getUnstructuredDocumentContent(e,t){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content,t)}getUnstructuredDocumentTextContent(e,t){return this.get(this.endpoints.khub.documents.documentId(e).text,t)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.khub.locales)}getMetadataConfiguration(){return this.get(this.endpoints.configuration.metadata)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:r})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t,from:r})}rateTopic(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:i})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:r})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t,from:r})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}getCustomMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).custom.contextName(t).endpoint)}listMySearches(e){return this.get(this.endpoints.users.userId(e).searches.list)}listMyBookmarks(e){return this.get(this.endpoints.users.userId(e).bookmarks.list)}get(e,t){return this.makeRequest("GET",this.withVersion(e,t))}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return e.startsWith(this.tenantBaseUrl)?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await fetch(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,i=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,s)=>{let n=new XMLHttpRequest;n.onload=()=>{if(n.status>=200&&n.status<300){let e="application/json"===n.getResponseHeader("Content-Type")?JSON.parse(n.responseText):n.responseText;a(e)}else s(new Me(n.status,n.statusText,n.responseText))},n.upload.onprogress=e=>i(e),n.open(e,this.makeAbsolute(t),!0),n.send(r)})):this.fetch(t,{method:e,body:r}).then(ke).then(we)}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0,credentials:null==this.authorization?"include":void 0}).then(ke).then(we)}fetchRawData(e,t){return fetch(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then(ke).then((e=>e.arrayBuffer()))}withVersion(e,t){let r=new URL(this.makeAbsolute(e));return t&&r.searchParams.append("v",t),r.toString()}}e.FluidTopicsApi=Be,e.HttpError=Me,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(Le.localStorage){const r=Pe(e),i=e=>{e.storageArea===Le.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return Le.addEventListener("storage",i),{removeHandler:()=>Le.removeEventListener("storage",i)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=Be,e.getUnauthenticatedUserSearchPreferences=function(e){if(Le.localStorage)return JSON.parse(Le.localStorage.getItem(Pe(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>r(e)&&me(e.authenticationIdentifier)&&ge(e.profile),e.isFtAuthenticationIdentifier=me,e.isFtBookmark=e=>r(e)&&s(e.mapTitle)&&o(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.lastUpdate)&&s(e.readerUrl)&&s(e.mapId)&&s(e.id)&&s(e.title)&&s(e.creationDate),e.isFtCollectionDocument=e=>r(e)&&i(e.deleted)&&(null==e.apiUrl||s(e.apiUrl))&&(null==e.portalUrl||s(e.portalUrl))&&s(e.id)&&s(e.title)&&W(e.type),e.isFtCollectionDocumentType=W,e.isFtConfigurationHistoryEntryStatus=e=>["VALID","INVALID"].includes(e),e.isFtCredentials=e=>r(e)&&s(e.password)&&(null==e.newPassword||s(e.newPassword))&&i(e.rememberMe)&&s(e.login),e.isFtEditorialType=G,e.isFtFacetType=e=>["AND","OR","MONOVALUED"].includes(e),e.isFtFeedbackCreation=e=>r(e)&&(null==e.from||s(e.from))&&s(e.message),e.isFtLabeledSearchFilter=J,e.isFtMap=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&X(e.openMode)&&(null==e.topicsApiEndpoint||s(e.topicsApiEndpoint))&&(null==e.description||s(e.description))&&(null==e.attachmentsApiEndpoint||s(e.attachmentsApiEndpoint))&&G(e.editorialType)&&s(e.baseId)&&s(e.clusterId)&&s(e.title)&&s(e.lastPublication)&&s(e.lastEdition)&&s(e.originId)&&(null==e.rightsApiEndpoint||s(e.rightsApiEndpoint))&&h(e.contentStyles)&&(null==e.originUrl||s(e.originUrl))&&s(e.fingerprint)&&s(e.readerUrl)&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtMapAttachment=e=>Se(e)&&Re(e.file)&&(null==e.size||Te(e.size))&&be(e.externalLink)&&Re(e.name)&&Re(e.id)&&(null==e.mimeType||Re(e.mimeType))&&(null==e.viewerUrl||Re(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&s(e.contentUrl)&&s(e.filename)&&s(e.id)&&s(e.mimeType),e.isFtMapStyles=h,e.isFtMessageContext=e=>r(e)&&s(e.name)&&r(e.messages)&&Object.keys(e.messages).every((e=>s(e)))&&Object.values(e.messages).every((e=>s(e)))&&s(e.locale),e.isFtMetadata=S,e.isFtMetadataConfiguration=e=>r(e)&&Array.isArray(e.descriptors)&&e.descriptors.every((e=>R(e))),e.isFtMetadataDescriptor=R,e.isFtMetadataHomeLayout=e=>["CLASSIC","CUSTOM","DESIGNER"].includes(e),e.isFtMetadataPreferenceConfiguration=L,e.isFtMetadataSortRule=T,e.isFtMyLibraryColors=o,e.isFtMySearch=e=>r(e)&&F(e.searchRequest)&&o(e.color)&&i(e.alert)&&s(e.description)&&s(e.id)&&s(e.ownerId)&&s(e.title)&&s(e.creationDate),e.isFtMySearchRequest=F,e.isFtOpenMode=X,e.isFtPageConfiguration=Ue,e.isFtPageRequest=Y,e.isFtPaginatedToc=e=>Se(e)&&ve(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>Ie(e))),e.isFtPaginatedTocNode=Ie,e.isFtPaginationConfiguration=ve,e.isFtPeriod=D,e.isFtPeriodFilter=P,e.isFtPeriodFilterType=M,e.isFtPersonalBookCreation=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>c(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>d(e)))&&s(e.description)&&s(e.title),e.isFtPersonalBookMetadataUpdate=c,e.isFtPersonalBookNodeCreation=d,e.isFtPersonalBookTopicLinkCreation=p,e.isFtPublicationRating=I,e.isFtPublicationRatingSummary=v,e.isFtRatingCreation=e=>r(e)&&U(e.type)&&a(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||C(e.topics))&&v(e.publication),e.isFtRatingType=U,e.isFtReaderConfiguration=e=>Se(e)&&Oe(e.feedback)&&Te(e.loadAfterLastVisibleTopic)&&Te(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=Oe,e.isFtSearchFacet=le,e.isFtSearchFacetConf=ue,e.isFtSearchFacetEntry=ce,e.isFtSearchFilter=k,e.isFtSearchLocale=E,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>E(e))),e.isFtSearchPreferences=Ee,e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>s(e)))&&Object.values(e.metadata).every((e=>L(e))),e.isFtSearchPreset=e=>r(e)&&s(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&a(e.priority)&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSearchPrior=Q,e.isFtSearchRequest=e=>r(e)&&(null==e.periodFilter||P(e.periodFilter))&&s(e.query)&&(null==e.scope||oe(e.scope))&&Y(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.uiLocale||s(e.uiLocale))&&(null==e.virtualField||K(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>Q(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>ue(e))),e.isFtSearchResultCluster=Z,e.isFtSearchResultClusterEntry=ee,e.isFtSearchResultMap=re,e.isFtSearchResultTopic=ie,e.isFtSearchResultType=se,e.isFtSearchResultUnstructuredDocument=te,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||pe(e.spellcheck))&&$(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>Z(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>le(e))),e.isFtSearchResultsPageInfo=$,e.isFtSearchScope=oe,e.isFtSearchSortCriterion=de,e.isFtSearchSortCriterionOrder=B,e.isFtSearchSortCriterionType=x,e.isFtSession=e=>r(e)&&(null==e.authenticationIdentifier||me(e.authenticationIdentifier))&&a(e.idleTimeoutInMillis)&&ge(e.profile)&&i(e.sessionAuthenticated)&&Ee(e.searchPreferences),e.isFtSpellcheck=pe,e.isFtSuggestRequest=e=>r(e)&&s(e.input)&&(null==e.scope||oe(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.maxCount||a(e.maxCount))&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSuggestResult=ye,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>ye(e))),e.isFtTocNode=y,e.isFtTopic=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&s(e.id)&&s(e.contentApiEndpoint)&&s(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=f,e.isFtTopicOriginType=u,e.isFtTopicRating=_,e.isFtTopicResource=he,e.isFtTopicsRatingSummary=C,e.isFtUiLocale=e=>r(e)&&s(e.displayName)&&s(e.languageTag)&&i(e.translated),e.isFtUnstructuredDocument=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&s(e.openMode)&&(null==e.description||s(e.description))&&s(e.mimeType)&&(null==e.baseId||s(e.baseId))&&(null==e.clusterId||s(e.clusterId))&&s(e.contentApiEndpoint)&&s(e.title)&&(null==e.lastPublication||s(e.lastPublication))&&s(e.viewerUrl)&&s(e.lastEdition)&&s(e.filename)&&(null==e.originId||s(e.originId))&&s(e.rightsApiEndpoint)&&(null==e.originUrl||s(e.originUrl))&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtUserProfile=ge,e.isFtUserRole=Ae,e.isFtVirtualField=K,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(Le.localStorage){let r={...t,metadata:De(t.metadata??{})};const i=Pe(e),a=JSON.stringify(r);return Le.localStorage.setItem(i,a),Le.dispatchEvent(new StorageEvent("storage",{key:i,newValue:a,storageArea:Le.localStorage,url:Le.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")},e.userHasRole=function(e,t){return null!=e&&(Array.isArray(e)?e:Array.isArray(e.roles)?e.roles:Array.isArray(e.profile?.roles)?e.profile.roles:[]).some((e=>Ce(e,t)))}}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function n(e){return"string"!=typeof e&&(e=String(e)),e}function o(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function u(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function d(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||a(e))?this._bodyArrayBuffer=p(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,i=u(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=n(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=n(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),o(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),o(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),o(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function f(e,t){var r,i,a=(t=t||{}).body;if(e instanceof f){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,a||null==e._bodyInit||(a=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),y.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(a)}function A(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),a=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(a))}})),t}function m(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}f.prototype.clone=function(){return new f(this,{body:this._bodyInit})},h.call(f.prototype),h.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},m.error=function(){var e=new m(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];m.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new m(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function g(e,i){return new Promise((function(a,s){var n=new f(e,i);if(n.signal&&n.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),i=r.shift().trim();if(i){var a=r.join(":").trim();t.append(i,a)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;a(new m(i,r))},o.onerror=function(){s(new TypeError("Network request failed"))},o.ontimeout=function(){s(new TypeError("Network request failed"))},o.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},o.open(n.method,n.url,!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),n.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),n.signal&&(n.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",u)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}g.polyfill=!0,e.fetch||(e.fetch=g,e.Headers=l,e.Request=f,e.Response=m),t.Headers=l,t.Request=f,t.Response=m,t.fetch=g,Object.defineProperty(t,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:t);const r=e=>"object"==typeof e&&null!=e,i=e=>"boolean"==typeof e,a=e=>"number"==typeof e,s=e=>"string"==typeof e;var n;e.FtMyLibraryColors=void 0,(n=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",n.green="green",n.blue="blue",n.purple="purple",n.red="red",n.orange="orange",n.yellow="yellow";const o=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var l;e.FtTopicOriginType=void 0,(l=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",l.PERSONAL="PERSONAL",l.SHARED="SHARED";const u=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),c=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>s(e)))))&&s(e.key),d=e=>r(e)&&s(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>d(e)))&&(null==e.topicLink||p(e.topicLink))&&s(e.title)&&(null==e.htmlContent||s(e.htmlContent)),p=e=>r(e)&&s(e.tocId)&&s(e.contentId)&&s(e.mapId),h=e=>r(e)&&s(e.topicStylesheetUrl)&&s(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>s(e))),y=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&(null==e.hasRating||i(e.hasRating))&&s(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>y(e)))&&(null==e.origin||f(e.origin))&&s(e.contentId)&&s(e.title),f=e=>r(e)&&s(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.contentId)&&s(e.mapId)&&u(e.type);var A;e.FtTopicContentTarget=void 0,(A=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",A.OFF_THE_GRID="OFF_THE_GRID",A.CONTENT_PACKAGER="CONTENT_PACKAGER",A.PAGES="PAGES",A.DESIGNED_READER="DESIGNED_READER";var m;e.FtMetadataHomeLayout=void 0,(m=e.FtMetadataHomeLayout||(e.FtMetadataHomeLayout={})).CLASSIC="CLASSIC",m.CUSTOM="CUSTOM",m.DESIGNER="DESIGNER";const E=e=>r(e)&&a(e.count)&&s(e.label)&&(null==e.lang||s(e.lang));var g;e.FtFacetType=void 0,(g=e.FtFacetType||(e.FtFacetType={})).AND="AND",g.OR="OR",g.MONOVALUED="MONOVALUED";const b=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>s(e))))))&&s(e.label)&&s(e.key);var T;e.FtMetadataSortRule=void 0,(T=e.FtMetadataSortRule||(e.FtMetadataSortRule={})).NONE="NONE",T.ALPHABET="ALPHABET",T.VERSION="VERSION";const S=e=>["NONE","ALPHABET","VERSION"].includes(e),R=e=>r(e)&&S(e.sortRule)&&i(e.reverseSort)&&s(e.key),F=e=>r(e)&&(null==e.periodFilter||P(e.periodFilter))&&s(e.query)&&(null==e.scope||oe(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>J(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.virtualField||$(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale));var O;e.FtRatingType=void 0,(O=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",O.LIKE="LIKE",O.DICHOTOMOUS="DICHOTOMOUS",O.NO_RATING="NO_RATING";const U=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),I=e=>r(e)&&s(e.date)&&U(e.type)&&a(e.value),v=e=>r(e)&&(null==e.rating||I(e.rating))&&U(e.type),_=e=>r(e)&&s(e.date)&&s(e.tocId)&&U(e.type)&&a(e.value),C=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>_(e)))&&U(e.type),L=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>s(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>s(e))),D=e=>r(e)&&s(e.from)&&s(e.to),P=e=>r(e)&&(null==e.period||D(e.period))&&M(e.periodType);var N;e.FtPeriodFilterType=void 0,(N=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",N.LAST_MONTH="LAST_MONTH",N.LAST_YEAR="LAST_YEAR",N.CUSTOM="CUSTOM";const M=e=>["LAST_WEEK","LAST_MONTH","LAST_YEAR","CUSTOM"].includes(e),k=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.key);var w;e.FtSearchSortCriterionOrder=void 0,(w=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",w.DESC="DESC";const B=e=>["ASC","DESC"].includes(e);var H;e.FtSearchSortCriterionType=void 0,(H=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",H.NATURAL="NATURAL";const x=e=>["ALPHA","NATURAL"].includes(e);var V;e.FtVirtualField=void 0,(V=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",V.TITLE_ONLY="TITLE_ONLY",V.NONE="NONE";const $=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),K=e=>r(e)&&a(e.totalResultsCount)&&i(e.isLastPage)&&a(e.currentPage)&&a(e.totalClustersCount);var j;e.FtEditorialType=void 0,(j=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",j.BOOK="BOOK",j.SHARED_BOOK="SHARED_BOOK";const G=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var q;e.FtOpenMode=void 0,(q=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",q.EXTERNAL="EXTERNAL";const X=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),Y=e=>r(e)&&(null==e.perPage||a(e.perPage))&&a(e.page);var z;e.FtCollectionDocumentType=void 0,(z=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",z.DOCUMENT="DOCUMENT",z.TOPIC="TOPIC",z.PERSONAL_BOOK="PERSONAL_BOOK",z.SHARED_BOOK="SHARED_BOOK";const W=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),J=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.label)&&s(e.key),Q=e=>r(e)&&a(e.weight)&&s(e.value)&&s(e.key),Z=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>ee(e)))&&(null==e.metadataVariableAxis||s(e.metadataVariableAxis)),ee=e=>r(e)&&(null==e.document||te(e.document))&&(null==e.topic||ie(e.topic))&&se(e.type)&&(null==e.map||re(e.map)),te=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&X(e.openMode)&&s(e.documentUrl)&&s(e.mimeType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.viewerUrl)&&s(e.contentUrl)&&s(e.filename)&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.documentId)&&s(e.lastEditionDate)&&s(e.htmlExcerpt),re=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&(null==e.openMode||X(e.openMode))&&G(e.editorialType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.mapUrl)&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt),ie=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&X(e.openMode)&&s(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>he(e)))&&s(e.title)&&s(e.mapTitle)&&s(e.topicUrl)&&s(e.contentUrl)&&s(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&(null==e.originUrl||s(e.originUrl))&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt);var ae;e.FtSearchResultType=void 0,(ae=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",ae.DOCUMENT="DOCUMENT",ae.TOPIC="TOPIC";const se=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var ne;e.FtSearchScope=void 0,(ne=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",ne.DOCUMENTS="DOCUMENTS",ne.ALL_TOPICS="ALL_TOPICS";const oe=e=>["DEFAULT","DOCUMENTS","ALL_TOPICS"].includes(e),le=e=>r(e)&&i(e.hierarchical)&&s(e.label)&&i(e.multiSelectionable)&&s(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>ce(e))),ue=e=>r(e)&&(null==e.maxDepth||a(e.maxDepth))&&s(e.id),ce=e=>r(e)&&a(e.totalResultsCount)&&i(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>ce(e)))&&s(e.label)&&s(e.value)&&i(e.selected),de=e=>r(e)&&x(e.type)&&s(e.key)&&B(e.order),pe=e=>r(e)&&s(e.suggestedQuery)&&s(e.htmlSuggestedQuery),he=e=>r(e)&&s(e.filename)&&s(e.resourceUrl)&&s(e.id)&&s(e.mimeType)&&s(e.resourceContentUrl)&&s(e.viewerUrl),ye=e=>r(e)&&(null==e.filenameExtension||s(e.filenameExtension))&&(null==e.editorialType||G(e.editorialType))&&(null==e.mimeType||s(e.mimeType))&&se(e.type)&&s(e.value);var fe;e.FtUserRole=void 0,(fe=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",fe.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",fe.HTML_EXPORT_USER="HTML_EXPORT_USER",fe.PDF_EXPORT_USER="PDF_EXPORT_USER",fe.SAVED_SEARCH_USER="SAVED_SEARCH_USER",fe.COLLECTION_USER="COLLECTION_USER",fe.OFFLINE_USER="OFFLINE_USER",fe.ANALYTICS_USER="ANALYTICS_USER",fe.BETA_USER="BETA_USER",fe.DEBUG_USER="DEBUG_USER",fe.PRINT_USER="PRINT_USER",fe.RATING_USER="RATING_USER",fe.FEEDBACK_USER="FEEDBACK_USER",fe.CONTENT_PUBLISHER="CONTENT_PUBLISHER",fe.KHUB_ADMIN="KHUB_ADMIN",fe.USERS_ADMIN="USERS_ADMIN",fe.PORTAL_ADMIN="PORTAL_ADMIN",fe.ADMIN="ADMIN",fe.DEVELOPER="DEVELOPER";const Ae=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),me=e=>r(e)&&s(e.identifier)&&s(e.realm),Ee=e=>r(e)&&Array.isArray(e.defaultFilters)&&e.defaultFilters.every((e=>k(e))),ge=e=>r(e)&&(null==e.emailAddress||s(e.emailAddress))&&(null==e.displayName||s(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>Ae(e)))&&(null==e.userId||s(e.userId)),be=e=>"object"==typeof e&&null!=e,Te=e=>"boolean"==typeof e,Se=e=>"number"==typeof e,Re=e=>"string"==typeof e;var Fe;e.FtConfigurationHistoryEntryStatus=void 0,(Fe=e.FtConfigurationHistoryEntryStatus||(e.FtConfigurationHistoryEntryStatus={})).VALID="VALID",Fe.INVALID="INVALID";const Oe=e=>be(e)&&Te(e.mailsSentByFluidTopics)&&Te(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>Re(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>Re(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>Re(e))),Ue=e=>be(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>Te(e))))&&Te(e.isVisible),Ie=e=>be(e)&&(null==e.prettyUrl||Re(e.prettyUrl))&&(null==e.hasRating||Te(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||Re(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>Ie(e)))&&(null==e.pageConfiguration||Ue(e.pageConfiguration))&&(null==e.contentId||Re(e.contentId))&&(null==e.title||Re(e.title)),ve=e=>be(e)&&Te(e.splitCurrentPageToc),_e={[e.FtUserRole.PERSONAL_BOOK_SHARE_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.HTML_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.PDF_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.KHUB_ADMIN]:[e.FtUserRole.CONTENT_PUBLISHER],[e.FtUserRole.ADMIN]:[e.FtUserRole.KHUB_ADMIN,e.FtUserRole.USERS_ADMIN,e.FtUserRole.PORTAL_ADMIN],[e.FtUserRole.DEVELOPER]:[e.FtUserRole.BETA_USER,e.FtUserRole.DEBUG_USER]};function Ce(e,t){return e===t||(_e[e]??[]).some((e=>Ce(e,t)))}const Le="undefined"==typeof window?globalThis:window;function De(e){let t={};for(let r in e){let i=e[r];("object"!=typeof i||Array.isArray(i))&&(i={prior:i});for(let e of["prior","filter"])i[e]=Array.isArray(i[e])?i[e]:[i[e]],i[e]=i[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=i}return t}function Pe(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const Ne="undefined"==typeof window?globalThis:window;class Me extends Error{method;endpoint;status;statusText;body;constructor(e,t,r,i,a){super(`${e} ${t} -> ${r} - ${i}: ${a}`),this.method=e,this.endpoint=t,this.status=r,this.statusText=i,this.body=a}}class ke extends CustomEvent{constructor(e){super("ft-api-http-error",{detail:e})}}async function we(e,t,r){if(!r.ok){let i={method:e,endpoint:t,status:r.status,statusText:r.statusText,body:await r.text()};throw"function"==typeof Ne.dispatchEvent&&Ne.dispatchEvent(new ke(i)),new Me(i.method,i.endpoint,i.status,i.statusText,i.body)}return r}function Be(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class He{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})},searches:{list:`api/users/${e}/searches`},bookmarks:{list:`api/users/${e}/bookmarks`}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader",metadata:"api/configuration/metadata"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??Ne.fluidTopicsBaseUrl??Ne.__gwt_ft_moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",r&&void 0!==Ne.location&&Ne.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e,t){return this.get(this.endpoints.khub.maps.mapId(e).info,t)}getTableOfContent(e,t){return this.get(this.endpoints.khub.maps.mapId(e).toc,t)}getPages(e,t){return this.get(this.endpoints.khub.maps.mapId(e).pages,t)}getTopic(e,t,r){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info,r)}getTopicHTMLContent(e,t,r,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(r?"?target="+r:""),i)}getMapAttachments(e,t){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list,t)}getMapAttachmentContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content,r)}getMapResources(e,t){return this.get(this.endpoints.khub.maps.mapId(e).resources.list,t)}getMapResourceContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content,r)}getUnstructuredDocument(e,t){return this.get(this.endpoints.khub.documents.documentId(e).info,t)}getUnstructuredDocumentContent(e,t){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content,t)}getUnstructuredDocumentTextContent(e,t){return this.get(this.endpoints.khub.documents.documentId(e).text,t)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.khub.locales)}getMetadataConfiguration(){return this.get(this.endpoints.configuration.metadata)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:r})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t,from:r})}rateTopic(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:i})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:r})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t,from:r})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}getCustomMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).custom.contextName(t).endpoint)}listMySearches(e){return this.get(this.endpoints.users.userId(e).searches.list)}listMyBookmarks(e){return this.get(this.endpoints.users.userId(e).bookmarks.list)}get(e,t){return this.makeRequest("GET",this.withVersion(e,t))}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return e.startsWith(this.tenantBaseUrl)?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await fetch(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,i=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,s)=>{let n=new XMLHttpRequest;n.onload=()=>{if(n.status>=200&&n.status<300){let e="application/json"===n.getResponseHeader("Content-Type")?JSON.parse(n.responseText):n.responseText;a(e)}else s(new Me("GET",t,n.status,n.statusText,n.responseText))},n.upload.onprogress=e=>i(e),n.open(e,this.makeAbsolute(t),!0),n.send(r)})):this.fetch(t,{method:e,body:r}).then((r=>we(e,t,r))).then(Be)}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0,credentials:null==this.authorization?"include":void 0}).then((r=>we(e,t,r))).then(Be)}fetchRawData(e,t){return fetch(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then((t=>we("GET",e,t))).then((e=>e.arrayBuffer()))}withVersion(e,t){let r=new URL(this.makeAbsolute(e));return t&&r.searchParams.append("v",t),r.toString()}}e.FluidTopicsApi=He,e.HttpError=Me,e.HttpErrorEvent=ke,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(Le.localStorage){const r=Pe(e),i=e=>{e.storageArea===Le.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return Le.addEventListener("storage",i),{removeHandler:()=>Le.removeEventListener("storage",i)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=He,e.getUnauthenticatedUserSearchPreferences=function(e){if(Le.localStorage)return JSON.parse(Le.localStorage.getItem(Pe(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>r(e)&&me(e.authenticationIdentifier)&&ge(e.profile),e.isFtAuthenticationIdentifier=me,e.isFtBookmark=e=>r(e)&&s(e.mapTitle)&&o(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.lastUpdate)&&s(e.readerUrl)&&s(e.mapId)&&s(e.id)&&s(e.title)&&s(e.creationDate),e.isFtCollectionDocument=e=>r(e)&&i(e.deleted)&&(null==e.apiUrl||s(e.apiUrl))&&(null==e.portalUrl||s(e.portalUrl))&&s(e.id)&&s(e.title)&&W(e.type),e.isFtCollectionDocumentType=W,e.isFtConfigurationHistoryEntryStatus=e=>["VALID","INVALID"].includes(e),e.isFtCredentials=e=>r(e)&&s(e.password)&&(null==e.newPassword||s(e.newPassword))&&i(e.rememberMe)&&s(e.login),e.isFtEditorialType=G,e.isFtFacetType=e=>["AND","OR","MONOVALUED"].includes(e),e.isFtFeedbackCreation=e=>r(e)&&(null==e.from||s(e.from))&&s(e.message),e.isFtHttpErrorDetails=e=>r(e)&&s(e.endpoint)&&s(e.method)&&s(e.statusText)&&s(e.body)&&a(e.status),e.isFtLabeledSearchFilter=J,e.isFtMap=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&X(e.openMode)&&(null==e.topicsApiEndpoint||s(e.topicsApiEndpoint))&&(null==e.description||s(e.description))&&(null==e.attachmentsApiEndpoint||s(e.attachmentsApiEndpoint))&&G(e.editorialType)&&s(e.baseId)&&s(e.clusterId)&&s(e.title)&&s(e.lastPublication)&&s(e.lastEdition)&&s(e.originId)&&(null==e.rightsApiEndpoint||s(e.rightsApiEndpoint))&&h(e.contentStyles)&&(null==e.originUrl||s(e.originUrl))&&s(e.fingerprint)&&s(e.readerUrl)&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtMapAttachment=e=>be(e)&&Re(e.file)&&(null==e.size||Se(e.size))&&Te(e.externalLink)&&Re(e.name)&&Re(e.id)&&(null==e.mimeType||Re(e.mimeType))&&(null==e.viewerUrl||Re(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&s(e.contentUrl)&&s(e.filename)&&s(e.id)&&s(e.mimeType),e.isFtMapStyles=h,e.isFtMessageContext=e=>r(e)&&s(e.name)&&r(e.messages)&&Object.keys(e.messages).every((e=>s(e)))&&Object.values(e.messages).every((e=>s(e)))&&s(e.locale),e.isFtMetadata=b,e.isFtMetadataConfiguration=e=>r(e)&&Array.isArray(e.descriptors)&&e.descriptors.every((e=>R(e))),e.isFtMetadataDescriptor=R,e.isFtMetadataHomeLayout=e=>["CLASSIC","CUSTOM","DESIGNER"].includes(e),e.isFtMetadataPreferenceConfiguration=L,e.isFtMetadataSortRule=S,e.isFtMyLibraryColors=o,e.isFtMySearch=e=>r(e)&&F(e.searchRequest)&&o(e.color)&&i(e.alert)&&s(e.description)&&s(e.id)&&s(e.ownerId)&&s(e.title)&&s(e.creationDate),e.isFtMySearchRequest=F,e.isFtOpenMode=X,e.isFtPageConfiguration=Ue,e.isFtPageRequest=Y,e.isFtPaginatedToc=e=>be(e)&&ve(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>Ie(e))),e.isFtPaginatedTocNode=Ie,e.isFtPaginationConfiguration=ve,e.isFtPeriod=D,e.isFtPeriodFilter=P,e.isFtPeriodFilterType=M,e.isFtPersonalBookCreation=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>c(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>d(e)))&&s(e.description)&&s(e.title),e.isFtPersonalBookMetadataUpdate=c,e.isFtPersonalBookNodeCreation=d,e.isFtPersonalBookTopicLinkCreation=p,e.isFtPublicationRating=I,e.isFtPublicationRatingSummary=v,e.isFtRatingCreation=e=>r(e)&&U(e.type)&&a(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||C(e.topics))&&v(e.publication),e.isFtRatingType=U,e.isFtReaderConfiguration=e=>be(e)&&Oe(e.feedback)&&Se(e.loadAfterLastVisibleTopic)&&Se(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=Oe,e.isFtSearchFacet=le,e.isFtSearchFacetConf=ue,e.isFtSearchFacetEntry=ce,e.isFtSearchFilter=k,e.isFtSearchLocale=E,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>E(e))),e.isFtSearchPreferences=Ee,e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>s(e)))&&Object.values(e.metadata).every((e=>L(e))),e.isFtSearchPreset=e=>r(e)&&s(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&a(e.priority)&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSearchPrior=Q,e.isFtSearchRequest=e=>r(e)&&(null==e.periodFilter||P(e.periodFilter))&&s(e.query)&&(null==e.scope||oe(e.scope))&&Y(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.uiLocale||s(e.uiLocale))&&(null==e.virtualField||$(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>Q(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>ue(e))),e.isFtSearchResultCluster=Z,e.isFtSearchResultClusterEntry=ee,e.isFtSearchResultMap=re,e.isFtSearchResultTopic=ie,e.isFtSearchResultType=se,e.isFtSearchResultUnstructuredDocument=te,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||pe(e.spellcheck))&&K(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>Z(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>le(e))),e.isFtSearchResultsPageInfo=K,e.isFtSearchScope=oe,e.isFtSearchSortCriterion=de,e.isFtSearchSortCriterionOrder=B,e.isFtSearchSortCriterionType=x,e.isFtSession=e=>r(e)&&(null==e.authenticationIdentifier||me(e.authenticationIdentifier))&&a(e.idleTimeoutInMillis)&&ge(e.profile)&&i(e.sessionAuthenticated)&&Ee(e.searchPreferences),e.isFtSpellcheck=pe,e.isFtSuggestRequest=e=>r(e)&&s(e.input)&&(null==e.scope||oe(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.maxCount||a(e.maxCount))&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSuggestResult=ye,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>ye(e))),e.isFtTocNode=y,e.isFtTopic=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&s(e.id)&&s(e.contentApiEndpoint)&&s(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=f,e.isFtTopicOriginType=u,e.isFtTopicRating=_,e.isFtTopicResource=he,e.isFtTopicsRatingSummary=C,e.isFtUiLocale=e=>r(e)&&s(e.displayName)&&s(e.languageTag)&&i(e.translated),e.isFtUnstructuredDocument=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&s(e.openMode)&&(null==e.description||s(e.description))&&s(e.mimeType)&&(null==e.baseId||s(e.baseId))&&(null==e.clusterId||s(e.clusterId))&&s(e.contentApiEndpoint)&&s(e.title)&&(null==e.lastPublication||s(e.lastPublication))&&s(e.viewerUrl)&&s(e.lastEdition)&&s(e.filename)&&(null==e.originId||s(e.originId))&&s(e.rightsApiEndpoint)&&(null==e.originUrl||s(e.originUrl))&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtUserProfile=ge,e.isFtUserRole=Ae,e.isFtVirtualField=$,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(Le.localStorage){let r={...t,metadata:De(t.metadata??{})};const i=Pe(e),a=JSON.stringify(r);return Le.localStorage.setItem(i,a),Le.dispatchEvent(new StorageEvent("storage",{key:i,newValue:a,storageArea:Le.localStorage,url:Le.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")},e.userHasRole=function(e,t){return null!=e&&(Array.isArray(e)?e:Array.isArray(e.roles)?e.roles:Array.isArray(e.profile?.roles)?e.profile.roles:[]).some((e=>Ce(e,t)))}}));
|
package/dist/cjs/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.FluidTopicsApi = exports.HttpError = void 0;
|
|
26
|
+
exports.FluidTopicsApi = exports.HttpErrorEvent = exports.HttpError = void 0;
|
|
27
27
|
require("cross-fetch/polyfill");
|
|
28
28
|
const wnd = (typeof window === "undefined" ? globalThis : window);
|
|
29
29
|
__exportStar(require("./types/ft-common/public"), exports);
|
|
@@ -34,18 +34,36 @@ function toBase64(s) {
|
|
|
34
34
|
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
35
35
|
}
|
|
36
36
|
class HttpError extends Error {
|
|
37
|
-
constructor(status, statusText, body) {
|
|
38
|
-
super(`${status} - ${statusText}: ${body}`);
|
|
37
|
+
constructor(method, endpoint, status, statusText, body) {
|
|
38
|
+
super(`${method} ${endpoint} -> ${status} - ${statusText}: ${body}`);
|
|
39
|
+
this.method = method;
|
|
40
|
+
this.endpoint = endpoint;
|
|
39
41
|
this.status = status;
|
|
40
42
|
this.statusText = statusText;
|
|
41
43
|
this.body = body;
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
exports.HttpError = HttpError;
|
|
45
|
-
|
|
47
|
+
class HttpErrorEvent extends CustomEvent {
|
|
48
|
+
constructor(e) {
|
|
49
|
+
super("ft-api-http-error", { detail: e });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.HttpErrorEvent = HttpErrorEvent;
|
|
53
|
+
function handleError(method, endpoint, response) {
|
|
46
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
55
|
if (!response.ok) {
|
|
48
|
-
|
|
56
|
+
let details = {
|
|
57
|
+
method,
|
|
58
|
+
endpoint,
|
|
59
|
+
status: response.status,
|
|
60
|
+
statusText: response.statusText,
|
|
61
|
+
body: yield response.text()
|
|
62
|
+
};
|
|
63
|
+
if (typeof wnd.dispatchEvent === "function") {
|
|
64
|
+
wnd.dispatchEvent(new HttpErrorEvent(details));
|
|
65
|
+
}
|
|
66
|
+
throw new HttpError(details.method, details.endpoint, details.status, details.statusText, details.body);
|
|
49
67
|
}
|
|
50
68
|
return response;
|
|
51
69
|
});
|
|
@@ -58,7 +76,7 @@ class FluidTopicsApi {
|
|
|
58
76
|
return Object.assign(Object.assign(Object.assign({}, this.authorization), this.searchLabel), { "Ft-Calling-App": this.ftCallingApp });
|
|
59
77
|
}
|
|
60
78
|
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
61
|
-
var _a, _b
|
|
79
|
+
var _a, _b;
|
|
62
80
|
this.endpoints = {
|
|
63
81
|
authentication: {
|
|
64
82
|
login: `api/authentication/login`,
|
|
@@ -156,7 +174,7 @@ class FluidTopicsApi {
|
|
|
156
174
|
},
|
|
157
175
|
};
|
|
158
176
|
//@ts-ignore
|
|
159
|
-
tenantBaseUrl = ((
|
|
177
|
+
tenantBaseUrl = ((_b = (_a = tenantBaseUrl !== null && tenantBaseUrl !== void 0 ? tenantBaseUrl : wnd.fluidTopicsBaseUrl) !== null && _a !== void 0 ? _a : wnd.__gwt_ft_moduleBase) !== null && _b !== void 0 ? _b : "").trim();
|
|
160
178
|
this.tenantBaseUrl = tenantBaseUrl.endsWith("/") ? tenantBaseUrl : tenantBaseUrl + "/";
|
|
161
179
|
if (overrideIdentifierIfOnTenant && typeof wnd.location !== "undefined" && wnd.location.href.startsWith(this.tenantBaseUrl)) {
|
|
162
180
|
this.ftCallingApp = integrationIdentifier;
|
|
@@ -335,7 +353,7 @@ class FluidTopicsApi {
|
|
|
335
353
|
resolve(data);
|
|
336
354
|
}
|
|
337
355
|
else {
|
|
338
|
-
reject(new HttpError(xhr.status, xhr.statusText, xhr.responseText));
|
|
356
|
+
reject(new HttpError("GET", endpoint, xhr.status, xhr.statusText, xhr.responseText));
|
|
339
357
|
}
|
|
340
358
|
};
|
|
341
359
|
xhr.upload.onprogress = (e) => onProgress(e);
|
|
@@ -344,7 +362,9 @@ class FluidTopicsApi {
|
|
|
344
362
|
});
|
|
345
363
|
}
|
|
346
364
|
else {
|
|
347
|
-
return this.fetch(endpoint, { method, body })
|
|
365
|
+
return this.fetch(endpoint, { method, body })
|
|
366
|
+
.then((r) => handleError(method, endpoint, r))
|
|
367
|
+
.then(getBody);
|
|
348
368
|
}
|
|
349
369
|
}
|
|
350
370
|
makeRequest(method, endpoint, data) {
|
|
@@ -354,7 +374,7 @@ class FluidTopicsApi {
|
|
|
354
374
|
body: data != null ? JSON.stringify(data) : undefined,
|
|
355
375
|
credentials: this.authorization == null ? "include" : undefined
|
|
356
376
|
})
|
|
357
|
-
.then(handleError)
|
|
377
|
+
.then((r) => handleError(method, endpoint, r))
|
|
358
378
|
.then(getBody);
|
|
359
379
|
}
|
|
360
380
|
fetchRawData(endpoint, v) {
|
|
@@ -362,7 +382,7 @@ class FluidTopicsApi {
|
|
|
362
382
|
headers: this.defaultHeaders,
|
|
363
383
|
credentials: this.authorization == null ? "include" : undefined
|
|
364
384
|
})
|
|
365
|
-
.then(handleError)
|
|
385
|
+
.then((r) => handleError("GET", endpoint, r))
|
|
366
386
|
.then(response => response.arrayBuffer());
|
|
367
387
|
}
|
|
368
388
|
withVersion(endpoint, v) {
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.isFtUserProfile = exports.isFtSession = exports.isFtSearchPreferences = exports.isFtAuthenticatedSession = exports.isFtAuthenticationIdentifier = exports.isFtUserRole = exports.FtUserRole = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = exports.isFtSearchFacetConf = exports.isFtSearchFacet = exports.isFtSearchScope = exports.FtSearchScope = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtSearchResultTopic = exports.isFtSearchResultMap = exports.isFtSearchResultUnstructuredDocument = exports.isFtSearchResultClusterEntry = exports.isFtSearchResultCluster = exports.isFtSearchRequest = exports.isFtSearchPrior = exports.isFtLabeledSearchFilter = exports.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtVirtualField = exports.FtVirtualField = exports.isFtSearchSortCriterionType = exports.FtSearchSortCriterionType = exports.isFtSearchSortCriterionOrder = exports.FtSearchSortCriterionOrder = exports.isFtSearchPreset = exports.isFtSearchFilter = void 0;
|
|
3
|
+
exports.FtPeriodFilterType = exports.isFtPeriodFilter = exports.isFtPeriod = exports.isFtSearchPreferencesConfiguration = exports.isFtMetadataPreferenceConfiguration = exports.isFtMapResource = exports.isFtTopicsRatingSummary = exports.isFtTopicRating = exports.isFtRatingSummary = exports.isFtRatingCreation = exports.isFtPublicationRatingSummary = exports.isFtPublicationRating = exports.isFtRatingType = exports.FtRatingType = exports.isFtMySearchRequest = exports.isFtMySearch = exports.isFtMetadataDescriptor = exports.isFtMetadataConfiguration = exports.isFtMetadataSortRule = exports.FtMetadataSortRule = exports.isFtMetadata = exports.isFtFacetType = exports.FtFacetType = exports.isFtUiLocale = exports.isFtMessageContext = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtMetadataHomeLayout = exports.FtMetadataHomeLayout = exports.isFtFeedbackCreation = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopicOrigin = exports.isFtTopic = exports.isFtTocNode = exports.isFtMapStyles = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtBookmark = exports.isFtPersonalBookTopicLinkCreation = exports.isFtPersonalBookNodeCreation = exports.isFtPersonalBookMetadataUpdate = exports.isFtPersonalBookCreation = exports.isFtCredentials = exports.isFtTopicOriginType = exports.FtTopicOriginType = exports.isFtMyLibraryColors = exports.FtMyLibraryColors = exports.isFtHttpErrorDetails = void 0;
|
|
4
|
+
exports.isFtUserProfile = exports.isFtSession = exports.isFtSearchPreferences = exports.isFtAuthenticatedSession = exports.isFtAuthenticationIdentifier = exports.isFtUserRole = exports.FtUserRole = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = exports.isFtSearchFacetConf = exports.isFtSearchFacet = exports.isFtSearchScope = exports.FtSearchScope = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtSearchResultTopic = exports.isFtSearchResultMap = exports.isFtSearchResultUnstructuredDocument = exports.isFtSearchResultClusterEntry = exports.isFtSearchResultCluster = exports.isFtSearchRequest = exports.isFtSearchPrior = exports.isFtLabeledSearchFilter = exports.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtVirtualField = exports.FtVirtualField = exports.isFtSearchSortCriterionType = exports.FtSearchSortCriterionType = exports.isFtSearchSortCriterionOrder = exports.FtSearchSortCriterionOrder = exports.isFtSearchPreset = exports.isFtSearchFilter = exports.isFtPeriodFilterType = void 0;
|
|
5
5
|
const isObject = (o) => typeof o === "object" && o != null;
|
|
6
6
|
const isBoolean = (o) => typeof o === "boolean";
|
|
7
7
|
const isNumber = (o) => typeof o === "number";
|
|
8
8
|
const isString = (o) => typeof o === "string";
|
|
9
|
+
const isFtHttpErrorDetails = (o) => {
|
|
10
|
+
return isObject(o)
|
|
11
|
+
&& (isString(o.endpoint))
|
|
12
|
+
&& (isString(o.method))
|
|
13
|
+
&& (isString(o.statusText))
|
|
14
|
+
&& (isString(o.body))
|
|
15
|
+
&& (isNumber(o.status));
|
|
16
|
+
};
|
|
17
|
+
exports.isFtHttpErrorDetails = isFtHttpErrorDetails;
|
|
9
18
|
// From: MyLibraryColors
|
|
10
19
|
var FtMyLibraryColors;
|
|
11
20
|
(function (FtMyLibraryColors) {
|
package/dist/fluidtopics.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function n(e){return"string"!=typeof e&&(e=String(e)),e}function o(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function u(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function d(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||a(e))?this._bodyArrayBuffer=p(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,i=u(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=n(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=n(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),o(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),o(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),o(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function f(e,t){var r,i,a=(t=t||{}).body;if(e instanceof f){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,a||null==e._bodyInit||(a=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),y.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(a)}function A(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),a=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(a))}})),t}function m(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}f.prototype.clone=function(){return new f(this,{body:this._bodyInit})},h.call(f.prototype),h.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},m.error=function(){var e=new m(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];m.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new m(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function g(e,i){return new Promise((function(a,s){var n=new f(e,i);if(n.signal&&n.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),i=r.shift().trim();if(i){var a=r.join(":").trim();t.append(i,a)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;a(new m(i,r))},o.onerror=function(){s(new TypeError("Network request failed"))},o.ontimeout=function(){s(new TypeError("Network request failed"))},o.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},o.open(n.method,n.url,!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),n.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),n.signal&&(n.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",u)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}g.polyfill=!0,e.fetch||(e.fetch=g,e.Headers=l,e.Request=f,e.Response=m),t.Headers=l,t.Request=f,t.Response=m,t.fetch=g,Object.defineProperty(t,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:t);const r=e=>"object"==typeof e&&null!=e,i=e=>"boolean"==typeof e,a=e=>"number"==typeof e,s=e=>"string"==typeof e;var n;e.FtMyLibraryColors=void 0,(n=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",n.green="green",n.blue="blue",n.purple="purple",n.red="red",n.orange="orange",n.yellow="yellow";const o=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var l;e.FtTopicOriginType=void 0,(l=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",l.PERSONAL="PERSONAL",l.SHARED="SHARED";const u=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),c=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>s(e)))))&&s(e.key),d=e=>r(e)&&s(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>d(e)))&&(null==e.topicLink||p(e.topicLink))&&s(e.title)&&(null==e.htmlContent||s(e.htmlContent)),p=e=>r(e)&&s(e.tocId)&&s(e.contentId)&&s(e.mapId),h=e=>r(e)&&s(e.topicStylesheetUrl)&&s(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>s(e))),y=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&(null==e.hasRating||i(e.hasRating))&&s(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>y(e)))&&(null==e.origin||f(e.origin))&&s(e.contentId)&&s(e.title),f=e=>r(e)&&s(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.contentId)&&s(e.mapId)&&u(e.type);var A;e.FtTopicContentTarget=void 0,(A=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",A.OFF_THE_GRID="OFF_THE_GRID",A.CONTENT_PACKAGER="CONTENT_PACKAGER",A.PAGES="PAGES",A.DESIGNED_READER="DESIGNED_READER";var m;e.FtMetadataHomeLayout=void 0,(m=e.FtMetadataHomeLayout||(e.FtMetadataHomeLayout={})).CLASSIC="CLASSIC",m.CUSTOM="CUSTOM",m.DESIGNER="DESIGNER";const E=e=>r(e)&&a(e.count)&&s(e.label)&&(null==e.lang||s(e.lang));var g;e.FtFacetType=void 0,(g=e.FtFacetType||(e.FtFacetType={})).AND="AND",g.OR="OR",g.MONOVALUED="MONOVALUED";const S=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>s(e))))))&&s(e.label)&&s(e.key);var b;e.FtMetadataSortRule=void 0,(b=e.FtMetadataSortRule||(e.FtMetadataSortRule={})).NONE="NONE",b.ALPHABET="ALPHABET",b.VERSION="VERSION";const T=e=>["NONE","ALPHABET","VERSION"].includes(e),R=e=>r(e)&&T(e.sortRule)&&i(e.reverseSort)&&s(e.key),F=e=>r(e)&&(null==e.periodFilter||P(e.periodFilter))&&s(e.query)&&(null==e.scope||oe(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>J(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.virtualField||K(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale));var O;e.FtRatingType=void 0,(O=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",O.LIKE="LIKE",O.DICHOTOMOUS="DICHOTOMOUS",O.NO_RATING="NO_RATING";const U=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),I=e=>r(e)&&s(e.date)&&U(e.type)&&a(e.value),v=e=>r(e)&&(null==e.rating||I(e.rating))&&U(e.type),_=e=>r(e)&&s(e.date)&&s(e.tocId)&&U(e.type)&&a(e.value),C=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>_(e)))&&U(e.type),L=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>s(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>s(e))),D=e=>r(e)&&s(e.from)&&s(e.to),P=e=>r(e)&&(null==e.period||D(e.period))&&M(e.periodType);var N;e.FtPeriodFilterType=void 0,(N=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",N.LAST_MONTH="LAST_MONTH",N.LAST_YEAR="LAST_YEAR",N.CUSTOM="CUSTOM";const M=e=>["LAST_WEEK","LAST_MONTH","LAST_YEAR","CUSTOM"].includes(e),k=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.key);var w;e.FtSearchSortCriterionOrder=void 0,(w=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",w.DESC="DESC";const B=e=>["ASC","DESC"].includes(e);var H;e.FtSearchSortCriterionType=void 0,(H=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",H.NATURAL="NATURAL";const x=e=>["ALPHA","NATURAL"].includes(e);var V;e.FtVirtualField=void 0,(V=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",V.TITLE_ONLY="TITLE_ONLY",V.NONE="NONE";const K=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),$=e=>r(e)&&a(e.totalResultsCount)&&i(e.isLastPage)&&a(e.currentPage)&&a(e.totalClustersCount);var j;e.FtEditorialType=void 0,(j=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",j.BOOK="BOOK",j.SHARED_BOOK="SHARED_BOOK";const G=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var q;e.FtOpenMode=void 0,(q=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",q.EXTERNAL="EXTERNAL";const X=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),Y=e=>r(e)&&(null==e.perPage||a(e.perPage))&&a(e.page);var z;e.FtCollectionDocumentType=void 0,(z=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",z.DOCUMENT="DOCUMENT",z.TOPIC="TOPIC",z.PERSONAL_BOOK="PERSONAL_BOOK",z.SHARED_BOOK="SHARED_BOOK";const W=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),J=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.label)&&s(e.key),Q=e=>r(e)&&a(e.weight)&&s(e.value)&&s(e.key),Z=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>ee(e)))&&(null==e.metadataVariableAxis||s(e.metadataVariableAxis)),ee=e=>r(e)&&(null==e.document||te(e.document))&&(null==e.topic||ie(e.topic))&&se(e.type)&&(null==e.map||re(e.map)),te=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&X(e.openMode)&&s(e.documentUrl)&&s(e.mimeType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.viewerUrl)&&s(e.contentUrl)&&s(e.filename)&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.documentId)&&s(e.lastEditionDate)&&s(e.htmlExcerpt),re=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&(null==e.openMode||X(e.openMode))&&G(e.editorialType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.mapUrl)&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt),ie=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&X(e.openMode)&&s(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>he(e)))&&s(e.title)&&s(e.mapTitle)&&s(e.topicUrl)&&s(e.contentUrl)&&s(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&(null==e.originUrl||s(e.originUrl))&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt);var ae;e.FtSearchResultType=void 0,(ae=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",ae.DOCUMENT="DOCUMENT",ae.TOPIC="TOPIC";const se=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var ne;e.FtSearchScope=void 0,(ne=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",ne.DOCUMENTS="DOCUMENTS",ne.ALL_TOPICS="ALL_TOPICS";const oe=e=>["DEFAULT","DOCUMENTS","ALL_TOPICS"].includes(e),le=e=>r(e)&&i(e.hierarchical)&&s(e.label)&&i(e.multiSelectionable)&&s(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>ce(e))),ue=e=>r(e)&&(null==e.maxDepth||a(e.maxDepth))&&s(e.id),ce=e=>r(e)&&a(e.totalResultsCount)&&i(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>ce(e)))&&s(e.label)&&s(e.value)&&i(e.selected),de=e=>r(e)&&x(e.type)&&s(e.key)&&B(e.order),pe=e=>r(e)&&s(e.suggestedQuery)&&s(e.htmlSuggestedQuery),he=e=>r(e)&&s(e.filename)&&s(e.resourceUrl)&&s(e.id)&&s(e.mimeType)&&s(e.resourceContentUrl)&&s(e.viewerUrl),ye=e=>r(e)&&(null==e.filenameExtension||s(e.filenameExtension))&&(null==e.editorialType||G(e.editorialType))&&(null==e.mimeType||s(e.mimeType))&&se(e.type)&&s(e.value);var fe;e.FtUserRole=void 0,(fe=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",fe.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",fe.HTML_EXPORT_USER="HTML_EXPORT_USER",fe.PDF_EXPORT_USER="PDF_EXPORT_USER",fe.SAVED_SEARCH_USER="SAVED_SEARCH_USER",fe.COLLECTION_USER="COLLECTION_USER",fe.OFFLINE_USER="OFFLINE_USER",fe.ANALYTICS_USER="ANALYTICS_USER",fe.BETA_USER="BETA_USER",fe.DEBUG_USER="DEBUG_USER",fe.PRINT_USER="PRINT_USER",fe.RATING_USER="RATING_USER",fe.FEEDBACK_USER="FEEDBACK_USER",fe.CONTENT_PUBLISHER="CONTENT_PUBLISHER",fe.KHUB_ADMIN="KHUB_ADMIN",fe.USERS_ADMIN="USERS_ADMIN",fe.PORTAL_ADMIN="PORTAL_ADMIN",fe.ADMIN="ADMIN",fe.DEVELOPER="DEVELOPER";const Ae=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),me=e=>r(e)&&s(e.identifier)&&s(e.realm),Ee=e=>r(e)&&Array.isArray(e.defaultFilters)&&e.defaultFilters.every((e=>k(e))),ge=e=>r(e)&&(null==e.emailAddress||s(e.emailAddress))&&(null==e.displayName||s(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>Ae(e)))&&(null==e.userId||s(e.userId)),Se=e=>"object"==typeof e&&null!=e,be=e=>"boolean"==typeof e,Te=e=>"number"==typeof e,Re=e=>"string"==typeof e;var Fe;e.FtConfigurationHistoryEntryStatus=void 0,(Fe=e.FtConfigurationHistoryEntryStatus||(e.FtConfigurationHistoryEntryStatus={})).VALID="VALID",Fe.INVALID="INVALID";const Oe=e=>Se(e)&&be(e.mailsSentByFluidTopics)&&be(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>Re(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>Re(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>Re(e))),Ue=e=>Se(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>be(e))))&&be(e.isVisible),Ie=e=>Se(e)&&(null==e.prettyUrl||Re(e.prettyUrl))&&(null==e.hasRating||be(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||Re(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>Ie(e)))&&(null==e.pageConfiguration||Ue(e.pageConfiguration))&&(null==e.contentId||Re(e.contentId))&&(null==e.title||Re(e.title)),ve=e=>Se(e)&&be(e.splitCurrentPageToc),_e={[e.FtUserRole.PERSONAL_BOOK_SHARE_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.HTML_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.PDF_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.KHUB_ADMIN]:[e.FtUserRole.CONTENT_PUBLISHER],[e.FtUserRole.ADMIN]:[e.FtUserRole.KHUB_ADMIN,e.FtUserRole.USERS_ADMIN,e.FtUserRole.PORTAL_ADMIN],[e.FtUserRole.DEVELOPER]:[e.FtUserRole.BETA_USER,e.FtUserRole.DEBUG_USER]};function Ce(e,t){return e===t||(_e[e]??[]).some((e=>Ce(e,t)))}const Le="undefined"==typeof window?globalThis:window;function De(e){let t={};for(let r in e){let i=e[r];("object"!=typeof i||Array.isArray(i))&&(i={prior:i});for(let e of["prior","filter"])i[e]=Array.isArray(i[e])?i[e]:[i[e]],i[e]=i[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=i}return t}function Pe(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const Ne="undefined"==typeof window?globalThis:window;class Me extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function ke(e){if(!e.ok)throw new Me(e.status,e.statusText,await e.text());return e}function we(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class Be{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})},searches:{list:`api/users/${e}/searches`},bookmarks:{list:`api/users/${e}/bookmarks`}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader",metadata:"api/configuration/metadata"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??Ne.__gwt_ft_moduleBase??Ne.fluidtopicsclient?.__moduleBase??Ne.__gwt_activeModules?.fluidtopicsclient?.moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",r&&void 0!==Ne.location&&Ne.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e,t){return this.get(this.endpoints.khub.maps.mapId(e).info,t)}getTableOfContent(e,t){return this.get(this.endpoints.khub.maps.mapId(e).toc,t)}getPages(e,t){return this.get(this.endpoints.khub.maps.mapId(e).pages,t)}getTopic(e,t,r){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info,r)}getTopicHTMLContent(e,t,r,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(r?"?target="+r:""),i)}getMapAttachments(e,t){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list,t)}getMapAttachmentContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content,r)}getMapResources(e,t){return this.get(this.endpoints.khub.maps.mapId(e).resources.list,t)}getMapResourceContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content,r)}getUnstructuredDocument(e,t){return this.get(this.endpoints.khub.documents.documentId(e).info,t)}getUnstructuredDocumentContent(e,t){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content,t)}getUnstructuredDocumentTextContent(e,t){return this.get(this.endpoints.khub.documents.documentId(e).text,t)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.khub.locales)}getMetadataConfiguration(){return this.get(this.endpoints.configuration.metadata)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:r})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t,from:r})}rateTopic(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:i})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:r})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t,from:r})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}getCustomMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).custom.contextName(t).endpoint)}listMySearches(e){return this.get(this.endpoints.users.userId(e).searches.list)}listMyBookmarks(e){return this.get(this.endpoints.users.userId(e).bookmarks.list)}get(e,t){return this.makeRequest("GET",this.withVersion(e,t))}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return e.startsWith(this.tenantBaseUrl)?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await fetch(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,i=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,s)=>{let n=new XMLHttpRequest;n.onload=()=>{if(n.status>=200&&n.status<300){let e="application/json"===n.getResponseHeader("Content-Type")?JSON.parse(n.responseText):n.responseText;a(e)}else s(new Me(n.status,n.statusText,n.responseText))},n.upload.onprogress=e=>i(e),n.open(e,this.makeAbsolute(t),!0),n.send(r)})):this.fetch(t,{method:e,body:r}).then(ke).then(we)}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0,credentials:null==this.authorization?"include":void 0}).then(ke).then(we)}fetchRawData(e,t){return fetch(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then(ke).then((e=>e.arrayBuffer()))}withVersion(e,t){let r=new URL(this.makeAbsolute(e));return t&&r.searchParams.append("v",t),r.toString()}}e.FluidTopicsApi=Be,e.HttpError=Me,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(Le.localStorage){const r=Pe(e),i=e=>{e.storageArea===Le.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return Le.addEventListener("storage",i),{removeHandler:()=>Le.removeEventListener("storage",i)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=Be,e.getUnauthenticatedUserSearchPreferences=function(e){if(Le.localStorage)return JSON.parse(Le.localStorage.getItem(Pe(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>r(e)&&me(e.authenticationIdentifier)&&ge(e.profile),e.isFtAuthenticationIdentifier=me,e.isFtBookmark=e=>r(e)&&s(e.mapTitle)&&o(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.lastUpdate)&&s(e.readerUrl)&&s(e.mapId)&&s(e.id)&&s(e.title)&&s(e.creationDate),e.isFtCollectionDocument=e=>r(e)&&i(e.deleted)&&(null==e.apiUrl||s(e.apiUrl))&&(null==e.portalUrl||s(e.portalUrl))&&s(e.id)&&s(e.title)&&W(e.type),e.isFtCollectionDocumentType=W,e.isFtConfigurationHistoryEntryStatus=e=>["VALID","INVALID"].includes(e),e.isFtCredentials=e=>r(e)&&s(e.password)&&(null==e.newPassword||s(e.newPassword))&&i(e.rememberMe)&&s(e.login),e.isFtEditorialType=G,e.isFtFacetType=e=>["AND","OR","MONOVALUED"].includes(e),e.isFtFeedbackCreation=e=>r(e)&&(null==e.from||s(e.from))&&s(e.message),e.isFtLabeledSearchFilter=J,e.isFtMap=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&X(e.openMode)&&(null==e.topicsApiEndpoint||s(e.topicsApiEndpoint))&&(null==e.description||s(e.description))&&(null==e.attachmentsApiEndpoint||s(e.attachmentsApiEndpoint))&&G(e.editorialType)&&s(e.baseId)&&s(e.clusterId)&&s(e.title)&&s(e.lastPublication)&&s(e.lastEdition)&&s(e.originId)&&(null==e.rightsApiEndpoint||s(e.rightsApiEndpoint))&&h(e.contentStyles)&&(null==e.originUrl||s(e.originUrl))&&s(e.fingerprint)&&s(e.readerUrl)&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtMapAttachment=e=>Se(e)&&Re(e.file)&&(null==e.size||Te(e.size))&&be(e.externalLink)&&Re(e.name)&&Re(e.id)&&(null==e.mimeType||Re(e.mimeType))&&(null==e.viewerUrl||Re(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&s(e.contentUrl)&&s(e.filename)&&s(e.id)&&s(e.mimeType),e.isFtMapStyles=h,e.isFtMessageContext=e=>r(e)&&s(e.name)&&r(e.messages)&&Object.keys(e.messages).every((e=>s(e)))&&Object.values(e.messages).every((e=>s(e)))&&s(e.locale),e.isFtMetadata=S,e.isFtMetadataConfiguration=e=>r(e)&&Array.isArray(e.descriptors)&&e.descriptors.every((e=>R(e))),e.isFtMetadataDescriptor=R,e.isFtMetadataHomeLayout=e=>["CLASSIC","CUSTOM","DESIGNER"].includes(e),e.isFtMetadataPreferenceConfiguration=L,e.isFtMetadataSortRule=T,e.isFtMyLibraryColors=o,e.isFtMySearch=e=>r(e)&&F(e.searchRequest)&&o(e.color)&&i(e.alert)&&s(e.description)&&s(e.id)&&s(e.ownerId)&&s(e.title)&&s(e.creationDate),e.isFtMySearchRequest=F,e.isFtOpenMode=X,e.isFtPageConfiguration=Ue,e.isFtPageRequest=Y,e.isFtPaginatedToc=e=>Se(e)&&ve(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>Ie(e))),e.isFtPaginatedTocNode=Ie,e.isFtPaginationConfiguration=ve,e.isFtPeriod=D,e.isFtPeriodFilter=P,e.isFtPeriodFilterType=M,e.isFtPersonalBookCreation=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>c(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>d(e)))&&s(e.description)&&s(e.title),e.isFtPersonalBookMetadataUpdate=c,e.isFtPersonalBookNodeCreation=d,e.isFtPersonalBookTopicLinkCreation=p,e.isFtPublicationRating=I,e.isFtPublicationRatingSummary=v,e.isFtRatingCreation=e=>r(e)&&U(e.type)&&a(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||C(e.topics))&&v(e.publication),e.isFtRatingType=U,e.isFtReaderConfiguration=e=>Se(e)&&Oe(e.feedback)&&Te(e.loadAfterLastVisibleTopic)&&Te(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=Oe,e.isFtSearchFacet=le,e.isFtSearchFacetConf=ue,e.isFtSearchFacetEntry=ce,e.isFtSearchFilter=k,e.isFtSearchLocale=E,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>E(e))),e.isFtSearchPreferences=Ee,e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>s(e)))&&Object.values(e.metadata).every((e=>L(e))),e.isFtSearchPreset=e=>r(e)&&s(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&a(e.priority)&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSearchPrior=Q,e.isFtSearchRequest=e=>r(e)&&(null==e.periodFilter||P(e.periodFilter))&&s(e.query)&&(null==e.scope||oe(e.scope))&&Y(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.uiLocale||s(e.uiLocale))&&(null==e.virtualField||K(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>Q(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>ue(e))),e.isFtSearchResultCluster=Z,e.isFtSearchResultClusterEntry=ee,e.isFtSearchResultMap=re,e.isFtSearchResultTopic=ie,e.isFtSearchResultType=se,e.isFtSearchResultUnstructuredDocument=te,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||pe(e.spellcheck))&&$(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>Z(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>le(e))),e.isFtSearchResultsPageInfo=$,e.isFtSearchScope=oe,e.isFtSearchSortCriterion=de,e.isFtSearchSortCriterionOrder=B,e.isFtSearchSortCriterionType=x,e.isFtSession=e=>r(e)&&(null==e.authenticationIdentifier||me(e.authenticationIdentifier))&&a(e.idleTimeoutInMillis)&&ge(e.profile)&&i(e.sessionAuthenticated)&&Ee(e.searchPreferences),e.isFtSpellcheck=pe,e.isFtSuggestRequest=e=>r(e)&&s(e.input)&&(null==e.scope||oe(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.maxCount||a(e.maxCount))&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSuggestResult=ye,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>ye(e))),e.isFtTocNode=y,e.isFtTopic=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&s(e.id)&&s(e.contentApiEndpoint)&&s(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=f,e.isFtTopicOriginType=u,e.isFtTopicRating=_,e.isFtTopicResource=he,e.isFtTopicsRatingSummary=C,e.isFtUiLocale=e=>r(e)&&s(e.displayName)&&s(e.languageTag)&&i(e.translated),e.isFtUnstructuredDocument=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>S(e)))&&s(e.openMode)&&(null==e.description||s(e.description))&&s(e.mimeType)&&(null==e.baseId||s(e.baseId))&&(null==e.clusterId||s(e.clusterId))&&s(e.contentApiEndpoint)&&s(e.title)&&(null==e.lastPublication||s(e.lastPublication))&&s(e.viewerUrl)&&s(e.lastEdition)&&s(e.filename)&&(null==e.originId||s(e.originId))&&s(e.rightsApiEndpoint)&&(null==e.originUrl||s(e.originUrl))&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtUserProfile=ge,e.isFtUserRole=Ae,e.isFtVirtualField=K,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(Le.localStorage){let r={...t,metadata:De(t.metadata??{})};const i=Pe(e),a=JSON.stringify(r);return Le.localStorage.setItem(i,a),Le.dispatchEvent(new StorageEvent("storage",{key:i,newValue:a,storageArea:Le.localStorage,url:Le.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")},e.userHasRole=function(e,t){return null!=e&&(Array.isArray(e)?e:Array.isArray(e.roles)?e.roles:Array.isArray(e.profile?.roles)?e.profile.roles:[]).some((e=>Ce(e,t)))}}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function n(e){return"string"!=typeof e&&(e=String(e)),e}function o(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function u(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function d(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||a(e))?this._bodyArrayBuffer=p(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,i=u(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=n(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=n(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),o(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),o(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),o(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function f(e,t){var r,i,a=(t=t||{}).body;if(e instanceof f){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,a||null==e._bodyInit||(a=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),y.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(a)}function A(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),a=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(a))}})),t}function m(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}f.prototype.clone=function(){return new f(this,{body:this._bodyInit})},h.call(f.prototype),h.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},m.error=function(){var e=new m(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];m.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new m(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function g(e,i){return new Promise((function(a,s){var n=new f(e,i);if(n.signal&&n.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),i=r.shift().trim();if(i){var a=r.join(":").trim();t.append(i,a)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;a(new m(i,r))},o.onerror=function(){s(new TypeError("Network request failed"))},o.ontimeout=function(){s(new TypeError("Network request failed"))},o.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},o.open(n.method,n.url,!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),n.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),n.signal&&(n.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",u)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}g.polyfill=!0,e.fetch||(e.fetch=g,e.Headers=l,e.Request=f,e.Response=m),t.Headers=l,t.Request=f,t.Response=m,t.fetch=g,Object.defineProperty(t,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:t);const r=e=>"object"==typeof e&&null!=e,i=e=>"boolean"==typeof e,a=e=>"number"==typeof e,s=e=>"string"==typeof e;var n;e.FtMyLibraryColors=void 0,(n=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",n.green="green",n.blue="blue",n.purple="purple",n.red="red",n.orange="orange",n.yellow="yellow";const o=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var l;e.FtTopicOriginType=void 0,(l=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",l.PERSONAL="PERSONAL",l.SHARED="SHARED";const u=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),c=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>s(e)))))&&s(e.key),d=e=>r(e)&&s(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>d(e)))&&(null==e.topicLink||p(e.topicLink))&&s(e.title)&&(null==e.htmlContent||s(e.htmlContent)),p=e=>r(e)&&s(e.tocId)&&s(e.contentId)&&s(e.mapId),h=e=>r(e)&&s(e.topicStylesheetUrl)&&s(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>s(e))),y=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&(null==e.hasRating||i(e.hasRating))&&s(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>y(e)))&&(null==e.origin||f(e.origin))&&s(e.contentId)&&s(e.title),f=e=>r(e)&&s(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.contentId)&&s(e.mapId)&&u(e.type);var A;e.FtTopicContentTarget=void 0,(A=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",A.OFF_THE_GRID="OFF_THE_GRID",A.CONTENT_PACKAGER="CONTENT_PACKAGER",A.PAGES="PAGES",A.DESIGNED_READER="DESIGNED_READER";var m;e.FtMetadataHomeLayout=void 0,(m=e.FtMetadataHomeLayout||(e.FtMetadataHomeLayout={})).CLASSIC="CLASSIC",m.CUSTOM="CUSTOM",m.DESIGNER="DESIGNER";const E=e=>r(e)&&a(e.count)&&s(e.label)&&(null==e.lang||s(e.lang));var g;e.FtFacetType=void 0,(g=e.FtFacetType||(e.FtFacetType={})).AND="AND",g.OR="OR",g.MONOVALUED="MONOVALUED";const b=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>s(e))))))&&s(e.label)&&s(e.key);var T;e.FtMetadataSortRule=void 0,(T=e.FtMetadataSortRule||(e.FtMetadataSortRule={})).NONE="NONE",T.ALPHABET="ALPHABET",T.VERSION="VERSION";const S=e=>["NONE","ALPHABET","VERSION"].includes(e),R=e=>r(e)&&S(e.sortRule)&&i(e.reverseSort)&&s(e.key),F=e=>r(e)&&(null==e.periodFilter||P(e.periodFilter))&&s(e.query)&&(null==e.scope||oe(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>J(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.virtualField||$(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale));var O;e.FtRatingType=void 0,(O=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",O.LIKE="LIKE",O.DICHOTOMOUS="DICHOTOMOUS",O.NO_RATING="NO_RATING";const U=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),I=e=>r(e)&&s(e.date)&&U(e.type)&&a(e.value),v=e=>r(e)&&(null==e.rating||I(e.rating))&&U(e.type),_=e=>r(e)&&s(e.date)&&s(e.tocId)&&U(e.type)&&a(e.value),C=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>_(e)))&&U(e.type),L=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>s(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>s(e))),D=e=>r(e)&&s(e.from)&&s(e.to),P=e=>r(e)&&(null==e.period||D(e.period))&&M(e.periodType);var N;e.FtPeriodFilterType=void 0,(N=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",N.LAST_MONTH="LAST_MONTH",N.LAST_YEAR="LAST_YEAR",N.CUSTOM="CUSTOM";const M=e=>["LAST_WEEK","LAST_MONTH","LAST_YEAR","CUSTOM"].includes(e),k=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.key);var w;e.FtSearchSortCriterionOrder=void 0,(w=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",w.DESC="DESC";const B=e=>["ASC","DESC"].includes(e);var H;e.FtSearchSortCriterionType=void 0,(H=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",H.NATURAL="NATURAL";const x=e=>["ALPHA","NATURAL"].includes(e);var V;e.FtVirtualField=void 0,(V=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",V.TITLE_ONLY="TITLE_ONLY",V.NONE="NONE";const $=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),K=e=>r(e)&&a(e.totalResultsCount)&&i(e.isLastPage)&&a(e.currentPage)&&a(e.totalClustersCount);var j;e.FtEditorialType=void 0,(j=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",j.BOOK="BOOK",j.SHARED_BOOK="SHARED_BOOK";const G=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var q;e.FtOpenMode=void 0,(q=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",q.EXTERNAL="EXTERNAL";const X=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),Y=e=>r(e)&&(null==e.perPage||a(e.perPage))&&a(e.page);var z;e.FtCollectionDocumentType=void 0,(z=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",z.DOCUMENT="DOCUMENT",z.TOPIC="TOPIC",z.PERSONAL_BOOK="PERSONAL_BOOK",z.SHARED_BOOK="SHARED_BOOK";const W=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),J=e=>r(e)&&i(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>s(e)))&&s(e.label)&&s(e.key),Q=e=>r(e)&&a(e.weight)&&s(e.value)&&s(e.key),Z=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>ee(e)))&&(null==e.metadataVariableAxis||s(e.metadataVariableAxis)),ee=e=>r(e)&&(null==e.document||te(e.document))&&(null==e.topic||ie(e.topic))&&se(e.type)&&(null==e.map||re(e.map)),te=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&X(e.openMode)&&s(e.documentUrl)&&s(e.mimeType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.viewerUrl)&&s(e.contentUrl)&&s(e.filename)&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.documentId)&&s(e.lastEditionDate)&&s(e.htmlExcerpt),re=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&(null==e.openMode||X(e.openMode))&&G(e.editorialType)&&s(e.title)&&(null==e.lastPublicationDate||s(e.lastPublicationDate))&&s(e.htmlTitle)&&(null==e.originUrl||s(e.originUrl))&&s(e.mapUrl)&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt),ie=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&X(e.openMode)&&s(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>he(e)))&&s(e.title)&&s(e.mapTitle)&&s(e.topicUrl)&&s(e.contentUrl)&&s(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&(null==e.originUrl||s(e.originUrl))&&s(e.readerUrl)&&s(e.mapId)&&(null==e.lastEditionDate||s(e.lastEditionDate))&&s(e.htmlExcerpt);var ae;e.FtSearchResultType=void 0,(ae=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",ae.DOCUMENT="DOCUMENT",ae.TOPIC="TOPIC";const se=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var ne;e.FtSearchScope=void 0,(ne=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",ne.DOCUMENTS="DOCUMENTS",ne.ALL_TOPICS="ALL_TOPICS";const oe=e=>["DEFAULT","DOCUMENTS","ALL_TOPICS"].includes(e),le=e=>r(e)&&i(e.hierarchical)&&s(e.label)&&i(e.multiSelectionable)&&s(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>ce(e))),ue=e=>r(e)&&(null==e.maxDepth||a(e.maxDepth))&&s(e.id),ce=e=>r(e)&&a(e.totalResultsCount)&&i(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>ce(e)))&&s(e.label)&&s(e.value)&&i(e.selected),de=e=>r(e)&&x(e.type)&&s(e.key)&&B(e.order),pe=e=>r(e)&&s(e.suggestedQuery)&&s(e.htmlSuggestedQuery),he=e=>r(e)&&s(e.filename)&&s(e.resourceUrl)&&s(e.id)&&s(e.mimeType)&&s(e.resourceContentUrl)&&s(e.viewerUrl),ye=e=>r(e)&&(null==e.filenameExtension||s(e.filenameExtension))&&(null==e.editorialType||G(e.editorialType))&&(null==e.mimeType||s(e.mimeType))&&se(e.type)&&s(e.value);var fe;e.FtUserRole=void 0,(fe=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",fe.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",fe.HTML_EXPORT_USER="HTML_EXPORT_USER",fe.PDF_EXPORT_USER="PDF_EXPORT_USER",fe.SAVED_SEARCH_USER="SAVED_SEARCH_USER",fe.COLLECTION_USER="COLLECTION_USER",fe.OFFLINE_USER="OFFLINE_USER",fe.ANALYTICS_USER="ANALYTICS_USER",fe.BETA_USER="BETA_USER",fe.DEBUG_USER="DEBUG_USER",fe.PRINT_USER="PRINT_USER",fe.RATING_USER="RATING_USER",fe.FEEDBACK_USER="FEEDBACK_USER",fe.CONTENT_PUBLISHER="CONTENT_PUBLISHER",fe.KHUB_ADMIN="KHUB_ADMIN",fe.USERS_ADMIN="USERS_ADMIN",fe.PORTAL_ADMIN="PORTAL_ADMIN",fe.ADMIN="ADMIN",fe.DEVELOPER="DEVELOPER";const Ae=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),me=e=>r(e)&&s(e.identifier)&&s(e.realm),Ee=e=>r(e)&&Array.isArray(e.defaultFilters)&&e.defaultFilters.every((e=>k(e))),ge=e=>r(e)&&(null==e.emailAddress||s(e.emailAddress))&&(null==e.displayName||s(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>Ae(e)))&&(null==e.userId||s(e.userId)),be=e=>"object"==typeof e&&null!=e,Te=e=>"boolean"==typeof e,Se=e=>"number"==typeof e,Re=e=>"string"==typeof e;var Fe;e.FtConfigurationHistoryEntryStatus=void 0,(Fe=e.FtConfigurationHistoryEntryStatus||(e.FtConfigurationHistoryEntryStatus={})).VALID="VALID",Fe.INVALID="INVALID";const Oe=e=>be(e)&&Te(e.mailsSentByFluidTopics)&&Te(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>Re(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>Re(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>Re(e))),Ue=e=>be(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>Te(e))))&&Te(e.isVisible),Ie=e=>be(e)&&(null==e.prettyUrl||Re(e.prettyUrl))&&(null==e.hasRating||Te(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||Re(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>Ie(e)))&&(null==e.pageConfiguration||Ue(e.pageConfiguration))&&(null==e.contentId||Re(e.contentId))&&(null==e.title||Re(e.title)),ve=e=>be(e)&&Te(e.splitCurrentPageToc),_e={[e.FtUserRole.PERSONAL_BOOK_SHARE_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.HTML_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.PDF_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.KHUB_ADMIN]:[e.FtUserRole.CONTENT_PUBLISHER],[e.FtUserRole.ADMIN]:[e.FtUserRole.KHUB_ADMIN,e.FtUserRole.USERS_ADMIN,e.FtUserRole.PORTAL_ADMIN],[e.FtUserRole.DEVELOPER]:[e.FtUserRole.BETA_USER,e.FtUserRole.DEBUG_USER]};function Ce(e,t){return e===t||(_e[e]??[]).some((e=>Ce(e,t)))}const Le="undefined"==typeof window?globalThis:window;function De(e){let t={};for(let r in e){let i=e[r];("object"!=typeof i||Array.isArray(i))&&(i={prior:i});for(let e of["prior","filter"])i[e]=Array.isArray(i[e])?i[e]:[i[e]],i[e]=i[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=i}return t}function Pe(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const Ne="undefined"==typeof window?globalThis:window;class Me extends Error{method;endpoint;status;statusText;body;constructor(e,t,r,i,a){super(`${e} ${t} -> ${r} - ${i}: ${a}`),this.method=e,this.endpoint=t,this.status=r,this.statusText=i,this.body=a}}class ke extends CustomEvent{constructor(e){super("ft-api-http-error",{detail:e})}}async function we(e,t,r){if(!r.ok){let i={method:e,endpoint:t,status:r.status,statusText:r.statusText,body:await r.text()};throw"function"==typeof Ne.dispatchEvent&&Ne.dispatchEvent(new ke(i)),new Me(i.method,i.endpoint,i.status,i.statusText,i.body)}return r}function Be(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class He{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})},searches:{list:`api/users/${e}/searches`},bookmarks:{list:`api/users/${e}/bookmarks`}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader",metadata:"api/configuration/metadata"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??Ne.fluidTopicsBaseUrl??Ne.__gwt_ft_moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",r&&void 0!==Ne.location&&Ne.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e,t){return this.get(this.endpoints.khub.maps.mapId(e).info,t)}getTableOfContent(e,t){return this.get(this.endpoints.khub.maps.mapId(e).toc,t)}getPages(e,t){return this.get(this.endpoints.khub.maps.mapId(e).pages,t)}getTopic(e,t,r){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info,r)}getTopicHTMLContent(e,t,r,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(r?"?target="+r:""),i)}getMapAttachments(e,t){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list,t)}getMapAttachmentContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content,r)}getMapResources(e,t){return this.get(this.endpoints.khub.maps.mapId(e).resources.list,t)}getMapResourceContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content,r)}getUnstructuredDocument(e,t){return this.get(this.endpoints.khub.documents.documentId(e).info,t)}getUnstructuredDocumentContent(e,t){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content,t)}getUnstructuredDocumentTextContent(e,t){return this.get(this.endpoints.khub.documents.documentId(e).text,t)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.khub.locales)}getMetadataConfiguration(){return this.get(this.endpoints.configuration.metadata)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:r})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t,from:r})}rateTopic(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:i})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:r})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t,from:r})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}getCustomMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).custom.contextName(t).endpoint)}listMySearches(e){return this.get(this.endpoints.users.userId(e).searches.list)}listMyBookmarks(e){return this.get(this.endpoints.users.userId(e).bookmarks.list)}get(e,t){return this.makeRequest("GET",this.withVersion(e,t))}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return e.startsWith(this.tenantBaseUrl)?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await fetch(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,i=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,s)=>{let n=new XMLHttpRequest;n.onload=()=>{if(n.status>=200&&n.status<300){let e="application/json"===n.getResponseHeader("Content-Type")?JSON.parse(n.responseText):n.responseText;a(e)}else s(new Me("GET",t,n.status,n.statusText,n.responseText))},n.upload.onprogress=e=>i(e),n.open(e,this.makeAbsolute(t),!0),n.send(r)})):this.fetch(t,{method:e,body:r}).then((r=>we(e,t,r))).then(Be)}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0,credentials:null==this.authorization?"include":void 0}).then((r=>we(e,t,r))).then(Be)}fetchRawData(e,t){return fetch(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then((t=>we("GET",e,t))).then((e=>e.arrayBuffer()))}withVersion(e,t){let r=new URL(this.makeAbsolute(e));return t&&r.searchParams.append("v",t),r.toString()}}e.FluidTopicsApi=He,e.HttpError=Me,e.HttpErrorEvent=ke,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(Le.localStorage){const r=Pe(e),i=e=>{e.storageArea===Le.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return Le.addEventListener("storage",i),{removeHandler:()=>Le.removeEventListener("storage",i)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=He,e.getUnauthenticatedUserSearchPreferences=function(e){if(Le.localStorage)return JSON.parse(Le.localStorage.getItem(Pe(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>r(e)&&me(e.authenticationIdentifier)&&ge(e.profile),e.isFtAuthenticationIdentifier=me,e.isFtBookmark=e=>r(e)&&s(e.mapTitle)&&o(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>s(e)))&&s(e.tocId)&&s(e.lastUpdate)&&s(e.readerUrl)&&s(e.mapId)&&s(e.id)&&s(e.title)&&s(e.creationDate),e.isFtCollectionDocument=e=>r(e)&&i(e.deleted)&&(null==e.apiUrl||s(e.apiUrl))&&(null==e.portalUrl||s(e.portalUrl))&&s(e.id)&&s(e.title)&&W(e.type),e.isFtCollectionDocumentType=W,e.isFtConfigurationHistoryEntryStatus=e=>["VALID","INVALID"].includes(e),e.isFtCredentials=e=>r(e)&&s(e.password)&&(null==e.newPassword||s(e.newPassword))&&i(e.rememberMe)&&s(e.login),e.isFtEditorialType=G,e.isFtFacetType=e=>["AND","OR","MONOVALUED"].includes(e),e.isFtFeedbackCreation=e=>r(e)&&(null==e.from||s(e.from))&&s(e.message),e.isFtHttpErrorDetails=e=>r(e)&&s(e.endpoint)&&s(e.method)&&s(e.statusText)&&s(e.body)&&a(e.status),e.isFtLabeledSearchFilter=J,e.isFtMap=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&X(e.openMode)&&(null==e.topicsApiEndpoint||s(e.topicsApiEndpoint))&&(null==e.description||s(e.description))&&(null==e.attachmentsApiEndpoint||s(e.attachmentsApiEndpoint))&&G(e.editorialType)&&s(e.baseId)&&s(e.clusterId)&&s(e.title)&&s(e.lastPublication)&&s(e.lastEdition)&&s(e.originId)&&(null==e.rightsApiEndpoint||s(e.rightsApiEndpoint))&&h(e.contentStyles)&&(null==e.originUrl||s(e.originUrl))&&s(e.fingerprint)&&s(e.readerUrl)&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtMapAttachment=e=>be(e)&&Re(e.file)&&(null==e.size||Se(e.size))&&Te(e.externalLink)&&Re(e.name)&&Re(e.id)&&(null==e.mimeType||Re(e.mimeType))&&(null==e.viewerUrl||Re(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&s(e.contentUrl)&&s(e.filename)&&s(e.id)&&s(e.mimeType),e.isFtMapStyles=h,e.isFtMessageContext=e=>r(e)&&s(e.name)&&r(e.messages)&&Object.keys(e.messages).every((e=>s(e)))&&Object.values(e.messages).every((e=>s(e)))&&s(e.locale),e.isFtMetadata=b,e.isFtMetadataConfiguration=e=>r(e)&&Array.isArray(e.descriptors)&&e.descriptors.every((e=>R(e))),e.isFtMetadataDescriptor=R,e.isFtMetadataHomeLayout=e=>["CLASSIC","CUSTOM","DESIGNER"].includes(e),e.isFtMetadataPreferenceConfiguration=L,e.isFtMetadataSortRule=S,e.isFtMyLibraryColors=o,e.isFtMySearch=e=>r(e)&&F(e.searchRequest)&&o(e.color)&&i(e.alert)&&s(e.description)&&s(e.id)&&s(e.ownerId)&&s(e.title)&&s(e.creationDate),e.isFtMySearchRequest=F,e.isFtOpenMode=X,e.isFtPageConfiguration=Ue,e.isFtPageRequest=Y,e.isFtPaginatedToc=e=>be(e)&&ve(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>Ie(e))),e.isFtPaginatedTocNode=Ie,e.isFtPaginationConfiguration=ve,e.isFtPeriod=D,e.isFtPeriodFilter=P,e.isFtPeriodFilterType=M,e.isFtPersonalBookCreation=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>c(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>d(e)))&&s(e.description)&&s(e.title),e.isFtPersonalBookMetadataUpdate=c,e.isFtPersonalBookNodeCreation=d,e.isFtPersonalBookTopicLinkCreation=p,e.isFtPublicationRating=I,e.isFtPublicationRatingSummary=v,e.isFtRatingCreation=e=>r(e)&&U(e.type)&&a(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||C(e.topics))&&v(e.publication),e.isFtRatingType=U,e.isFtReaderConfiguration=e=>be(e)&&Oe(e.feedback)&&Se(e.loadAfterLastVisibleTopic)&&Se(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=Oe,e.isFtSearchFacet=le,e.isFtSearchFacetConf=ue,e.isFtSearchFacetEntry=ce,e.isFtSearchFilter=k,e.isFtSearchLocale=E,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>E(e))),e.isFtSearchPreferences=Ee,e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>s(e)))&&Object.values(e.metadata).every((e=>L(e))),e.isFtSearchPreset=e=>r(e)&&s(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&a(e.priority)&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSearchPrior=Q,e.isFtSearchRequest=e=>r(e)&&(null==e.periodFilter||P(e.periodFilter))&&s(e.query)&&(null==e.scope||oe(e.scope))&&Y(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.uiLocale||s(e.uiLocale))&&(null==e.virtualField||$(e.virtualField))&&(null==e.contentLocale||s(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>Q(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>ue(e))),e.isFtSearchResultCluster=Z,e.isFtSearchResultClusterEntry=ee,e.isFtSearchResultMap=re,e.isFtSearchResultTopic=ie,e.isFtSearchResultType=se,e.isFtSearchResultUnstructuredDocument=te,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||pe(e.spellcheck))&&K(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>Z(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>le(e))),e.isFtSearchResultsPageInfo=K,e.isFtSearchScope=oe,e.isFtSearchSortCriterion=de,e.isFtSearchSortCriterionOrder=B,e.isFtSearchSortCriterionType=x,e.isFtSession=e=>r(e)&&(null==e.authenticationIdentifier||me(e.authenticationIdentifier))&&a(e.idleTimeoutInMillis)&&ge(e.profile)&&i(e.sessionAuthenticated)&&Ee(e.searchPreferences),e.isFtSpellcheck=pe,e.isFtSuggestRequest=e=>r(e)&&s(e.input)&&(null==e.scope||oe(e.scope))&&Array.isArray(e.filters)&&e.filters.every((e=>k(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>de(e)))&&(null==e.maxCount||a(e.maxCount))&&(null==e.contentLocale||s(e.contentLocale)),e.isFtSuggestResult=ye,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>ye(e))),e.isFtTocNode=y,e.isFtTopic=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&s(e.id)&&s(e.contentApiEndpoint)&&s(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=f,e.isFtTopicOriginType=u,e.isFtTopicRating=_,e.isFtTopicResource=he,e.isFtTopicsRatingSummary=C,e.isFtUiLocale=e=>r(e)&&s(e.displayName)&&s(e.languageTag)&&i(e.translated),e.isFtUnstructuredDocument=e=>r(e)&&(null==e.prettyUrl||s(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>b(e)))&&s(e.openMode)&&(null==e.description||s(e.description))&&s(e.mimeType)&&(null==e.baseId||s(e.baseId))&&(null==e.clusterId||s(e.clusterId))&&s(e.contentApiEndpoint)&&s(e.title)&&(null==e.lastPublication||s(e.lastPublication))&&s(e.viewerUrl)&&s(e.lastEdition)&&s(e.filename)&&(null==e.originId||s(e.originId))&&s(e.rightsApiEndpoint)&&(null==e.originUrl||s(e.originUrl))&&(null==e.khubVersion||s(e.khubVersion))&&s(e.id)&&(null==e.lang||s(e.lang)),e.isFtUserProfile=ge,e.isFtUserRole=Ae,e.isFtVirtualField=$,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(Le.localStorage){let r={...t,metadata:De(t.metadata??{})};const i=Pe(e),a=JSON.stringify(r);return Le.localStorage.setItem(i,a),Le.dispatchEvent(new StorageEvent("storage",{key:i,newValue:a,storageArea:Le.localStorage,url:Le.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")},e.userHasRole=function(e,t){return null!=e&&(Array.isArray(e)?e:Array.isArray(e.roles)?e.roles:Array.isArray(e.profile?.roles)?e.profile.roles:[]).some((e=>Ce(e,t)))}}));
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import "cross-fetch/polyfill";
|
|
2
|
-
import { FtAuthenticatedSession, FtBookmark, FtCollectionDocument, FtMap, FtMapResource, FtMessageContext, FtMetadataConfiguration, FtMySearch, FtRatingSummary, FtRatingType, FtRatingTypeKeys, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSession, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUiLocale, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
2
|
+
import { FtAuthenticatedSession, FtBookmark, FtCollectionDocument, FtHttpErrorDetails, FtMap, FtMapResource, FtMessageContext, FtMetadataConfiguration, FtMySearch, FtRatingSummary, FtRatingType, FtRatingTypeKeys, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSession, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUiLocale, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
3
3
|
import { FtMapAttachment, FtPaginatedToc, FtReaderConfiguration } from "./types/ft-server/public";
|
|
4
4
|
export * from "./types/ft-common/public";
|
|
5
5
|
export * from "./types/ft-server/public";
|
|
6
6
|
export * from "./roles/roles";
|
|
7
7
|
export * from "./preferences/unauthenticated-preferences";
|
|
8
8
|
export declare class HttpError extends Error {
|
|
9
|
+
readonly method: string;
|
|
10
|
+
readonly endpoint: string;
|
|
9
11
|
readonly status: number;
|
|
10
12
|
readonly statusText: string;
|
|
11
13
|
readonly body: string;
|
|
12
|
-
constructor(status: number, statusText: string, body: string);
|
|
14
|
+
constructor(method: string, endpoint: string, status: number, statusText: string, body: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class HttpErrorEvent extends CustomEvent<FtHttpErrorDetails> {
|
|
17
|
+
constructor(e: FtHttpErrorDetails);
|
|
13
18
|
}
|
|
14
19
|
export declare class FluidTopicsApi {
|
|
15
20
|
readonly tenantBaseUrl: string;
|
package/dist/mjs/index.js
CHANGED
|
@@ -8,19 +8,38 @@ function toBase64(s) {
|
|
|
8
8
|
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
9
9
|
}
|
|
10
10
|
export class HttpError extends Error {
|
|
11
|
+
method;
|
|
12
|
+
endpoint;
|
|
11
13
|
status;
|
|
12
14
|
statusText;
|
|
13
15
|
body;
|
|
14
|
-
constructor(status, statusText, body) {
|
|
15
|
-
super(`${status} - ${statusText}: ${body}`);
|
|
16
|
+
constructor(method, endpoint, status, statusText, body) {
|
|
17
|
+
super(`${method} ${endpoint} -> ${status} - ${statusText}: ${body}`);
|
|
18
|
+
this.method = method;
|
|
19
|
+
this.endpoint = endpoint;
|
|
16
20
|
this.status = status;
|
|
17
21
|
this.statusText = statusText;
|
|
18
22
|
this.body = body;
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
|
|
25
|
+
export class HttpErrorEvent extends CustomEvent {
|
|
26
|
+
constructor(e) {
|
|
27
|
+
super("ft-api-http-error", { detail: e });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function handleError(method, endpoint, response) {
|
|
22
31
|
if (!response.ok) {
|
|
23
|
-
|
|
32
|
+
let details = {
|
|
33
|
+
method,
|
|
34
|
+
endpoint,
|
|
35
|
+
status: response.status,
|
|
36
|
+
statusText: response.statusText,
|
|
37
|
+
body: await response.text()
|
|
38
|
+
};
|
|
39
|
+
if (typeof wnd.dispatchEvent === "function") {
|
|
40
|
+
wnd.dispatchEvent(new HttpErrorEvent(details));
|
|
41
|
+
}
|
|
42
|
+
throw new HttpError(details.method, details.endpoint, details.status, details.statusText, details.body);
|
|
24
43
|
}
|
|
25
44
|
return response;
|
|
26
45
|
}
|
|
@@ -137,7 +156,7 @@ export class FluidTopicsApi {
|
|
|
137
156
|
}
|
|
138
157
|
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
139
158
|
//@ts-ignore
|
|
140
|
-
tenantBaseUrl = (tenantBaseUrl ?? wnd.
|
|
159
|
+
tenantBaseUrl = (tenantBaseUrl ?? wnd.fluidTopicsBaseUrl ?? wnd.__gwt_ft_moduleBase ?? "").trim();
|
|
141
160
|
this.tenantBaseUrl = tenantBaseUrl.endsWith("/") ? tenantBaseUrl : tenantBaseUrl + "/";
|
|
142
161
|
if (overrideIdentifierIfOnTenant && typeof wnd.location !== "undefined" && wnd.location.href.startsWith(this.tenantBaseUrl)) {
|
|
143
162
|
this.ftCallingApp = integrationIdentifier;
|
|
@@ -319,7 +338,7 @@ export class FluidTopicsApi {
|
|
|
319
338
|
resolve(data);
|
|
320
339
|
}
|
|
321
340
|
else {
|
|
322
|
-
reject(new HttpError(xhr.status, xhr.statusText, xhr.responseText));
|
|
341
|
+
reject(new HttpError("GET", endpoint, xhr.status, xhr.statusText, xhr.responseText));
|
|
323
342
|
}
|
|
324
343
|
};
|
|
325
344
|
xhr.upload.onprogress = (e) => onProgress(e);
|
|
@@ -328,7 +347,9 @@ export class FluidTopicsApi {
|
|
|
328
347
|
});
|
|
329
348
|
}
|
|
330
349
|
else {
|
|
331
|
-
return this.fetch(endpoint, { method, body })
|
|
350
|
+
return this.fetch(endpoint, { method, body })
|
|
351
|
+
.then((r) => handleError(method, endpoint, r))
|
|
352
|
+
.then(getBody);
|
|
332
353
|
}
|
|
333
354
|
}
|
|
334
355
|
makeRequest(method, endpoint, data) {
|
|
@@ -340,7 +361,7 @@ export class FluidTopicsApi {
|
|
|
340
361
|
body: data != null ? JSON.stringify(data) : undefined,
|
|
341
362
|
credentials: this.authorization == null ? "include" : undefined
|
|
342
363
|
})
|
|
343
|
-
.then(handleError)
|
|
364
|
+
.then((r) => handleError(method, endpoint, r))
|
|
344
365
|
.then(getBody);
|
|
345
366
|
}
|
|
346
367
|
fetchRawData(endpoint, v) {
|
|
@@ -348,7 +369,7 @@ export class FluidTopicsApi {
|
|
|
348
369
|
headers: this.defaultHeaders,
|
|
349
370
|
credentials: this.authorization == null ? "include" : undefined
|
|
350
371
|
})
|
|
351
|
-
.then(handleError)
|
|
372
|
+
.then((r) => handleError("GET", endpoint, r))
|
|
352
373
|
.then(response => response.arrayBuffer());
|
|
353
374
|
}
|
|
354
375
|
withVersion(endpoint, v) {
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export interface FtHttpErrorDetails {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
method: string;
|
|
4
|
+
statusText: string;
|
|
5
|
+
body: string;
|
|
6
|
+
status: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const isFtHttpErrorDetails: (o: any) => o is FtHttpErrorDetails;
|
|
1
9
|
export declare enum FtMyLibraryColors {
|
|
2
10
|
black = "black",
|
|
3
11
|
green = "green",
|
|
@@ -2,6 +2,14 @@ const isObject = (o) => typeof o === "object" && o != null;
|
|
|
2
2
|
const isBoolean = (o) => typeof o === "boolean";
|
|
3
3
|
const isNumber = (o) => typeof o === "number";
|
|
4
4
|
const isString = (o) => typeof o === "string";
|
|
5
|
+
export const isFtHttpErrorDetails = (o) => {
|
|
6
|
+
return isObject(o)
|
|
7
|
+
&& (isString(o.endpoint))
|
|
8
|
+
&& (isString(o.method))
|
|
9
|
+
&& (isString(o.statusText))
|
|
10
|
+
&& (isString(o.body))
|
|
11
|
+
&& (isNumber(o.status));
|
|
12
|
+
};
|
|
5
13
|
// From: MyLibraryColors
|
|
6
14
|
export var FtMyLibraryColors;
|
|
7
15
|
(function (FtMyLibraryColors) {
|