@fluid-topics/ft-search-context 1.1.36 → 1.1.38
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/build/ft-search-context.d.ts +2 -0
- package/build/ft-search-context.js +5 -1
- package/build/ft-search-context.light.js +4 -4
- package/build/ft-search-context.min.js +17 -17
- package/build/store/FtSearchStateManager.d.ts +4 -6
- package/build/store/FtSearchStateManager.js +8 -14
- package/build/store/utils/FtSearchService.d.ts +4 -6
- package/build/store/utils/FtSearchService.js +4 -9
- package/package.json +4 -4
|
@@ -3,6 +3,7 @@ import { ElementDefinitionsMap, FtLitElementRedux, FtRegistrationContext } from
|
|
|
3
3
|
import { FtSearchContextProperties } from "./ft-search-context.properties";
|
|
4
4
|
import { FtSearchComponentInterface, FtSearchResultsChangeEventDetail } from "./registration";
|
|
5
5
|
import { FtSearchFilter, FtSearchRequest, FtSearchResultsPageInfo, FtSearchScope, FtSearchSortCriterion, FtSpellcheck } from "@fluid-topics/public-api";
|
|
6
|
+
import { FtSearchService } from "./store/utils/FtSearchService";
|
|
6
7
|
export declare class LoadErrorEvent extends CustomEvent<Error> {
|
|
7
8
|
constructor(e: Error);
|
|
8
9
|
}
|
|
@@ -28,6 +29,7 @@ export declare class FtSearchContext extends FtLitElementRedux implements FtSear
|
|
|
28
29
|
private paging?;
|
|
29
30
|
private autocorrect?;
|
|
30
31
|
private session?;
|
|
32
|
+
searchServiceProvider?: () => FtSearchService;
|
|
31
33
|
private _stateManager?;
|
|
32
34
|
private get stateManager();
|
|
33
35
|
constructor();
|
|
@@ -29,7 +29,8 @@ export class SearchResultsChangeEvent extends CustomEvent {
|
|
|
29
29
|
class FtSearchContext extends FtLitElementRedux {
|
|
30
30
|
get stateManager() {
|
|
31
31
|
if (this._stateManager == null) {
|
|
32
|
-
|
|
32
|
+
const service = this.searchServiceProvider ? this.searchServiceProvider() : undefined;
|
|
33
|
+
this._stateManager = FtSearchStateManager.build(this.id || ("" + Math.round(Math.random() * 999000)).padStart(6, "0"), service);
|
|
33
34
|
this._stateManager.errorHandler = (e) => this.handleLoadError(e);
|
|
34
35
|
this.addStore(this.stateManager.store, "search");
|
|
35
36
|
}
|
|
@@ -161,4 +162,7 @@ __decorate([
|
|
|
161
162
|
__decorate([
|
|
162
163
|
redux({ store: ftAppInfoStore.name })
|
|
163
164
|
], FtSearchContext.prototype, "session", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
property({ attribute: false })
|
|
167
|
+
], FtSearchContext.prototype, "searchServiceProvider", void 0);
|
|
164
168
|
export { FtSearchContext };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
!function(t,i,s,e){const n=s.css`
|
|
2
|
-
`,r={setRequest:(t,i)=>{t.request=i.payload},setRequestQuery:(t,i)=>{t.request.query=i.payload},setRequestContentLocale:(t,i)=>{t.request.contentLocale=i.payload},setPageSize:(t,i)=>{t.request.paging.perPage=i.payload},setPageNumber:(t,i)=>{t.request.paging.page=i.payload},setRequestSort:(t,i)=>{t.request.sort=i.payload},setRequestFilters:(t,i)=>{t.request.filters=i.payload},setRequestFacets:(t,i)=>{t.request.facets=i.payload},setRequestVirtualField:(t,i)=>{t.request.virtualField=i.payload},setRequestScope:(t,i)=>{t.request.scope=i.payload},setResults:(t,i)=>{t.results=i.payload},setFacets:(t,i)=>{t.facets=i.payload},setSpellcheck:(t,i)=>{t.spellcheck=i.payload},setLocales:(t,i)=>{t.locales=i.payload},setPaging:(t,i)=>{t.paging=i.payload},setLiveQuery:(t,i)=>{t.liveQuery=i.payload},setSuggestResults:(t,i)=>{t.suggestResults=i.payload}};var o,a,h,c,u,l,d,f,v,w,y,E,S,p,b,A,m,g;!function(t){!function(i){var s={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(s.arrayBuffer)var e=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(t){return t&&e.indexOf(Object.prototype.toString.call(t))>-1};function r(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var i={next:function(){var i=t.shift();return{done:void 0===i,value:i}}};return s.iterable&&(i[Symbol.iterator]=function(){return i}),i}function h(t){this.map={},t instanceof h?t.forEach((function(t,i){this.append(i,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(i){this.append(i,t[i])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise((function(i,s){t.onload=function(){i(t.result)},t.onerror=function(){s(t.error)}}))}function l(t){var i=new FileReader,s=u(i);return i.readAsArrayBuffer(t),s}function d(t){if(t.slice)return t.slice(0);var i=new Uint8Array(t.byteLength);return i.set(new Uint8Array(t)),i.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(t){var i;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:s.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s.arrayBuffer&&s.blob&&((i=t)&&DataView.prototype.isPrototypeOf(i))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||n(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s.blob&&(this.blob=function(){var t=c(this);if(t)return t;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?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t,i,s,e=c(this);if(e)return e;if(this._bodyBlob)return t=this._bodyBlob,i=new FileReader,s=u(i),i.readAsText(t),s;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var i=new Uint8Array(t),s=new Array(i.length),e=0;e<i.length;e++)s[e]=String.fromCharCode(i[e]);return s.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,i){t=r(t),i=o(i);var s=this.map[t];this.map[t]=s?s+", "+i:i},h.prototype.delete=function(t){delete this.map[r(t)]},h.prototype.get=function(t){return t=r(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(r(t))},h.prototype.set=function(t,i){this.map[r(t)]=o(i)},h.prototype.forEach=function(t,i){for(var s in this.map)this.map.hasOwnProperty(s)&&t.call(i,this.map[s],s,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(i,s){t.push(s)})),a(t)},h.prototype.values=function(){var t=[];return this.forEach((function(i){t.push(i)})),a(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(i,s){t.push([s,i])})),a(t)},s.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,i){var s,e,n=(i=i||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,i.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=i.credentials||this.credentials||"same-origin",!i.headers&&this.headers||(this.headers=new h(i.headers)),this.method=(s=i.method||this.method||"GET",e=s.toUpperCase(),v.indexOf(e)>-1?e:s),this.mode=i.mode||this.mode||null,this.signal=i.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function y(t){var i=new FormData;return t.trim().split("&").forEach((function(t){if(t){var s=t.split("="),e=s.shift().replace(/\+/g," "),n=s.join("=").replace(/\+/g," ");i.append(decodeURIComponent(e),decodeURIComponent(n))}})),i}function E(t,i){i||(i={}),this.type="default",this.status=void 0===i.status?200:i.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in i?i.statusText:"OK",this.headers=new h(i.headers),this.url=i.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},f.call(w.prototype),f.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:0,statusText:""});return t.type="error",t};var S=[301,302,303,307,308];E.redirect=function(t,i){if(-1===S.indexOf(i))throw new RangeError("Invalid status code");return new E(null,{status:i,headers:{location:t}})},i.DOMException=t.DOMException;try{new i.DOMException}catch(t){i.DOMException=function(t,i){this.message=t,this.name=i;var s=Error(t);this.stack=s.stack},i.DOMException.prototype=Object.create(Error.prototype),i.DOMException.prototype.constructor=i.DOMException}function p(t,e){return new Promise((function(n,r){var o=new w(t,e);if(o.signal&&o.signal.aborted)return r(new i.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t,i,s={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",i=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var s=t.split(":"),e=s.shift().trim();if(e){var n=s.join(":").trim();i.append(e,n)}})),i)};s.url="responseURL"in a?a.responseURL:s.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;n(new E(e,s))},a.onerror=function(){r(new TypeError("Network request failed"))},a.ontimeout=function(){r(new TypeError("Network request failed"))},a.onabort=function(){r(new i.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&s.blob&&(a.responseType="blob"),o.headers.forEach((function(t,i){a.setRequestHeader(i,t)})),o.signal&&(o.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",c)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}p.polyfill=!0,t.fetch||(t.fetch=p,t.Headers=h,t.Request=w,t.Response=E),i.Headers=h,i.Request=w,i.Response=E,i.fetch=p,Object.defineProperty(i,"t",{value:!0})}({})}("undefined"!=typeof self?self:void 0),function(t){t.black="black",t.green="green",t.blue="blue",t.purple="purple",t.red="red",t.orange="orange",t.yellow="yellow"}(o||(o={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(a||(a={})),function(t){t.THIRD_PARTY="THIRD_PARTY",t.OFF_THE_GRID="OFF_THE_GRID",t.CONTENT_PACKAGER="CONTENT_PACKAGER",t.PAGES="PAGES",t.DESIGNED_READER="DESIGNED_READER"}(h||(h={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(c||(c={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(u||(u={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(l||(l={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(d||(d={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(f||(f={})),function(t){t.ASC="ASC",t.DESC="DESC"}(v||(v={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(w||(w={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(y||(y={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(E||(E={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(S||(S={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(p||(p={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(b||(b={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(A||(A={})),function(t){t.PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",t.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",t.HTML_EXPORT_USER="HTML_EXPORT_USER",t.PDF_EXPORT_USER="PDF_EXPORT_USER",t.SAVED_SEARCH_USER="SAVED_SEARCH_USER",t.COLLECTION_USER="COLLECTION_USER",t.OFFLINE_USER="OFFLINE_USER",t.ANALYTICS_USER="ANALYTICS_USER",t.BETA_USER="BETA_USER",t.DEBUG_USER="DEBUG_USER",t.PRINT_USER="PRINT_USER",t.RATING_USER="RATING_USER",t.FEEDBACK_USER="FEEDBACK_USER",t.GENERATIVE_AI_USER="GENERATIVE_AI_USER",t.CONTENT_PUBLISHER="CONTENT_PUBLISHER",t.KHUB_ADMIN="KHUB_ADMIN",t.USERS_ADMIN="USERS_ADMIN",t.PORTAL_ADMIN="PORTAL_ADMIN",t.ADMIN="ADMIN",t.DEVELOPER="DEVELOPER"}(m||(m={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(g||(g={})),m.PERSONAL_BOOK_SHARE_USER,m.PERSONAL_BOOK_USER,m.HTML_EXPORT_USER,m.PERSONAL_BOOK_USER,m.PDF_EXPORT_USER,m.PERSONAL_BOOK_USER,m.KHUB_ADMIN,m.CONTENT_PUBLISHER,m.ADMIN,m.KHUB_ADMIN,m.USERS_ADMIN,m.PORTAL_ADMIN,m.DEVELOPER,m.BETA_USER,m.DEBUG_USER;const R=s.css`
|
|
3
|
-
`,O=i.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0}});class T{static build(t){const{baseUrl:i,apiIntegrationIdentifier:s}=O.getState(),e=null!=t?t:s;if(i&&e&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(i,e,!0)}static get(t){var i;return null!=t?T.build(t):null!==(i=T.API)&&void 0!==i?i:T.API=T.build()}static await(t){return new Promise((i=>{let s=T.get(t);if(s)i(s);else{const e=O.subscribe((()=>{s=T.get(t),s&&(e(),i(s))}))}}))}}var
|
|
2
|
+
`,r={setRequest:(t,i)=>{t.request=i.payload},setRequestQuery:(t,i)=>{t.request.query=i.payload},setRequestContentLocale:(t,i)=>{t.request.contentLocale=i.payload},setPageSize:(t,i)=>{t.request.paging.perPage=i.payload},setPageNumber:(t,i)=>{t.request.paging.page=i.payload},setRequestSort:(t,i)=>{t.request.sort=i.payload},setRequestFilters:(t,i)=>{t.request.filters=i.payload},setRequestFacets:(t,i)=>{t.request.facets=i.payload},setRequestVirtualField:(t,i)=>{t.request.virtualField=i.payload},setRequestScope:(t,i)=>{t.request.scope=i.payload},setResults:(t,i)=>{t.results=i.payload},setFacets:(t,i)=>{t.facets=i.payload},setSpellcheck:(t,i)=>{t.spellcheck=i.payload},setLocales:(t,i)=>{t.locales=i.payload},setPaging:(t,i)=>{t.paging=i.payload},setLiveQuery:(t,i)=>{t.liveQuery=i.payload},setSuggestResults:(t,i)=>{t.suggestResults=i.payload}};var o,a,h,c,u,l,d,f,v,w,y,E,p,S,b,A,m,g;!function(t){!function(i){var s={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(s.arrayBuffer)var e=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(t){return t&&e.indexOf(Object.prototype.toString.call(t))>-1};function r(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var i={next:function(){var i=t.shift();return{done:void 0===i,value:i}}};return s.iterable&&(i[Symbol.iterator]=function(){return i}),i}function h(t){this.map={},t instanceof h?t.forEach((function(t,i){this.append(i,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(i){this.append(i,t[i])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise((function(i,s){t.onload=function(){i(t.result)},t.onerror=function(){s(t.error)}}))}function l(t){var i=new FileReader,s=u(i);return i.readAsArrayBuffer(t),s}function d(t){if(t.slice)return t.slice(0);var i=new Uint8Array(t.byteLength);return i.set(new Uint8Array(t)),i.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(t){var i;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:s.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s.arrayBuffer&&s.blob&&((i=t)&&DataView.prototype.isPrototypeOf(i))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||n(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s.blob&&(this.blob=function(){var t=c(this);if(t)return t;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?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t,i,s,e=c(this);if(e)return e;if(this._bodyBlob)return t=this._bodyBlob,i=new FileReader,s=u(i),i.readAsText(t),s;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var i=new Uint8Array(t),s=new Array(i.length),e=0;e<i.length;e++)s[e]=String.fromCharCode(i[e]);return s.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,i){t=r(t),i=o(i);var s=this.map[t];this.map[t]=s?s+", "+i:i},h.prototype.delete=function(t){delete this.map[r(t)]},h.prototype.get=function(t){return t=r(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(r(t))},h.prototype.set=function(t,i){this.map[r(t)]=o(i)},h.prototype.forEach=function(t,i){for(var s in this.map)this.map.hasOwnProperty(s)&&t.call(i,this.map[s],s,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(i,s){t.push(s)})),a(t)},h.prototype.values=function(){var t=[];return this.forEach((function(i){t.push(i)})),a(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(i,s){t.push([s,i])})),a(t)},s.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,i){var s,e,n=(i=i||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,i.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=i.credentials||this.credentials||"same-origin",!i.headers&&this.headers||(this.headers=new h(i.headers)),this.method=(s=i.method||this.method||"GET",e=s.toUpperCase(),v.indexOf(e)>-1?e:s),this.mode=i.mode||this.mode||null,this.signal=i.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function y(t){var i=new FormData;return t.trim().split("&").forEach((function(t){if(t){var s=t.split("="),e=s.shift().replace(/\+/g," "),n=s.join("=").replace(/\+/g," ");i.append(decodeURIComponent(e),decodeURIComponent(n))}})),i}function E(t,i){i||(i={}),this.type="default",this.status=void 0===i.status?200:i.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in i?i.statusText:"OK",this.headers=new h(i.headers),this.url=i.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},f.call(w.prototype),f.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:0,statusText:""});return t.type="error",t};var p=[301,302,303,307,308];E.redirect=function(t,i){if(-1===p.indexOf(i))throw new RangeError("Invalid status code");return new E(null,{status:i,headers:{location:t}})},i.DOMException=t.DOMException;try{new i.DOMException}catch(t){i.DOMException=function(t,i){this.message=t,this.name=i;var s=Error(t);this.stack=s.stack},i.DOMException.prototype=Object.create(Error.prototype),i.DOMException.prototype.constructor=i.DOMException}function S(t,e){return new Promise((function(n,r){var o=new w(t,e);if(o.signal&&o.signal.aborted)return r(new i.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t,i,s={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",i=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var s=t.split(":"),e=s.shift().trim();if(e){var n=s.join(":").trim();i.append(e,n)}})),i)};s.url="responseURL"in a?a.responseURL:s.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;n(new E(e,s))},a.onerror=function(){r(new TypeError("Network request failed"))},a.ontimeout=function(){r(new TypeError("Network request failed"))},a.onabort=function(){r(new i.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&s.blob&&(a.responseType="blob"),o.headers.forEach((function(t,i){a.setRequestHeader(i,t)})),o.signal&&(o.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",c)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}S.polyfill=!0,t.fetch||(t.fetch=S,t.Headers=h,t.Request=w,t.Response=E),i.Headers=h,i.Request=w,i.Response=E,i.fetch=S,Object.defineProperty(i,"t",{value:!0})}({})}("undefined"!=typeof self?self:void 0),function(t){t.black="black",t.green="green",t.blue="blue",t.purple="purple",t.red="red",t.orange="orange",t.yellow="yellow"}(o||(o={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(a||(a={})),function(t){t.THIRD_PARTY="THIRD_PARTY",t.OFF_THE_GRID="OFF_THE_GRID",t.CONTENT_PACKAGER="CONTENT_PACKAGER",t.PAGES="PAGES",t.DESIGNED_READER="DESIGNED_READER"}(h||(h={})),function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"}(c||(c={})),function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"}(u||(u={})),function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"}(l||(l={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(d||(d={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(f||(f={})),function(t){t.ASC="ASC",t.DESC="DESC"}(v||(v={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(w||(w={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(y||(y={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(E||(E={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(p||(p={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(S||(S={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(b||(b={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS"}(A||(A={})),function(t){t.PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",t.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",t.HTML_EXPORT_USER="HTML_EXPORT_USER",t.PDF_EXPORT_USER="PDF_EXPORT_USER",t.SAVED_SEARCH_USER="SAVED_SEARCH_USER",t.COLLECTION_USER="COLLECTION_USER",t.OFFLINE_USER="OFFLINE_USER",t.ANALYTICS_USER="ANALYTICS_USER",t.BETA_USER="BETA_USER",t.DEBUG_USER="DEBUG_USER",t.PRINT_USER="PRINT_USER",t.RATING_USER="RATING_USER",t.FEEDBACK_USER="FEEDBACK_USER",t.GENERATIVE_AI_USER="GENERATIVE_AI_USER",t.CONTENT_PUBLISHER="CONTENT_PUBLISHER",t.KHUB_ADMIN="KHUB_ADMIN",t.USERS_ADMIN="USERS_ADMIN",t.PORTAL_ADMIN="PORTAL_ADMIN",t.ADMIN="ADMIN",t.DEVELOPER="DEVELOPER"}(m||(m={})),function(t){t.VALID="VALID",t.INVALID="INVALID"}(g||(g={})),m.PERSONAL_BOOK_SHARE_USER,m.PERSONAL_BOOK_USER,m.HTML_EXPORT_USER,m.PERSONAL_BOOK_USER,m.PDF_EXPORT_USER,m.PERSONAL_BOOK_USER,m.KHUB_ADMIN,m.CONTENT_PUBLISHER,m.ADMIN,m.KHUB_ADMIN,m.USERS_ADMIN,m.PORTAL_ADMIN,m.DEVELOPER,m.BETA_USER,m.DEBUG_USER;const R=s.css`
|
|
3
|
+
`,O=i.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0}});class T{static build(t){const{baseUrl:i,apiIntegrationIdentifier:s}=O.getState(),e=null!=t?t:s;if(i&&e&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(i,e,!0)}static get(t){var i;return null!=t?T.build(t):null!==(i=T.API)&&void 0!==i?i:T.API=T.build()}static await(t){return new Promise((i=>{let s=T.get(t);if(s)i(s);else{const e=O.subscribe((()=>{s=T.get(t),s&&(e(),i(s))}))}}))}}class C{constructor(t=!0,s){var e;this.overrideApi=s;let n=this.constructor;n.commonCache=null!==(e=n.commonCache)&&void 0!==e?e:new i.CacheRegistry,this.cache=t?n.commonCache:new i.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:T.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:T.await()}clearCache(){this.cache.clearAll()}}var I;const U=Symbol("clearAfterUnitTest");class L extends C{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[I]=()=>{this.defaultMessages={},this.cache=new i.CacheRegistry,this.listeners={}},this.currentUiLocale=O.getState().uiLocale,O.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=O.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const i=t.name.toLowerCase();this.cache.setFinal(i,t),this.notify(i)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,s){var e;if(t=t.toLowerCase(),Object.keys(s).length>0){const n={...null!==(e=this.defaultMessages[t])&&void 0!==e?e:{},...s};i.deepEqual(this.defaultMessages[t],n)||(this.defaultMessages[t]=n,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,s,...e){var n,r,o;t=t.toLowerCase(),this.fetchContext(t);const a=null!==(r=null===(n=this.cache.getNow(t))||void 0===n?void 0:n.messages)&&void 0!==r?r:{};return new i.ParametrizedLabelResolver(null!==(o=this.defaultMessages[t])&&void 0!==o?o:{},a).resolve(s,...e)}async fetchContext(t){if(!this.cache.has(t))try{await this.cache.get(t,(()=>this.messageContextProvider(this.currentUiLocale,t))),await this.notify(t)}catch(t){console.error(t)}}subscribe(t,i){var s;return t=t.toLowerCase(),this.listeners[t]=null!==(s=this.listeners[t])&&void 0!==s?s:new Set,this.listeners[t].add(i),()=>{var s;return null===(s=this.listeners[t])||void 0===s?void 0:s.delete(i)}}async notifyAll(){await Promise.all(Object.keys(this.listeners).map((t=>this.notify(t))))}async notify(t){null!=this.listeners[t]&&await Promise.all([...this.listeners[t].values()].map((t=>i.delay(0).then((()=>t())).catch((()=>null)))))}}I=U,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends L{constructor(){super((async(t,i)=>(await this.awaitApi).getFluidTopicsMessageContext(t,i)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends L{constructor(){super((async(t,i)=>(await this.awaitApi).getCustomMessageContext(t,i)))}});const D=window.FluidTopicsI18nService;var P=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class N extends i.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>T.get(),this.cache=new i.CacheRegistry,this.cleanSessionDebouncer=new i.Debouncer}render(){return s.html`
|
|
4
4
|
<slot></slot>
|
|
5
|
-
`}update(t){super.update(t),t.has("baseUrl")&&(O.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&O.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&O.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&O.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&O.actions.noCustom(this.noCustom),t.has("editorMode")&&O.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&O.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&O.actions.session(this.session),t.has("availableUiLocales")&&O.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>L.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}N.elementDefinitions={},N.styles=R,D([e.property()],N.prototype,"baseUrl",void 0),D([e.property()],N.prototype,"apiIntegrationIdentifier",void 0),D([e.property()],N.prototype,"uiLocale",void 0),D([i.jsonProperty(null)],N.prototype,"availableUiLocales",void 0),D([i.jsonProperty(null)],N.prototype,"metadataConfiguration",void 0),D([e.property({type:Boolean})],N.prototype,"editorMode",void 0),D([e.property({type:Boolean})],N.prototype,"noCustom",void 0),D([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],N.prototype,"noCustomComponent",void 0),D([e.property({type:Boolean})],N.prototype,"withManualResources",void 0),D([i.jsonProperty([])],N.prototype,"messageContexts",void 0),D([i.jsonProperty(void 0)],N.prototype,"session",void 0),D([e.property({type:Object})],N.prototype,"apiProvider",void 0);class P{async listMySearches(){var t;return(null===(t=O.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await T.await()).listMySearches(O.getState().session.profile.userId):[]}}const _=new i.CacheRegistry;class B{async listMyBookmarks(){return _.get("bookmarks",(async()=>(await T.await()).listMyBookmarks(O.getState().session.profile.userId)))}clearCache(){_.clear("bookmarks")}}const M=i.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const x=new class{constructor(){this.currentSession=O.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new B,O.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:s}=O.getState();i.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==s?void 0:s.profile)||(this.currentSession=s,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){M.actions.savedSearches(void 0)}clearMyBookmarks(){M.actions.bookmarks(void 0)}async reloadMySearches(){const t=new P,i=await t.listMySearches();M.actions.savedSearches(i)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const i=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;M.actions.bookmarks(i)}}};i.customElement("ft-app-context")(N);class F{static async build(){return new F(await T.await())}constructor(t){this.api=t,this.cache=new i.CacheRegistry,this.cache.registerFinal("available-locales",(()=>this.api.getAvailableSearchLocales()))}async launchSearch(t){return this.api.search(t)}async launchSuggest(t){return this.api.getSuggestions(t)}async getAvailableSearchLocales(){return this.cache.get("available-locales")}}const k=t=>t.request.virtualField===y.TITLE_ONLY&&t.request.scope===A.DOCUMENTS;class j extends Event{constructor(){super(j.eventName)}}j.eventName="search-context-clear-all-filters";class q{static build(t){return new q((t=>i.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:r}))(t.trim()||"context"),F.build)}constructor(t,s){this.store=t,this.serviceProvider=s,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.searchDebouncer=new i.Debouncer(100),this.suggestDebouncer=new i.Debouncer(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){return i.waitFor((()=>this.service))}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let i=this.store.getState().locales,s=this.store.getState().request.contentLocale;if(t!=s){if(i){const e=t=>i.some((i=>i.lang==t));e(t)||(t=e(s)?s:i[0].lang)}this.store.actions.setRequestContentLocale(t),this.store.actions.setPageNumber(1),this.store.actions.setRequestFilters([]),this.launchSearch()}return t}setPageSize(t){this.store.actions.setPageSize(t),this.launchSearch()}setPageNumber(t){this.store.actions.setPageNumber(t),this.launchSearch()}setSort(t){this.store.actions.setRequestSort(t),this.store.actions.setPageNumber(1),this.launchSearch()}setFilters(t){const i=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(i),this.store.actions.setPageNumber(1),i.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(y.TITLE_ONLY),this.store.actions.setRequestScope(A.DOCUMENTS)):(this.store.actions.setRequestVirtualField(y.EVERYWHERE),this.store.actions.setRequestScope(A.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return k(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new j)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,i){let s=this.facetIds.filter((i=>i!=t));i&&s.push(i),this.facetIds=s,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let i=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(i)}setFilter(t,i){let s=this.store.getState().request.filters,e={key:t,values:i,negative:!1},n=[...s.filter((i=>i.key!==t)),e];this.setFilters(n)}setLiveQuery(t){this.store.actions.setLiveQuery(t),this.launchSuggest()}setRequest(t){this.store.actions.setRequest(t),this.store.actions.setLiveQuery(t.query),this.store.actions.setPageNumber(1),this.launchSearch()}setScope(t){this.store.actions.setRequestScope(t),this.launchSearch()}setIgnoreEmptyQuery(t){this.ignoreEmptyQuery=t,this.launchSearch()}setOpenExternalDocumentInNewTab(t){this.openExternalDocumentInNewTab=t}async launchSearch(){return await this.awaitService(),this.searchDebouncer.run((()=>this.fetchSearchData()))}async launchSuggest(){await this.awaitService(),this.suggestDebouncer.run((()=>this.fetchSuggestData()))}async fetchSearchData(){var t,s;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel();let e=this.store.getState().request;if(this.store.actions.setPaging(void 0),this.ignoreEmptyQuery&&0==e.query.length)this.store.actions.setResults(void 0),this.store.actions.setFacets(void 0),this.store.actions.setSpellcheck(void 0);else{this.cancelableSearch=i.cancelable(this.service.launchSearch(e));const t=await this.cancelableSearch;if(t.paging.currentPage<=1)this.store.actions.setResults(t.results),this.store.actions.setFacets(t.facets),this.store.actions.setSpellcheck(t.spellcheck);else{let i=(null!==(s=this.store.getState().results)&&void 0!==s?s:[]).concat(t.results);this.store.actions.setResults(i)}this.store.actions.setPaging(t.paging)}}catch(t){t instanceof i.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const s=this.store.getState(),e=s.request,n={input:s.liveQuery,filters:e.filters,sort:e.sort,contentLocale:e.contentLocale,scope:e.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=i.cancelable(this.service.launchSuggest(n));let r=await this.cancelableSuggest;this.store.actions.setSuggestResults(r.suggestions)}catch(t){t instanceof i.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}clear(){this.store.clear()}}var H=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class G extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const K=Symbol("registerInterval");class V extends(function(t){var i;class s extends t{constructor(){super(...arguments),this[i]=0}setSearchStateManager(t){this.clearStateManager(),this.stateManager=t,this.addStore(t.store,"search")}clearStateManager(){this.stateManager&&(this.removeStore(this.stateManager.store),this.stateManager=void 0)}connectedCallback(){super.connectedCallback(),this[K]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[K]):this.dispatchEvent(new G)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return i=K,H([e.state()],s.prototype,"stateManager",void 0),s}(i.FtLitElementRedux)){}var Q=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class z extends CustomEvent{constructor(t){super("ft-search-load-error",{detail:t})}}class X extends CustomEvent{constructor(t){super("ft-search-request-change",{detail:t})}}class Y extends CustomEvent{constructor(t,i,s){super("ft-search-results-change",{detail:{request:t,paging:i,spellcheck:s}})}}class W extends i.FtLitElementRedux{get stateManager(){return null==this._stateManager&&(this._stateManager=q.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0")),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"search")),this._stateManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.filters=[],this.sort=[],this.addStore(O)}render(){return s.html`
|
|
5
|
+
`}update(t){super.update(t),t.has("baseUrl")&&(O.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&O.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&O.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&O.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&O.actions.noCustom(this.noCustom),t.has("editorMode")&&O.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&O.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&O.actions.session(this.session),t.has("availableUiLocales")&&O.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>D.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}N.elementDefinitions={},N.styles=R,P([e.property()],N.prototype,"baseUrl",void 0),P([e.property()],N.prototype,"apiIntegrationIdentifier",void 0),P([e.property()],N.prototype,"uiLocale",void 0),P([i.jsonProperty(null)],N.prototype,"availableUiLocales",void 0),P([i.jsonProperty(null)],N.prototype,"metadataConfiguration",void 0),P([e.property({type:Boolean})],N.prototype,"editorMode",void 0),P([e.property({type:Boolean})],N.prototype,"noCustom",void 0),P([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],N.prototype,"noCustomComponent",void 0),P([e.property({type:Boolean})],N.prototype,"withManualResources",void 0),P([i.jsonProperty([])],N.prototype,"messageContexts",void 0),P([i.jsonProperty(void 0)],N.prototype,"session",void 0),P([e.property({type:Object})],N.prototype,"apiProvider",void 0);class _ extends C{async listMySearches(){let t=O.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class x extends C{async listMyBookmarks(){let t=O.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const B=i.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const M=new class{constructor(){this.currentSession=O.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new x,this.savedSearchesService=new _,O.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:s}=O.getState();i.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==s?void 0:s.profile)||(this.currentSession=s,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),B.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),B.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();B.actions.savedSearches(t)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const i=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;B.actions.bookmarks(i)}}};i.customElement("ft-app-context")(N);class F extends C{constructor(){super(),this.cache.registerFinal("available-locales",(()=>this.api.getAvailableSearchLocales()))}async launchSearch(t){return this.api.search(t)}async launchSuggest(t){return this.api.getSuggestions(t)}async getAvailableSearchLocales(){return this.cache.get("available-locales")}}const k=t=>t.request.virtualField===y.TITLE_ONLY&&t.request.scope===A.DOCUMENTS;class j extends Event{constructor(){super(j.eventName)}}j.eventName="search-context-clear-all-filters";class q{static build(t,s){return new q((t=>i.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:r}))(t.trim()||"context"),s)}constructor(t,s){this.store=t,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.searchDebouncer=new i.Debouncer(100),this.suggestDebouncer=new i.Debouncer(300),this.service=null!=s?s:new F}async initService(){return this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let i=this.store.getState().locales,s=this.store.getState().request.contentLocale;if(t!=s){if(i){const e=t=>i.some((i=>i.lang==t));e(t)||(t=e(s)?s:i[0].lang)}this.store.actions.setRequestContentLocale(t),this.store.actions.setPageNumber(1),this.store.actions.setRequestFilters([]),this.launchSearch()}return t}setPageSize(t){this.store.actions.setPageSize(t),this.launchSearch()}setPageNumber(t){this.store.actions.setPageNumber(t),this.launchSearch()}setSort(t){this.store.actions.setRequestSort(t),this.store.actions.setPageNumber(1),this.launchSearch()}setFilters(t){const i=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(i),this.store.actions.setPageNumber(1),i.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(y.TITLE_ONLY),this.store.actions.setRequestScope(A.DOCUMENTS)):(this.store.actions.setRequestVirtualField(y.EVERYWHERE),this.store.actions.setRequestScope(A.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return k(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new j)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,i){let s=this.facetIds.filter((i=>i!=t));i&&s.push(i),this.facetIds=s,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let i=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(i)}setFilter(t,i){let s=this.store.getState().request.filters,e={key:t,values:i,negative:!1},n=[...s.filter((i=>i.key!==t)),e];this.setFilters(n)}setLiveQuery(t){this.store.actions.setLiveQuery(t),this.launchSuggest()}setRequest(t){this.store.actions.setRequest(t),this.store.actions.setLiveQuery(t.query),this.store.actions.setPageNumber(1),this.launchSearch()}setScope(t){this.store.actions.setRequestScope(t),this.launchSearch()}setIgnoreEmptyQuery(t){this.ignoreEmptyQuery=t,this.launchSearch()}setOpenExternalDocumentInNewTab(t){this.openExternalDocumentInNewTab=t}launchSearch(){return this.searchDebouncer.run((()=>this.fetchSearchData()))}launchSuggest(){return this.suggestDebouncer.run((()=>this.fetchSuggestData()))}async fetchSearchData(){var t,s;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel();let e=this.store.getState().request;if(this.store.actions.setPaging(void 0),this.ignoreEmptyQuery&&0==e.query.length)this.store.actions.setResults(void 0),this.store.actions.setFacets(void 0),this.store.actions.setSpellcheck(void 0);else{this.cancelableSearch=i.cancelable(this.service.launchSearch(e));const t=await this.cancelableSearch;if(t.paging.currentPage<=1)this.store.actions.setResults(t.results),this.store.actions.setFacets(t.facets),this.store.actions.setSpellcheck(t.spellcheck);else{let i=(null!==(s=this.store.getState().results)&&void 0!==s?s:[]).concat(t.results);this.store.actions.setResults(i)}this.store.actions.setPaging(t.paging)}}catch(t){t instanceof i.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const s=this.store.getState(),e=s.request,n={input:s.liveQuery,filters:e.filters,sort:e.sort,contentLocale:e.contentLocale,scope:e.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=i.cancelable(this.service.launchSuggest(n));let r=await this.cancelableSuggest;this.store.actions.setSuggestResults(r.suggestions)}catch(t){t instanceof i.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}clear(){this.store.clear()}}var H=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class G extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const K=Symbol("registerInterval");class V extends(function(t){var i;class s extends t{constructor(){super(...arguments),this[i]=0}setSearchStateManager(t){this.clearStateManager(),this.stateManager=t,this.addStore(t.store,"search")}clearStateManager(){this.stateManager&&(this.removeStore(this.stateManager.store),this.stateManager=void 0)}connectedCallback(){super.connectedCallback(),this[K]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[K]):this.dispatchEvent(new G)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return i=K,H([e.state()],s.prototype,"stateManager",void 0),s}(i.FtLitElementRedux)){}var Q=function(t,i,s,e){for(var n,r=arguments.length,o=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(i,s,o):n(i,s))||o);return r>3&&o&&Object.defineProperty(i,s,o),o};class z extends CustomEvent{constructor(t){super("ft-search-load-error",{detail:t})}}class X extends CustomEvent{constructor(t){super("ft-search-request-change",{detail:t})}}class Y extends CustomEvent{constructor(t,i,s){super("ft-search-results-change",{detail:{request:t,paging:i,spellcheck:s}})}}class W extends i.FtLitElementRedux{get stateManager(){if(null==this._stateManager){const t=this.searchServiceProvider?this.searchServiceProvider():void 0;this._stateManager=q.build(this.id||(""+Math.round(999e3*Math.random())).padStart(6,"0"),t),this._stateManager.errorHandler=t=>this.handleLoadError(t),this.addStore(this.stateManager.store,"search")}return this._stateManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.filters=[],this.sort=[],this.addStore(O)}render(){return s.html`
|
|
6
6
|
<slot @register-ft-search-component=${this.registerComponent}></slot>
|
|
7
|
-
`}update(t){super.update(t),t.has("query")&&void 0!==this.query&&this.stateManager.setQuery(this.query),t.has("contentLocale")&&void 0!==this.contentLocale&&this.stateManager.setContentLocale(this.contentLocale),t.has("session")&&this.session&&this.stateManager.initService(),t.has("filters")&&void 0!==this.filters&&this.stateManager.setFilters(this.filters),t.has("sort")&&void 0!==this.sort&&this.stateManager.setSort(this.sort),t.has("pageSize")&&void 0!==this.pageSize&&this.stateManager.setPageSize(this.pageSize),t.has("searchInDocumentTitlesOnly")&&void 0!==this.searchInDocumentTitlesOnly&&this.stateManager.setSearchInDocumentTitlesOnly(this.searchInDocumentTitlesOnly),t.has("scope")&&void 0!==this.scope&&this.stateManager.setScope(this.scope),t.has("ignoreEmptyQuery")&&void 0!==this.ignoreEmptyQuery&&this.stateManager.setIgnoreEmptyQuery(this.ignoreEmptyQuery),t.has("openExternalDocumentInNewTab")&&void 0!==this.openExternalDocumentInNewTab&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab)}connectedCallback(){super.connectedCallback(),this.stateManager.setQuery(this.query),this.stateManager.setContentLocale(this.contentLocale),this.stateManager.setFilters(this.filters),this.stateManager.setPageSize(this.pageSize),this.stateManager.setSort(this.sort)}contentAvailableCallback(t){super.contentAvailableCallback(t),t.has("request")&&this.request&&this.dispatchEvent(new X(this.request)),t.has("paging")&&void 0!==this.paging&&this.dispatchEvent(new Y(this.request,this.paging,this.autocorrect))}registerComponent(t){t.stopPropagation();const i=t.composedPath()[0];this.register(i)}register(t){t.setSearchStateManager(this.stateManager)}handleLoadError(t){this.dispatchEvent(new z(t))}reloadSavedSearches(){
|
|
7
|
+
`}update(t){super.update(t),t.has("query")&&void 0!==this.query&&this.stateManager.setQuery(this.query),t.has("contentLocale")&&void 0!==this.contentLocale&&this.stateManager.setContentLocale(this.contentLocale),t.has("session")&&this.session&&this.stateManager.initService(),t.has("filters")&&void 0!==this.filters&&this.stateManager.setFilters(this.filters),t.has("sort")&&void 0!==this.sort&&this.stateManager.setSort(this.sort),t.has("pageSize")&&void 0!==this.pageSize&&this.stateManager.setPageSize(this.pageSize),t.has("searchInDocumentTitlesOnly")&&void 0!==this.searchInDocumentTitlesOnly&&this.stateManager.setSearchInDocumentTitlesOnly(this.searchInDocumentTitlesOnly),t.has("scope")&&void 0!==this.scope&&this.stateManager.setScope(this.scope),t.has("ignoreEmptyQuery")&&void 0!==this.ignoreEmptyQuery&&this.stateManager.setIgnoreEmptyQuery(this.ignoreEmptyQuery),t.has("openExternalDocumentInNewTab")&&void 0!==this.openExternalDocumentInNewTab&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab)}connectedCallback(){super.connectedCallback(),this.stateManager.setQuery(this.query),this.stateManager.setContentLocale(this.contentLocale),this.stateManager.setFilters(this.filters),this.stateManager.setPageSize(this.pageSize),this.stateManager.setSort(this.sort)}contentAvailableCallback(t){super.contentAvailableCallback(t),t.has("request")&&this.request&&this.dispatchEvent(new X(this.request)),t.has("paging")&&void 0!==this.paging&&this.dispatchEvent(new Y(this.request,this.paging,this.autocorrect))}registerComponent(t){t.stopPropagation();const i=t.composedPath()[0];this.register(i)}register(t){t.setSearchStateManager(this.stateManager)}handleLoadError(t){this.dispatchEvent(new z(t))}reloadSavedSearches(){M.clearMySearches()}clear(){this.stateManager.clear()}}W.elementDefinitions={},W.styles=n,Q([e.property()],W.prototype,"query",void 0),Q([e.property()],W.prototype,"contentLocale",void 0),Q([e.property({type:Number})],W.prototype,"pageSize",void 0),Q([e.property({type:Boolean})],W.prototype,"searchInDocumentTitlesOnly",void 0),Q([e.property()],W.prototype,"scope",void 0),Q([e.property({type:Boolean})],W.prototype,"ignoreEmptyQuery",void 0),Q([e.property({type:Boolean})],W.prototype,"openExternalDocumentInNewTab",void 0),Q([i.jsonProperty([])],W.prototype,"filters",void 0),Q([i.jsonProperty([])],W.prototype,"sort",void 0),Q([i.redux({store:"search"})],W.prototype,"request",void 0),Q([i.redux({store:"search"})],W.prototype,"paging",void 0),Q([i.redux({store:"search",selector:t=>t.spellcheck})],W.prototype,"autocorrect",void 0),Q([i.redux({store:O.name})],W.prototype,"session",void 0),Q([e.property({attribute:!1})],W.prototype,"searchServiceProvider",void 0),i.customElement("ft-search-context")(W),t.ClearAllFiltersEvent=j,t.FtSearchContext=W,t.FtSearchContextCssVariables={},t.FtSearchStateManager=q,t.LoadErrorEvent=z,t.SearchRequestChangeEvent=X,t.SearchResultsChangeEvent=Y,t.searchInDocumentTitlesOnlySelector=k,t.styles=n}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
|