@fluid-topics/ft-reader-topic-content 1.1.49 → 1.1.51
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.
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
</i>
|
|
76
76
|
`}get textContent(){var t,e;return null!==(e=null===(t=this.slottedContent)||void 0===t?void 0:t.assignedNodes().map((t=>t.textContent)).join("").trim())&&void 0!==e?e:""}update(t){super.update(t),["value","variant"].some((e=>t.has(e)))&&this.resolveIcon()}resolveIcon(){var t,e;let s=this.value||this.textContent;switch(this.variant){case I.file_format:this.resolvedIcon=null!==(t=m[s.replace("-","_").toUpperCase()])&&void 0!==t?t:s;break;case I.material:this.resolvedIcon=this.value||i.nothing;break;default:this.resolvedIcon=null!==(e=f[s.replace("-","_").toUpperCase()])&&void 0!==e?e:s}}firstUpdated(t){super.firstUpdated(t),setTimeout((()=>this.resolveIcon()))}}O.elementDefinitions={},O.styles=k,j([s.property()],O.prototype,"variant",void 0),j([s.property()],O.prototype,"value",void 0),j([s.state()],O.prototype,"resolvedIcon",void 0),j([s.query("slot")],O.prototype,"slottedContent",void 0),e.customElement("ft-icon")(O);const S=i.css`
|
|
77
77
|
`,$=i.css`
|
|
78
|
-
`,M=e.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,openExternalDocumentInNewTab:!1}});class N{static
|
|
78
|
+
`,M=e.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,openExternalDocumentInNewTab:!1}});class N{static get(t){const{baseUrl:e,apiIntegrationIdentifier:i}=M.getState(),s=null!=t?t:i;if(e&&s&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(e,s,!0)}static await(t){return new Promise((e=>{let i=N.get(t);if(i)e(i);else{const s=M.subscribe((()=>{i=N.get(t),i&&(s(),e(i))}))}}))}}class U{constructor(t=!0,i){var s;this.overrideApi=i;let o=this.constructor;o.commonCache=null!==(s=o.commonCache)&&void 0!==s?s:new e.CacheRegistry,this.cache=t?o.commonCache:new e.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:N.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:N.await()}clearCache(){this.cache.clearAll()}}var A;const T=Symbol("clearAfterUnitTest");class B extends U{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[A]=()=>{this.defaultMessages={},this.cache=new e.CacheRegistry,this.listeners={}},this.currentUiLocale=M.getState().uiLocale,M.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=M.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,i){var s;if(t=t.toLowerCase(),Object.keys(i).length>0){const o={...null!==(s=this.defaultMessages[t])&&void 0!==s?s:{},...i};e.deepEqual(this.defaultMessages[t],o)||(this.defaultMessages[t]=o,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,i,...s){var o,n,a;t=t.toLowerCase(),this.fetchContext(t);const r=null!==(n=null===(o=this.cache.getNow(t))||void 0===o?void 0:o.messages)&&void 0!==n?n:{};return new e.ParametrizedLabelResolver(null!==(a=this.defaultMessages[t])&&void 0!==a?a:{},r).resolve(i,...s)}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 i;return t=t.toLowerCase(),this.listeners[t]=null!==(i=this.listeners[t])&&void 0!==i?i:new Set,this.listeners[t].add(e),()=>{var i;return null===(i=this.listeners[t])||void 0===i?void 0:i.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=>e.delay(0).then((()=>t())).catch((()=>null)))))}}A=T,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends B{constructor(){super((async(t,e)=>(await this.awaitApi).getFluidTopicsMessageContext(t,e)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends B{constructor(){super((async(t,e)=>(await this.awaitApi).getCustomMessageContext(t,e)))}});const L=window.FluidTopicsI18nService,E=window.FluidTopicsCustomI18nService;var z=function(t,e,i,s){for(var o,n=arguments.length,a=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,r=t.length-1;r>=0;r--)(o=t[r])&&(a=(n<3?o(a):n>3?o(e,i,a):o(e,i))||a);return n>3&&a&&Object.defineProperty(e,i,a),a};class P extends e.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>N.get(),this.cache=new e.CacheRegistry,this.cleanSessionDebouncer=new e.Debouncer}render(){return i.html`
|
|
79
79
|
<slot></slot>
|
|
80
80
|
`}update(t){super.update(t),t.has("baseUrl")&&(M.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&M.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&M.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&M.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&M.actions.noCustom(this.noCustom),t.has("editorMode")&&M.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&M.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&M.actions.session(this.session),t.has("availableUiLocales")&&M.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>L.addContext(t))),t.has("openExternalDocumentInNewTab")&&M.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab),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()))}}P.elementDefinitions={},P.styles=$,z([s.property()],P.prototype,"baseUrl",void 0),z([s.property()],P.prototype,"apiIntegrationIdentifier",void 0),z([s.property()],P.prototype,"uiLocale",void 0),z([e.jsonProperty(null)],P.prototype,"availableUiLocales",void 0),z([e.jsonProperty(null)],P.prototype,"metadataConfiguration",void 0),z([s.property({type:Boolean})],P.prototype,"editorMode",void 0),z([s.property({type:Boolean})],P.prototype,"noCustom",void 0),z([s.property({type:Boolean})],P.prototype,"openExternalDocumentInNewTab",void 0),z([s.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],P.prototype,"noCustomComponent",void 0),z([s.property({type:Boolean})],P.prototype,"withManualResources",void 0),z([e.jsonProperty([])],P.prototype,"messageContexts",void 0),z([e.jsonProperty(void 0)],P.prototype,"session",void 0),z([s.property({type:Object})],P.prototype,"apiProvider",void 0);class R extends U{async listMySearches(){let t=M.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class _ extends U{async listMyBookmarks(){let t=M.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const K=e.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});new class{constructor(){this.currentSession=M.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new _,this.savedSearchesService=new R,M.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:i}=M.getState();e.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==i?void 0:i.profile)||(this.currentSession=i,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),K.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),K.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();K.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 e=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;K.actions.bookmarks(e)}}},e.customElement("ft-app-context")(P);var D=function(t,e,i,s){for(var o,n=arguments.length,a=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,r=t.length-1;r>=0;r--)(o=t[r])&&(a=(n<3?o(a):n>3?o(e,i,a):o(e,i))||a);return n>3&&a&&Object.defineProperty(e,i,a),a};const G=Symbol("i18nAttributes"),W=Symbol("i18nProperties"),q=Symbol("i18nUnsubs");function F(t){var e;class i extends t{constructor(){super(...arguments),this.useCustomMessageContexts=!1,this[e]=new Map}get i18nService(){return this.useCustomMessageContexts?E:L}i18n(t,e,...i){var s;if("string"==typeof t)return this.i18nService.resolveMessage(t,e,...i);const o=null!==(s=t.args)&&void 0!==s?s:t.argsProvider?t.argsProvider(this):[];return this.i18nService.resolveMessage(t.context,t.key,...o)}onI18nUpdate(t){var e,i;null===(e=this[G])||void 0===e||e.forEach(((e,i)=>{var s;const o=this.getI18nAttributeValue(i);(null===(s=null==o?void 0:o.context)||void 0===s?void 0:s.toLowerCase())===t.toLowerCase()&&this.updateI18nAttributeMessage(i,o,e)})),null===(i=this[W])||void 0===i||i.forEach(((e,i)=>{e.context.toLowerCase()===t.toLowerCase()&&(this[i]=this.i18n(e))})),setTimeout((()=>this.requestUpdate()),0)}updateI18nAttributeMessage(t,e,i){this[t]={...e,message:this.i18n({context:e.context,key:e.key,...i})}}update(t){var e,i;super.update(t),null===(e=this[G])||void 0===e||e.forEach(((e,i)=>{const s=this.getI18nAttributeValue(i);(null==s?void 0:s.context)&&s.key&&(t.has(i)||null!=e.argsProvider)&&(t.has(i)&&this.addI18nContext(s.context),this.updateI18nAttributeMessage(i,s,e))})),null===(i=this[W])||void 0===i||i.forEach(((t,e)=>{null!=t.argsProvider&&(this[e]=this.i18n(t))}))}getI18nAttributeValue(t){return this[t]}connectedCallback(){var t,e,i,s;super.connectedCallback(),new Set([...null!==(e=null===(t=this[W])||void 0===t?void 0:t.values())&&void 0!==e?e:[],...[...null!==(s=null===(i=this[G])||void 0===i?void 0:i.keys())&&void 0!==s?s:[]].map((t=>this.getI18nAttributeValue(t)))].map((t=>null==t?void 0:t.context))).forEach((t=>t&&this.addI18nMessages(t)))}addI18nMessages(t,e){t=t.toLowerCase(),this[q].has(t)||this[q].set(t,this.i18nService.subscribe(t,(()=>this.onI18nUpdate(t)))),this.i18nService.prepareContext(t,null!=e?e:{})}addI18nContext(t,e){this.addI18nMessages("string"==typeof t?t:t.name,e)}disconnectedCallback(){super.disconnectedCallback(),this[q].forEach((t=>t())),this[q].clear()}}return e=q,D([s.property({type:Boolean})],i.prototype,"useCustomMessageContexts",void 0),i}class Q extends(F(e.FtLitElement)){}class V extends(F(e.FtLitElementRedux)){}var Z=function(t,e,i,s){for(var o,n=arguments.length,a=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,r=t.length-1;r>=0;r--)(o=t[r])&&(a=(n<3?o(a):n>3?o(e,i,a):o(e,i))||a);return n>3&&a&&Object.defineProperty(e,i,a),a};class H extends V{constructor(){super(),this.editorMode=!1,this.addStore(M)}render(){return this.key&&this.context?i.html`
|
|
81
81
|
<span class="ft-i18n">
|