@fluid-topics/ft-search-facet 1.0.62 → 1.0.63
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.
|
@@ -1482,7 +1482,7 @@ const M=Symbol.for(""),_=t=>{if((null==t?void 0:t.r)===M)return null==t?void 0:t
|
|
|
1482
1482
|
`}updateSubOptionsFromSlot(t){t.stopPropagation(),this.subOptions=this.slotElement.assignedElements().map((t=>t))}update(t){super.update(t),this.dispatchEvent(new CustomEvent("option-change",{detail:this,bubbles:!0}))}}qe.elementDefinitions={},Ve([i.property({type:String})],qe.prototype,"label",void 0),Ve([i.property({type:Object,converter:t=>t})],qe.prototype,"value",void 0),Ve([i.property({type:Boolean,reflect:!0})],qe.prototype,"selected",void 0),Ve([i.property({type:Object})],qe.prototype,"subOptions",void 0),Ve([o.jsonProperty({})],qe.prototype,"renderOption",void 0),Ve([i.query(".ft-filter-option--slot")],qe.prototype,"slotElement",void 0),o.customElement("ft-filter")(Ge),o.customElement("ft-filter-option")(qe);const Ye={setRequest:(t,o)=>{t.request=o.payload},setRequestQuery:(t,o)=>{t.request.query=o.payload},setRequestContentLocale:(t,o)=>{t.request.contentLocale=o.payload},setPageSize:(t,o)=>{t.request.paging.perPage=o.payload},setPageNumber:(t,o)=>{t.request.paging.page=o.payload},setRequestSort:(t,o)=>{t.request.sort=o.payload},setRequestFilters:(t,o)=>{t.request.filters=o.payload},setRequestFacets:(t,o)=>{t.request.facets=o.payload},setRequestVirtualField:(t,o)=>{t.request.virtualField=o.payload},setRequestScope:(t,o)=>{t.request.scope=o.payload},setResults:(t,o)=>{t.results=o.payload},setFacets:(t,o)=>{t.facets=o.payload},setSpellcheck:(t,o)=>{t.spellcheck=o.payload},setLocales:(t,o)=>{t.locales=o.payload},setPaging:(t,o)=>{t.paging=o.payload},setLiveQuery:(t,o)=>{t.liveQuery=o.payload},setSuggestResults:(t,o)=>{t.suggestResults=o.payload}};var Xe,Qe,Je,ti,oi,ei,ii,ri,ai,ni,si,li,ci,hi;!function(t){!function(o){var e={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(e.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],r=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function a(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 n(t){return"string"!=typeof t&&(t=String(t)),t}function s(t){var o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return e.iterable&&(o[Symbol.iterator]=function(){return o}),o}function l(t){this.map={},t instanceof l?t.forEach((function(t,o){this.append(o,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(o){this.append(o,t[o])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function h(t){return new Promise((function(o,e){t.onload=function(){o(t.result)},t.onerror=function(){e(t.error)}}))}function p(t){var o=new FileReader,e=h(o);return o.readAsArrayBuffer(t),e}function f(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var o;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:e.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:e.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():e.arrayBuffer&&e.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=f(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):e.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||r(t))?this._bodyArrayBuffer=f(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):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.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(p)}),this.text=function(){var t,o,e,i=c(this);if(i)return i;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,e=h(o),o.readAsText(t),e;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var o=new Uint8Array(t),e=new Array(o.length),i=0;i<o.length;i++)e[i]=String.fromCharCode(o[i]);return e.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(g)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,o){t=a(t),o=n(o);var e=this.map[t];this.map[t]=e?e+", "+o:o},l.prototype.delete=function(t){delete this.map[a(t)]},l.prototype.get=function(t){return t=a(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(a(t))},l.prototype.set=function(t,o){this.map[a(t)]=n(o)},l.prototype.forEach=function(t,o){for(var e in this.map)this.map.hasOwnProperty(e)&&t.call(o,this.map[e],e,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(o,e){t.push(e)})),s(t)},l.prototype.values=function(){var t=[];return this.forEach((function(o){t.push(o)})),s(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(o,e){t.push([e,o])})),s(t)},e.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var u=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,o){var e,i,r=(o=o||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||"same-origin",!o.headers&&this.headers||(this.headers=new l(o.headers)),this.method=(e=o.method||this.method||"GET",i=e.toUpperCase(),u.indexOf(i)>-1?i:e),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function g(t){var o=new FormData;return t.trim().split("&").forEach((function(t){if(t){var e=t.split("="),i=e.shift().replace(/\+/g," "),r=e.join("=").replace(/\+/g," ");o.append(decodeURIComponent(i),decodeURIComponent(r))}})),o}function b(t,o){o||(o={}),this.type="default",this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in o?o.statusText:"OK",this.headers=new l(o.headers),this.url=o.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},d.call(y.prototype),d.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];b.redirect=function(t,o){if(-1===m.indexOf(o))throw new RangeError("Invalid status code");return new b(null,{status:o,headers:{location:t}})},o.DOMException=t.DOMException;try{new o.DOMException}catch(t){o.DOMException=function(t,o){this.message=t,this.name=o;var e=Error(t);this.stack=e.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function v(t,i){return new Promise((function(r,a){var n=new y(t,i);if(n.signal&&n.signal.aborted)return a(new o.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var t,o,e={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",o=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var e=t.split(":"),i=e.shift().trim();if(i){var r=e.join(":").trim();o.append(i,r)}})),o)};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;r(new b(i,e))},s.onerror=function(){a(new TypeError("Network request failed"))},s.ontimeout=function(){a(new TypeError("Network request failed"))},s.onabort=function(){a(new o.DOMException("Aborted","AbortError"))},s.open(n.method,n.url,!0),"include"===n.credentials?s.withCredentials=!0:"omit"===n.credentials&&(s.withCredentials=!1),"responseType"in s&&e.blob&&(s.responseType="blob"),n.headers.forEach((function(t,o){s.setRequestHeader(o,t)})),n.signal&&(n.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&n.signal.removeEventListener("abort",c)}),s.send(void 0===n._bodyInit?null:n._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=l,t.Request=y,t.Response=b),o.Headers=l,o.Request=y,o.Response=b,o.fetch=v,Object.defineProperty(o,"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"}(Xe||(Xe={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(Qe||(Qe={})),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"}(Je||(Je={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(ti||(ti={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(oi||(oi={})),function(t){t.ASC="ASC",t.DESC="DESC"}(ei||(ei={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(ii||(ii={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(ri||(ri={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(ai||(ai={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(ni||(ni={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(si||(si={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(li||(li={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS"}(ci||(ci={})),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.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"}(hi||(hi={})),hi.PERSONAL_BOOK_SHARE_USER,hi.PERSONAL_BOOK_USER,hi.HTML_EXPORT_USER,hi.PERSONAL_BOOK_USER,hi.PDF_EXPORT_USER,hi.PERSONAL_BOOK_USER,hi.KHUB_ADMIN,hi.CONTENT_PUBLISHER,hi.ADMIN,hi.KHUB_ADMIN,hi.USERS_ADMIN,hi.PORTAL_ADMIN,hi.DEVELOPER,hi.BETA_USER,hi.DEBUG_USER;const pi=e.css`
|
|
1483
1483
|
`,fi=o.FtReduxStore.get({name:"ft-app-info",reducers:{setBaseUrl:(t,o)=>{t.baseUrl=o.payload},setApiIntegrationIdentifier:(t,o)=>{t.apiIntegrationIdentifier=o.payload},setUiLocale:(t,o)=>{t.uiLocale=o.payload},setAvailableUiLocales:(t,o)=>{t.availableUiLocales=o.payload},setEditorMode:(t,o)=>{t.editorMode=o.payload},setNoCustom:(t,o)=>{t.noCustom=o.payload},setNoCustomComponent:(t,o)=>{t.noCustomComponent=o.payload},setSession:(t,o)=>{t.session=o.payload}},initialState:{uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],editorMode:!1,noCustom:!1,noCustomComponent:!1}});class di{static build(t){const{baseUrl:o,apiIntegrationIdentifier:e}=fi.getState(),i=null!=t?t:e;if(o&&i&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(o,i,!0)}static get(t){var o;return null!=t?di.build(t):null!==(o=di.API)&&void 0!==o?o:di.API=di.build()}static await(t){return new Promise((o=>{let e=di.get(t);if(e)o(e);else{const i=fi.subscribe((()=>{e=di.get(t),e&&(i(),o(e))}))}}))}}var ui;const yi=Symbol("clearAfterUnitTest");class gi{constructor(t){this.messageContextProvider=t,this.defaultMessages={},this.cache=new o.CacheRegistry,this.listeners={},this.currentUiLocale="",this[ui]=()=>{this.defaultMessages={},this.cache=new o.CacheRegistry,this.listeners={}},this.currentUiLocale=fi.getState().uiLocale,fi.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=fi.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const o=t.name.toLowerCase();this.cache.setFinal(o,t),this.notify(o)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,e){var i;if(t=t.toLowerCase(),Object.keys(e).length>0){const r={...null!==(i=this.defaultMessages[t])&&void 0!==i?i:{},...e};o.deepEqual(this.defaultMessages[t],r)||(this.defaultMessages[t]=r,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,e,...i){var r,a,n;t=t.toLowerCase(),this.fetchContext(t);const s=null!==(a=null===(r=this.cache.getNow(t))||void 0===r?void 0:r.messages)&&void 0!==a?a:{};return new o.ParametrizedLabelResolver(null!==(n=this.defaultMessages[t])&&void 0!==n?n:{},s).resolve(e,...i)}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,o){var e;return t=t.toLowerCase(),this.listeners[t]=null!==(e=this.listeners[t])&&void 0!==e?e:new Set,this.listeners[t].add(o),()=>{var e;return null===(e=this.listeners[t])||void 0===e?void 0:e.delete(o)}}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=>o.delay(0).then((()=>t())).catch((()=>null)))))}}ui=yi,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new gi((async(t,o)=>(await di.await()).getFluidTopicsMessageContext(t,o)))),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new gi((async(t,o)=>(await di.await()).getCustomMessageContext(t,o))));const bi=window.FluidTopicsI18nService,mi=window.FluidTopicsCustomI18nService;var vi=function(t,o,e,i){for(var r,a=arguments.length,n=a<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,s=t.length-1;s>=0;s--)(r=t[s])&&(n=(a<3?r(n):a>3?r(o,e,n):r(o,e))||n);return a>3&&n&&Object.defineProperty(o,e,n),n};class xi extends o.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.availableUiLocales=[],this.editorMode=!1,this.noCustom=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>di.get(),this.cache=new o.CacheRegistry,this.cleanSessionDebouncer=new o.Debouncer}render(){return e.html`
|
|
1484
1484
|
<slot></slot>
|
|
1485
|
-
`}update(t){super.update(t),t.has("baseUrl")&&fi.actions.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&fi.actions.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&fi.actions.setUiLocale(this.uiLocale),t.has("noCustom")&&fi.actions.setNoCustom(this.noCustom),t.has("editorMode")&&fi.actions.setEditorMode(this.editorMode),t.has("noCustomComponent")&&fi.actions.setNoCustomComponent(this.noCustomComponent),t.has("session")&&fi.actions.setSession(this.session),t.has("availableUiLocales")&&fi.actions.setAvailableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>bi.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){const t=this.apiProvider();!this.withManualResources&&t&&(null==this.session&&(this.session=await this.cache.get("session",(async()=>{const o=await t.getCurrentSession();return o.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),o.idleTimeoutInMillis),o}))),null==this.availableUiLocales&&(this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>t.getAvailableUiLocales()))))}}xi.elementDefinitions={},xi.styles=pi,vi([i.property()],xi.prototype,"baseUrl",void 0),vi([i.property()],xi.prototype,"apiIntegrationIdentifier",void 0),vi([i.property()],xi.prototype,"uiLocale",void 0),vi([o.jsonProperty([])],xi.prototype,"availableUiLocales",void 0),vi([i.property({type:Boolean})],xi.prototype,"editorMode",void 0),vi([i.property({type:Boolean})],xi.prototype,"noCustom",void 0),vi([i.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],xi.prototype,"noCustomComponent",void 0),vi([i.property({type:Boolean})],xi.prototype,"withManualResources",void 0),vi([o.jsonProperty([])],xi.prototype,"messageContexts",void 0),vi([o.jsonProperty(void 0)],xi.prototype,"session",void 0),vi([i.property({type:Object})],xi.prototype,"apiProvider",void 0);class Oi{async listMySearches(){var t;return(null===(t=fi.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await di.await()).listMySearches(fi.getState().session.profile.userId):[]}}const Ni=new o.CacheRegistry;class Si{async listMyBookmarks(){return Ni.get("bookmarks",(async()=>(await di.await()).listMyBookmarks(fi.getState().session.profile.userId)))}clearCache(){Ni.clear("bookmarks")}}const wi=o.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const $i=new class{constructor(){this.currentSession=fi.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new Si,fi.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:e}=fi.getState();o.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==e?void 0:e.profile)||(this.currentSession=e,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){wi.actions.savedSearches(void 0)}clearMyBookmarks(){wi.actions.bookmarks(void 0)}async reloadMySearches(){const t=new Oi,o=await t.listMySearches();wi.actions.savedSearches(o)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const o=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;wi.actions.bookmarks(o)}}};o.customElement("ft-app-context")(xi);class Ci{static async build(){return new Ci(await di.await())}constructor(t){this.api=t,this.cache=new o.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")}}class ki extends Event{constructor(){super(ki.eventName)}}ki.eventName="search-context-clear-all-filters";class Ii{static build(t){return new Ii((t=>o.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:Ye}))(t.trim()||"context"),Ci.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.searchDebouncer=new o.Debouncer(100),this.suggestDebouncer=new o.Debouncer(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){for(;null==this.service;)await o.delay(5);return this.service}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let o=this.store.getState().locales,e=this.store.getState().request.contentLocale;if(t!=e){if(o){const i=t=>o.some((o=>o.lang==t));i(t)||(t=i(e)?e:o[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 o=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(o),this.store.actions.setPageNumber(1),o.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(ri.TITLE_ONLY),this.store.actions.setRequestScope(ci.DOCUMENTS)):(this.store.actions.setRequestVirtualField(ri.EVERYWHERE),this.store.actions.setRequestScope(ci.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return(t=>t.request.virtualField===ri.TITLE_ONLY&&t.request.scope===ci.DOCUMENTS)(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new ki)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,o){let e=this.facetIds.filter((o=>o!=t));o&&e.push(o),this.facetIds=e,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let o=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(o)}setFilter(t,o){let e=this.store.getState().request.filters,i={key:t,values:o,negative:!1},r=[...e.filter((o=>o.key!==t)),i];this.setFilters(r)}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()}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,e;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel(),this.cancelableSearch=o.cancelable(this.service.launchSearch(this.store.getState().request));const i=await this.cancelableSearch;if(i.paging.currentPage<=1)this.store.actions.setResults(i.results),this.store.actions.setFacets(i.facets),this.store.actions.setSpellcheck(i.spellcheck);else{let t=(null!==(e=this.store.getState().results)&&void 0!==e?e:[]).concat(i.results);this.store.actions.setResults(t)}this.store.actions.setPaging(i.paging)}catch(t){t instanceof o.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{
|
|
1485
|
+
`}update(t){super.update(t),t.has("baseUrl")&&fi.actions.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&fi.actions.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&fi.actions.setUiLocale(this.uiLocale),t.has("noCustom")&&fi.actions.setNoCustom(this.noCustom),t.has("editorMode")&&fi.actions.setEditorMode(this.editorMode),t.has("noCustomComponent")&&fi.actions.setNoCustomComponent(this.noCustomComponent),t.has("session")&&fi.actions.setSession(this.session),t.has("availableUiLocales")&&fi.actions.setAvailableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>bi.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){const t=this.apiProvider();!this.withManualResources&&t&&(null==this.session&&(this.session=await this.cache.get("session",(async()=>{const o=await t.getCurrentSession();return o.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),o.idleTimeoutInMillis),o}))),null==this.availableUiLocales&&(this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>t.getAvailableUiLocales()))))}}xi.elementDefinitions={},xi.styles=pi,vi([i.property()],xi.prototype,"baseUrl",void 0),vi([i.property()],xi.prototype,"apiIntegrationIdentifier",void 0),vi([i.property()],xi.prototype,"uiLocale",void 0),vi([o.jsonProperty([])],xi.prototype,"availableUiLocales",void 0),vi([i.property({type:Boolean})],xi.prototype,"editorMode",void 0),vi([i.property({type:Boolean})],xi.prototype,"noCustom",void 0),vi([i.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],xi.prototype,"noCustomComponent",void 0),vi([i.property({type:Boolean})],xi.prototype,"withManualResources",void 0),vi([o.jsonProperty([])],xi.prototype,"messageContexts",void 0),vi([o.jsonProperty(void 0)],xi.prototype,"session",void 0),vi([i.property({type:Object})],xi.prototype,"apiProvider",void 0);class Oi{async listMySearches(){var t;return(null===(t=fi.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await di.await()).listMySearches(fi.getState().session.profile.userId):[]}}const Ni=new o.CacheRegistry;class Si{async listMyBookmarks(){return Ni.get("bookmarks",(async()=>(await di.await()).listMyBookmarks(fi.getState().session.profile.userId)))}clearCache(){Ni.clear("bookmarks")}}const wi=o.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const $i=new class{constructor(){this.currentSession=fi.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new Si,fi.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:e}=fi.getState();o.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==e?void 0:e.profile)||(this.currentSession=e,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){wi.actions.savedSearches(void 0)}clearMyBookmarks(){wi.actions.bookmarks(void 0)}async reloadMySearches(){const t=new Oi,o=await t.listMySearches();wi.actions.savedSearches(o)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const o=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;wi.actions.bookmarks(o)}}};o.customElement("ft-app-context")(xi);class Ci{static async build(){return new Ci(await di.await())}constructor(t){this.api=t,this.cache=new o.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")}}class ki extends Event{constructor(){super(ki.eventName)}}ki.eventName="search-context-clear-all-filters";class Ii{static build(t){return new Ii((t=>o.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:Ye}))(t.trim()||"context"),Ci.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.searchDebouncer=new o.Debouncer(100),this.suggestDebouncer=new o.Debouncer(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){for(;null==this.service;)await o.delay(5);return this.service}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let o=this.store.getState().locales,e=this.store.getState().request.contentLocale;if(t!=e){if(o){const i=t=>o.some((o=>o.lang==t));i(t)||(t=i(e)?e:o[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 o=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(o),this.store.actions.setPageNumber(1),o.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(ri.TITLE_ONLY),this.store.actions.setRequestScope(ci.DOCUMENTS)):(this.store.actions.setRequestVirtualField(ri.EVERYWHERE),this.store.actions.setRequestScope(ci.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return(t=>t.request.virtualField===ri.TITLE_ONLY&&t.request.scope===ci.DOCUMENTS)(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new ki)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,o){let e=this.facetIds.filter((o=>o!=t));o&&e.push(o),this.facetIds=e,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let o=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(o)}setFilter(t,o){let e=this.store.getState().request.filters,i={key:t,values:o,negative:!1},r=[...e.filter((o=>o.key!==t)),i];this.setFilters(r)}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()}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,e;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel(),this.cancelableSearch=o.cancelable(this.service.launchSearch(this.store.getState().request));const i=await this.cancelableSearch;if(i.paging.currentPage<=1)this.store.actions.setResults(i.results),this.store.actions.setFacets(i.facets),this.store.actions.setSpellcheck(i.spellcheck);else{let t=(null!==(e=this.store.getState().results)&&void 0!==e?e:[]).concat(i.results);this.store.actions.setResults(t)}this.store.actions.setPaging(i.paging)}catch(t){t instanceof o.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const e=this.store.getState(),i=e.request,r={input:e.liveQuery,filters:i.filters,sort:i.sort,contentLocale:i.contentLocale,scope:i.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=o.cancelable(this.service.launchSuggest(r));let a=await this.cancelableSuggest;this.store.actions.setSuggestResults(a.suggestions)}catch(t){t instanceof o.CanceledPromiseError||!this.errorHandler||this.errorHandler(t)}}}var Ei=function(t,o,e,i){for(var r,a=arguments.length,n=a<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,s=t.length-1;s>=0;s--)(r=t[s])&&(n=(a<3?r(n):a>3?r(o,e,n):r(o,e))||n);return a>3&&n&&Object.defineProperty(o,e,n),n};class Ri extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const Ui=Symbol("registerInterval");class Li extends(function(t){var o;class e extends t{constructor(){super(...arguments),this[o]=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[Ui]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Ui]):this.dispatchEvent(new Ri)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return o=Ui,Ei([i.state()],e.prototype,"stateManager",void 0),e}(o.FtLitElementRedux)){}function Wi(t){return t.rootNodes.map((t=>zi(t)))}function zi(t){return{label:t.label,value:t.value,selected:t.selected,subOptions:t.childNodes.map((t=>zi(t)))}}const Bi=e.css`
|
|
1486
1486
|
`;var Ki=function(t,o,e,i){for(var r,a=arguments.length,n=a<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,s=t.length-1;s>=0;s--)(r=t[s])&&(n=(a<3?r(n):a>3?r(o,e,n):r(o,e))||n);return a>3&&n&&Object.defineProperty(o,e,n),n};const Ai=Symbol("i18nProperties"),Di=Symbol("i18nUnsubs");function Fi(t){var o;class e extends t{constructor(){super(...arguments),this.useCustomMessageContexts=!1,this[o]=new Map}get i18nService(){return this.useCustomMessageContexts?mi:bi}i18n(t,o,...e){var i;if("string"==typeof t)return this.i18nService.resolveMessage(t,o,...e);const r=null!==(i=t.args)&&void 0!==i?i:t.argsProvider?t.argsProvider(this):[];return this.i18nService.resolveMessage(t.context,t.key,...r)}onI18nUpdate(t){var o;null===(o=this[Ai])||void 0===o||o.forEach(((o,e)=>{o.context.toLowerCase()===t.toLowerCase()&&(this[e]=this.i18n(o))})),setTimeout((()=>this.requestUpdate()),0)}update(t){var o;super.update(t),null===(o=this[Ai])||void 0===o||o.forEach(((t,o)=>{null!=t.argsProvider&&(this[o]=this.i18n(t))}))}connectedCallback(){super.connectedCallback(),null!=this[Ai]&&new Set([...this[Ai].values()].map((t=>t.context))).forEach((t=>this.addI18nMessages(t)))}addI18nMessages(t,o){t=t.toLowerCase(),this[Di].has(t)||this[Di].set(t,this.i18nService.subscribe(t,(()=>this.onI18nUpdate(t)))),this.i18nService.prepareContext(t,null!=o?o:{})}addI18nContext(t,o){this.addI18nMessages(t.name,o)}disconnectedCallback(){super.disconnectedCallback(),this[Di].forEach((t=>t())),this[Di].clear()}}return o=Di,Ki([i.property({type:Boolean})],e.prototype,"useCustomMessageContexts",void 0),e}class Zi extends(Fi(o.FtLitElement)){}class Ti extends(Fi(o.FtLitElementRedux)){}var Hi=function(t,o,e,i){for(var r,a=arguments.length,n=a<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,s=t.length-1;s>=0;s--)(r=t[s])&&(n=(a<3?r(n):a>3?r(o,e,n):r(o,e))||n);return a>3&&n&&Object.defineProperty(o,e,n),n};class Pi extends Ti{constructor(){super(),this.editorMode=!1,this.addStore(fi)}render(){return this.key&&this.context?e.html`
|
|
1487
1487
|
<span class="ft-i18n">
|
|
1488
1488
|
${this.i18n(this.context,this.key,...Array.isArray(this.args)?this.args:[])}
|
|
@@ -1604,7 +1604,7 @@ class an extends br{constructor(t){if(super(t),this.et=at,t.type!==dr)throw Erro
|
|
|
1604
1604
|
`}updateSubOptionsFromSlot(t){t.stopPropagation(),this.subOptions=this.slotElement.assignedElements().map((t=>t))}update(t){super.update(t),this.dispatchEvent(new CustomEvent("option-change",{detail:this,bubbles:!0}))}}sa.elementDefinitions={},aa([s({type:String})],sa.prototype,"label",void 0),aa([s({type:Object,converter:t=>t})],sa.prototype,"value",void 0),aa([s({type:Boolean,reflect:!0})],sa.prototype,"selected",void 0),aa([s({type:Object})],sa.prototype,"subOptions",void 0),aa([v({})],sa.prototype,"renderOption",void 0),aa([f(".ft-filter-option--slot")],sa.prototype,"slotElement",void 0),g("ft-filter")(na),g("ft-filter-option")(sa);const la={setRequest:(t,e)=>{t.request=e.payload},setRequestQuery:(t,e)=>{t.request.query=e.payload},setRequestContentLocale:(t,e)=>{t.request.contentLocale=e.payload},setPageSize:(t,e)=>{t.request.paging.perPage=e.payload},setPageNumber:(t,e)=>{t.request.paging.page=e.payload},setRequestSort:(t,e)=>{t.request.sort=e.payload},setRequestFilters:(t,e)=>{t.request.filters=e.payload},setRequestFacets:(t,e)=>{t.request.facets=e.payload},setRequestVirtualField:(t,e)=>{t.request.virtualField=e.payload},setRequestScope:(t,e)=>{t.request.scope=e.payload},setResults:(t,e)=>{t.results=e.payload},setFacets:(t,e)=>{t.facets=e.payload},setSpellcheck:(t,e)=>{t.spellcheck=e.payload},setLocales:(t,e)=>{t.locales=e.payload},setPaging:(t,e)=>{t.paging=e.payload},setLiveQuery:(t,e)=>{t.liveQuery=e.payload},setSuggestResults:(t,e)=>{t.suggestResults=e.payload}};var ca,fa,ha,pa,ua,da,ya,ba,ga,va,ma,xa,Oa,wa;!function(t){!function(e){var o={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(o.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],r=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function n(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 a(t){return"string"!=typeof t&&(t=String(t)),t}function s(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return o.iterable&&(e[Symbol.iterator]=function(){return e}),e}function l(t){this.map={},t instanceof l?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise((function(e,o){t.onload=function(){e(t.result)},t.onerror=function(){o(t.error)}}))}function h(t){var e=new FileReader,o=f(e);return e.readAsArrayBuffer(t),o}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function u(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:o.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o.arrayBuffer&&o.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||r(t))?this._bodyArrayBuffer=p(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):o.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o.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(h)}),this.text=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,o=f(e);return e.readAsText(t),o}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),o=new Array(e.length),i=0;i<e.length;i++)o[i]=String.fromCharCode(e[i]);return o.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,e){t=n(t),e=a(e);var o=this.map[t];this.map[t]=o?o+", "+e:e},l.prototype.delete=function(t){delete this.map[n(t)]},l.prototype.get=function(t){return t=n(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},l.prototype.set=function(t,e){this.map[n(t)]=a(e)},l.prototype.forEach=function(t,e){for(var o in this.map)this.map.hasOwnProperty(o)&&t.call(e,this.map[o],o,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(e,o){t.push(o)})),s(t)},l.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),s(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(e,o){t.push([o,e])})),s(t)},o.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var d=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var o,i,r=(e=e||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new l(e.headers)),this.method=(o=e.method||this.method||"GET",i=o.toUpperCase(),d.indexOf(i)>-1?i:o),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function b(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var o=t.split("="),i=o.shift().replace(/\+/g," "),r=o.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(r))}})),e}function g(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new l(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},u.call(y.prototype),u.call(g.prototype),g.prototype.clone=function(){return new g(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},g.error=function(){var t=new g(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];g.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new g(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var o=Error(t);this.stack=o.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function m(t,i){return new Promise((function(r,n){var a=new y(t,i);if(a.signal&&a.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var t,e,o={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var o=t.split(":"),i=o.shift().trim();if(i){var r=o.join(":").trim();e.append(i,r)}})),e)};o.url="responseURL"in s?s.responseURL:o.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;r(new g(i,o))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.onabort=function(){n(new e.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&o.blob&&(s.responseType="blob"),a.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",c)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}m.polyfill=!0,t.fetch||(t.fetch=m,t.Headers=l,t.Request=y,t.Response=g),e.Headers=l,e.Request=y,e.Response=g,e.fetch=m,Object.defineProperty(e,"W",{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"}(ca||(ca={})),function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"}(fa||(fa={})),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"}(ha||(ha={})),function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"}(pa||(pa={})),function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"}(ua||(ua={})),function(t){t.ASC="ASC",t.DESC="DESC"}(da||(da={})),function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"}(ya||(ya={})),function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"}(ba||(ba={})),function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK"}(ga||(ga={})),function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"}(va||(va={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK"}(ma||(ma={})),function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC"}(xa||(xa={})),function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS"}(Oa||(Oa={})),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.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"}(wa||(wa={})),wa.PERSONAL_BOOK_SHARE_USER,wa.PERSONAL_BOOK_USER,wa.HTML_EXPORT_USER,wa.PERSONAL_BOOK_USER,wa.PDF_EXPORT_USER,wa.PERSONAL_BOOK_USER,wa.KHUB_ADMIN,wa.CONTENT_PUBLISHER,wa.ADMIN,wa.KHUB_ADMIN,wa.USERS_ADMIN,wa.PORTAL_ADMIN,wa.DEVELOPER,wa.BETA_USER,wa.DEBUG_USER;const Sa=C`
|
|
1605
1605
|
`,Na=Ko.get({name:"ft-app-info",reducers:{setBaseUrl:(t,e)=>{t.baseUrl=e.payload},setApiIntegrationIdentifier:(t,e)=>{t.apiIntegrationIdentifier=e.payload},setUiLocale:(t,e)=>{t.uiLocale=e.payload},setAvailableUiLocales:(t,e)=>{t.availableUiLocales=e.payload},setEditorMode:(t,e)=>{t.editorMode=e.payload},setNoCustom:(t,e)=>{t.noCustom=e.payload},setNoCustomComponent:(t,e)=>{t.noCustomComponent=e.payload},setSession:(t,e)=>{t.session=e.payload}},initialState:{uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],editorMode:!1,noCustom:!1,noCustomComponent:!1}});class Ca{static build(t){const{baseUrl:e,apiIntegrationIdentifier:o}=Na.getState(),i=null!=t?t:o;if(e&&i&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(e,i,!0)}static get(t){var e;return null!=t?Ca.build(t):null!==(e=Ca.API)&&void 0!==e?e:Ca.API=Ca.build()}static await(t){return new Promise((e=>{let o=Ca.get(t);if(o)e(o);else{const i=Na.subscribe((()=>{o=Ca.get(t),o&&(i(),e(o))}))}}))}}var $a;const Ea=Symbol("clearAfterUnitTest");class ka{constructor(t){this.messageContextProvider=t,this.defaultMessages={},this.cache=new r,this.listeners={},this.currentUiLocale="",this[$a]=()=>{this.defaultMessages={},this.cache=new r,this.listeners={}},this.currentUiLocale=Na.getState().uiLocale,Na.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=Na.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const e=t.name.toLowerCase();this.cache.setFinal(e,t),this.notify(e)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,e){var o;if(t=t.toLowerCase(),Object.keys(e).length>0){const i={...null!==(o=this.defaultMessages[t])&&void 0!==o?o:{},...e};b(this.defaultMessages[t],i)||(this.defaultMessages[t]=i,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,e,...o){var i,r,n;t=t.toLowerCase(),this.fetchContext(t);const a=null!==(r=null===(i=this.cache.getNow(t))||void 0===i?void 0:i.messages)&&void 0!==r?r:{};return new Tt(null!==(n=this.defaultMessages[t])&&void 0!==n?n:{},a).resolve(e,...o)}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,e){var o;return t=t.toLowerCase(),this.listeners[t]=null!==(o=this.listeners[t])&&void 0!==o?o:new Set,this.listeners[t].add(e),()=>{var o;return null===(o=this.listeners[t])||void 0===o?void 0:o.delete(e)}}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=>d(0).then((()=>t())).catch((()=>null)))))}}$a=Ea,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new ka((async(t,e)=>(await Ca.await()).getFluidTopicsMessageContext(t,e)))),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new ka((async(t,e)=>(await Ca.await()).getCustomMessageContext(t,e))));const Ra=window.FluidTopicsI18nService,Ia=window.FluidTopicsCustomI18nService;var Ua=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class La extends Kt{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.availableUiLocales=[],this.editorMode=!1,this.noCustom=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>Ca.get(),this.cache=new r,this.cleanSessionDebouncer=new n}render(){return rt`
|
|
1606
1606
|
<slot></slot>
|
|
1607
|
-
`}update(t){super.update(t),t.has("baseUrl")&&Na.actions.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&Na.actions.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&Na.actions.setUiLocale(this.uiLocale),t.has("noCustom")&&Na.actions.setNoCustom(this.noCustom),t.has("editorMode")&&Na.actions.setEditorMode(this.editorMode),t.has("noCustomComponent")&&Na.actions.setNoCustomComponent(this.noCustomComponent),t.has("session")&&Na.actions.setSession(this.session),t.has("availableUiLocales")&&Na.actions.setAvailableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>Ra.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){const t=this.apiProvider();!this.withManualResources&&t&&(null==this.session&&(this.session=await this.cache.get("session",(async()=>{const e=await t.getCurrentSession();return e.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),e.idleTimeoutInMillis),e}))),null==this.availableUiLocales&&(this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>t.getAvailableUiLocales()))))}}La.elementDefinitions={},La.styles=Sa,Ua([s()],La.prototype,"baseUrl",void 0),Ua([s()],La.prototype,"apiIntegrationIdentifier",void 0),Ua([s()],La.prototype,"uiLocale",void 0),Ua([v([])],La.prototype,"availableUiLocales",void 0),Ua([s({type:Boolean})],La.prototype,"editorMode",void 0),Ua([s({type:Boolean})],La.prototype,"noCustom",void 0),Ua([s({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],La.prototype,"noCustomComponent",void 0),Ua([s({type:Boolean})],La.prototype,"withManualResources",void 0),Ua([v([])],La.prototype,"messageContexts",void 0),Ua([v(void 0)],La.prototype,"session",void 0),Ua([s({type:Object})],La.prototype,"apiProvider",void 0);class Wa{async listMySearches(){var t;return(null===(t=Na.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await Ca.await()).listMySearches(Na.getState().session.profile.userId):[]}}const Aa=new r;class ja{async listMyBookmarks(){return Aa.get("bookmarks",(async()=>(await Ca.await()).listMyBookmarks(Na.getState().session.profile.userId)))}clearCache(){Aa.clear("bookmarks")}}const Fa=Ko.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const Ba=new class{constructor(){this.currentSession=Na.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new ja,Na.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:e}=Na.getState();b(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==e?void 0:e.profile)||(this.currentSession=e,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){Fa.actions.savedSearches(void 0)}clearMyBookmarks(){Fa.actions.bookmarks(void 0)}async reloadMySearches(){const t=new Wa,e=await t.listMySearches();Fa.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const e=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;Fa.actions.bookmarks(e)}}};g("ft-app-context")(La);class Da{static async build(){return new Da(await Ca.await())}constructor(t){this.api=t,this.cache=new r,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")}}class za extends Event{constructor(){super(za.eventName)}}za.eventName="search-context-clear-all-filters";class Ka{static build(t){return new Ka((t=>Ko.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:la}))(t.trim()||"context"),Da.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.searchDebouncer=new n(100),this.suggestDebouncer=new n(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){for(;null==this.service;)await d(5);return this.service}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let e=this.store.getState().locales,o=this.store.getState().request.contentLocale;if(t!=o){if(e){const i=t=>e.some((e=>e.lang==t));i(t)||(t=i(o)?o:e[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 e=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(e),this.store.actions.setPageNumber(1),e.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(ba.TITLE_ONLY),this.store.actions.setRequestScope(Oa.DOCUMENTS)):(this.store.actions.setRequestVirtualField(ba.EVERYWHERE),this.store.actions.setRequestScope(Oa.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return(t=>t.request.virtualField===ba.TITLE_ONLY&&t.request.scope===Oa.DOCUMENTS)(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new za)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,e){let o=this.facetIds.filter((e=>e!=t));e&&o.push(e),this.facetIds=o,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let e=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(e)}setFilter(t,e){let o=this.store.getState().request.filters,i={key:t,values:e,negative:!1},r=[...o.filter((e=>e.key!==t)),i];this.setFilters(r)}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()}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,o;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel(),this.cancelableSearch=i(this.service.launchSearch(this.store.getState().request));const e=await this.cancelableSearch;if(e.paging.currentPage<=1)this.store.actions.setResults(e.results),this.store.actions.setFacets(e.facets),this.store.actions.setSpellcheck(e.spellcheck);else{let t=(null!==(o=this.store.getState().results)&&void 0!==o?o:[]).concat(e.results);this.store.actions.setResults(t)}this.store.actions.setPaging(e.paging)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{
|
|
1607
|
+
`}update(t){super.update(t),t.has("baseUrl")&&Na.actions.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&Na.actions.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&Na.actions.setUiLocale(this.uiLocale),t.has("noCustom")&&Na.actions.setNoCustom(this.noCustom),t.has("editorMode")&&Na.actions.setEditorMode(this.editorMode),t.has("noCustomComponent")&&Na.actions.setNoCustomComponent(this.noCustomComponent),t.has("session")&&Na.actions.setSession(this.session),t.has("availableUiLocales")&&Na.actions.setAvailableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>Ra.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){const t=this.apiProvider();!this.withManualResources&&t&&(null==this.session&&(this.session=await this.cache.get("session",(async()=>{const e=await t.getCurrentSession();return e.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),e.idleTimeoutInMillis),e}))),null==this.availableUiLocales&&(this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>t.getAvailableUiLocales()))))}}La.elementDefinitions={},La.styles=Sa,Ua([s()],La.prototype,"baseUrl",void 0),Ua([s()],La.prototype,"apiIntegrationIdentifier",void 0),Ua([s()],La.prototype,"uiLocale",void 0),Ua([v([])],La.prototype,"availableUiLocales",void 0),Ua([s({type:Boolean})],La.prototype,"editorMode",void 0),Ua([s({type:Boolean})],La.prototype,"noCustom",void 0),Ua([s({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],La.prototype,"noCustomComponent",void 0),Ua([s({type:Boolean})],La.prototype,"withManualResources",void 0),Ua([v([])],La.prototype,"messageContexts",void 0),Ua([v(void 0)],La.prototype,"session",void 0),Ua([s({type:Object})],La.prototype,"apiProvider",void 0);class Wa{async listMySearches(){var t;return(null===(t=Na.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await Ca.await()).listMySearches(Na.getState().session.profile.userId):[]}}const Aa=new r;class ja{async listMyBookmarks(){return Aa.get("bookmarks",(async()=>(await Ca.await()).listMyBookmarks(Na.getState().session.profile.userId)))}clearCache(){Aa.clear("bookmarks")}}const Fa=Ko.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});const Ba=new class{constructor(){this.currentSession=Na.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new ja,Na.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:e}=Na.getState();b(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==e?void 0:e.profile)||(this.currentSession=e,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){Fa.actions.savedSearches(void 0)}clearMyBookmarks(){Fa.actions.bookmarks(void 0)}async reloadMySearches(){const t=new Wa,e=await t.listMySearches();Fa.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const e=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;Fa.actions.bookmarks(e)}}};g("ft-app-context")(La);class Da{static async build(){return new Da(await Ca.await())}constructor(t){this.api=t,this.cache=new r,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")}}class za extends Event{constructor(){super(za.eventName)}}za.eventName="search-context-clear-all-filters";class Ka{static build(t){return new Ka((t=>Ko.get({name:"ft-search-"+t,initialState:{request:{query:"",filters:[],facets:[],sort:[],paging:{page:1,perPage:20}},liveQuery:""},reducers:la}))(t.trim()||"context"),Da.build)}constructor(t,e){this.store=t,this.serviceProvider=e,this.searchDebouncer=new n(100),this.suggestDebouncer=new n(300)}async initService(){return this.service=await this.serviceProvider(),this.store.actions.setLocales((await this.service.getAvailableSearchLocales()).contentLocales),this.launchSearch()}async awaitService(){for(;null==this.service;)await d(5);return this.service}setQuery(t){this.store.actions.setRequestQuery(t),this.store.actions.setLiveQuery(t),this.store.actions.setPageNumber(1),this.launchSearch()}setContentLocale(t){let e=this.store.getState().locales,o=this.store.getState().request.contentLocale;if(t!=o){if(e){const i=t=>e.some((e=>e.lang==t));i(t)||(t=i(o)?o:e[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 e=t.filter((t=>t.values.length>0));this.store.actions.setRequestFilters(e),this.store.actions.setPageNumber(1),e.forEach((t=>{this.facetIds.includes(t.key)||(this.facetIds=[...this.facetIds,t.key])})),this.launchSearch()}setSearchInDocumentTitlesOnly(t){t?(this.store.actions.setRequestVirtualField(ba.TITLE_ONLY),this.store.actions.setRequestScope(Oa.DOCUMENTS)):(this.store.actions.setRequestVirtualField(ba.EVERYWHERE),this.store.actions.setRequestScope(Oa.DEFAULT)),this.launchSearch()}get searchInDocumentTitlesOnly(){return(t=>t.request.virtualField===ba.TITLE_ONLY&&t.request.scope===Oa.DOCUMENTS)(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.eventBus.dispatchEvent(new za)}addFacet(t){this.facetIds=[...this.facetIds,t],this.launchSearch()}replaceFacet(t,e){let o=this.facetIds.filter((e=>e!=t));e&&o.push(e),this.facetIds=o,this.launchSearch()}get facetIds(){return this.store.getState().request.facets.map((t=>t.id))}set facetIds(t){let e=[...new Set(t)].map((t=>({id:t})));this.store.actions.setRequestFacets(e)}setFilter(t,e){let o=this.store.getState().request.filters,i={key:t,values:e,negative:!1},r=[...o.filter((e=>e.key!==t)),i];this.setFilters(r)}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()}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,o;try{null===(t=this.cancelableSearch)||void 0===t||t.cancel(),this.cancelableSearch=i(this.service.launchSearch(this.store.getState().request));const e=await this.cancelableSearch;if(e.paging.currentPage<=1)this.store.actions.setResults(e.results),this.store.actions.setFacets(e.facets),this.store.actions.setSpellcheck(e.spellcheck);else{let t=(null!==(o=this.store.getState().results)&&void 0!==o?o:[]).concat(e.results);this.store.actions.setResults(t)}this.store.actions.setPaging(e.paging)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}async fetchSuggestData(){var t;try{const e=this.store.getState(),o=e.request,r={input:e.liveQuery,filters:o.filters,sort:o.sort,contentLocale:o.contentLocale,scope:o.scope};null===(t=this.cancelableSuggest)||void 0===t||t.cancel(),this.cancelableSuggest=i(this.service.launchSuggest(r));let n=await this.cancelableSuggest;this.store.actions.setSuggestResults(n.suggestions)}catch(t){t instanceof e||!this.errorHandler||this.errorHandler(t)}}}var Pa=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class Ma extends Event{constructor(){super("register-ft-search-component",{bubbles:!0,composed:!0})}}const Ta=Symbol("registerInterval");class Za extends(function(t){var e;class o extends t{constructor(){super(...arguments),this[e]=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[Ta]=window.setInterval((()=>this.tryToRegisterToContext()),50)}tryToRegisterToContext(){null!=this.stateManager?window.clearInterval(this[Ta]):this.dispatchEvent(new Ma)}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return e=Ta,Pa([l()],o.prototype,"stateManager",void 0),o}(Xt)){}function _a(t){return t.rootNodes.map((t=>Ha(t)))}function Ha(t){return{label:t.label,value:t.value,selected:t.selected,subOptions:t.childNodes.map((t=>Ha(t)))}}const Ga=C`
|
|
1608
1608
|
`;var Va=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};const qa=Symbol("i18nProperties"),Ya=Symbol("i18nUnsubs");function Xa(t){var e;class o extends t{constructor(){super(...arguments),this.useCustomMessageContexts=!1,this[e]=new Map}get i18nService(){return this.useCustomMessageContexts?Ia:Ra}i18n(t,e,...o){var i;if("string"==typeof t)return this.i18nService.resolveMessage(t,e,...o);const r=null!==(i=t.args)&&void 0!==i?i:t.argsProvider?t.argsProvider(this):[];return this.i18nService.resolveMessage(t.context,t.key,...r)}onI18nUpdate(t){var e;null===(e=this[qa])||void 0===e||e.forEach(((e,o)=>{e.context.toLowerCase()===t.toLowerCase()&&(this[o]=this.i18n(e))})),setTimeout((()=>this.requestUpdate()),0)}update(t){var e;super.update(t),null===(e=this[qa])||void 0===e||e.forEach(((t,e)=>{null!=t.argsProvider&&(this[e]=this.i18n(t))}))}connectedCallback(){super.connectedCallback(),null!=this[qa]&&new Set([...this[qa].values()].map((t=>t.context))).forEach((t=>this.addI18nMessages(t)))}addI18nMessages(t,e){t=t.toLowerCase(),this[Ya].has(t)||this[Ya].set(t,this.i18nService.subscribe(t,(()=>this.onI18nUpdate(t)))),this.i18nService.prepareContext(t,null!=e?e:{})}addI18nContext(t,e){this.addI18nMessages(t.name,e)}disconnectedCallback(){super.disconnectedCallback(),this[Ya].forEach((t=>t())),this[Ya].clear()}}return e=Ya,Va([s({type:Boolean})],o.prototype,"useCustomMessageContexts",void 0),o}class Ja extends(Xa(Kt)){}class Qa extends(Xa(Xt)){}var ts=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class es extends Qa{constructor(){super(),this.editorMode=!1,this.addStore(Na)}render(){return this.key&&this.context?rt`
|
|
1609
1609
|
<span class="ft-i18n">
|
|
1610
1610
|
${this.i18n(this.context,this.key,...Array.isArray(this.args)?this.args:[])}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-search-facet",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.63",
|
|
4
4
|
"description": "Search facet for integrated search component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-filter": "1.0.
|
|
23
|
-
"@fluid-topics/ft-i18n": "1.0.
|
|
24
|
-
"@fluid-topics/ft-search-context": "1.0.
|
|
25
|
-
"@fluid-topics/ft-typography": "1.0.
|
|
26
|
-
"@fluid-topics/ft-wc-utils": "1.0.
|
|
22
|
+
"@fluid-topics/ft-filter": "1.0.63",
|
|
23
|
+
"@fluid-topics/ft-i18n": "1.0.63",
|
|
24
|
+
"@fluid-topics/ft-search-context": "1.0.63",
|
|
25
|
+
"@fluid-topics/ft-typography": "1.0.63",
|
|
26
|
+
"@fluid-topics/ft-wc-utils": "1.0.63",
|
|
27
27
|
"lit": "2.7.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@fluid-topics/public-api": "1.0.
|
|
30
|
+
"@fluid-topics/public-api": "1.0.50"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "020d13bf82a28437f4d7a7395ad9b628bc4342f1"
|
|
33
33
|
}
|