@fluid-topics/ft-reader-feedback 1.3.52 → 1.3.53
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.
|
@@ -1967,7 +1967,7 @@ Also for action icons.`,l.colorGray200),contentGlobalSubtle:o.extend("--ftds-con
|
|
|
1967
1967
|
.variant=${this.iconVariant}
|
|
1968
1968
|
.value=${this.icon}
|
|
1969
1969
|
@click=${()=>{var e;return(e=this.input)===null||e===void 0?void 0:e.focus()}}></ft-icon>
|
|
1970
|
-
`:Te.nothing}update(e){super.update(e),(e.has("value")||e.has("filterSuggestions")||e.has("suggestionsProvider"))&&this.updateSuggestions(),e.has("value")&&e.get("value")!=null&&(this.hideSuggestions=!1),e.has("dispatchedValue")&&e.get("dispatchedValue")!=null&&(this.hideSuggestions=!0)}async updateSuggestions(){this.suggestionsProvider?this.providedSuggestions=await this.suggestionsProvider(this.value):this.filterSuggestionsIfNeeded()}filterSuggestionsIfNeeded(){this.filterSuggestions?(this.slottedSuggestions.forEach(e=>e.hidden=!e.getValue().toLowerCase().includes(this.value.toLowerCase())),this.visibleSuggestions=this.slottedSuggestions.filter(e=>!e.hidden)):this.visibleSuggestions=this.slottedSuggestions,this.newValueSuggestion&&(this.visibleSuggestions=[...this.visibleSuggestions,this.newValueSuggestion]),this.hideSuggestions=this.visibleSuggestions.length<=0}contentAvailableCallback(e){super.contentAvailableCallback(e),e.has("focused")&&!this.hideSuggestions&&this.visibleSuggestions.length>0&&this.setSuggestionPosition(),e.has("value")&&this.suggestionsProvider&&(this.visibleSuggestions=[...this.providedSuggestionsInDom]),e.has("autocomplete")&&this.setupWatchAutofill(),this.suggestionsShouldBeDisplayed()&&this.setSuggestionPosition()}setupWatchAutofill(){var e;this.clearWatchAutofill(),((e=this.autocomplete)!==null&&e!==void 0?e:"off")!=="off"&&(this.watchAutofillInterval=setInterval(()=>{var r,i,n;!((r=this.input)===null||r===void 0)&&r.matches(":autofill")&&this.dispatchedValue!==((i=this.input)===null||i===void 0?void 0:i.value)&&this.setValue((n=this.input)===null||n===void 0?void 0:n.value,!0)},200))}clearWatchAutofill(){this.watchAutofillInterval&&clearInterval(this.watchAutofillInterval)}connectedCallback(){super.connectedCallback(),this.setupWatchAutofill()}disconnectedCallback(){super.disconnectedCallback(),this.clearWatchAutofill()}setValue(e,r=!1){this.value!==e&&(this.setInternalValue(e),this.dispatchEvent(new CustomEvent("live-change",{detail:e}))),r&&this.dispatchedValue!==e&&(this.dispatchedValue=e,this.dispatchEvent(new CustomEvent("change",{detail:e})))}handleInput(e){var r;let i=((r=this.input)===null||r===void 0?void 0:r.value)||"";this.setValue(i,e.key=="Escape"||e.key=="Enter")}handleClick(){this.hideSuggestions=!1}handleKeyboardNavigation(e){var r;if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault(),e.stopPropagation(),this.hideSuggestions=!1;let i=this.visibleSuggestions.findIndex(a=>a.matches(":focus-within")),n;e.key==="ArrowDown"?n=i<this.visibleSuggestions.length-1?i+1:0:n=i>0?i-1:this.visibleSuggestions.length-1,(r=this.visibleSuggestions[n])===null||r===void 0||r.focus()}(e.key=="Escape"||e.key=="Enter")&&(this.hideSuggestions=!0)}onSuggestionSelected(e){var r;this.setValue(e.detail,!0),(r=this.input)===null||r===void 0||r.focus(),setTimeout(()=>this.hideSuggestions=!0,0)}onFocus(){this.focused=!0,this.hideSuggestions=!1}onMainPanelBlur(){var e,r;!((e=this.mainPanel)===null||e===void 0)&&e.matches(":focus-within")||(this.focused=!1,this.setValue(((r=this.input)===null||r===void 0?void 0:r.value)||"",!0))}togglePasswordVisibility(){this.hidePassword=!this.hidePassword}isPasswordField(){return this.password||this.type==="password"}setSuggestionPosition(){this.suggestionsContainer.style.width=this.mainPanel.getBoundingClientRect().width+"px";let e=["bottom","top"];(0,br.computeOffsetAutoPosition)(this.mainPanel,this.suggestionsContainer,"bottom",e,"fixed","--text-field-internal-suggest-size",0).then(({x:r,y:i})=>{this.suggestionsContainer.style.left=`${r}px`,this.suggestionsContainer.style.top=`${i}px`})}suggestionsShouldBeDisplayed(){return!this.hideSuggestions&&(this.visibleSuggestions.length||this.providedSuggestions.length)}};B.elementDefinitions={"ft-input-label":nt,"ft-ripple":Z,"ft-typography":ue,"ft-icon":he,"ft-text-field-suggestion":yt};B.styles=[Zr,br.noTextInputDefaultClearButton,_p];j([(0,z.property)()],B.prototype,"label",void 0);j([(0,z.property)({noAccessor:!0})],B.prototype,"value",null);j([(0,z.state)()],B.prototype,"dispatchedValue",void 0);j([(0,z.property)()],B.prototype,"helper",void 0);j([(0,z.property)()],B.prototype,"suggestionsHelper",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"outlined",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"disabled",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"error",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"fixedMenuPosition",void 0);j([(0,z.property)()],B.prototype,"prefix",void 0);j([(0,z.property)()],B.prototype,"icon",void 0);j([(0,z.property)()],B.prototype,"name",void 0);j([(0,z.property)()],B.prototype,"type",void 0);j([(0,z.property)()],B.prototype,"passwordHiddenIcon",void 0);j([(0,z.property)()],B.prototype,"passwordRevealedIcon",void 0);j([(0,z.property)()],B.prototype,"iconVariant",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"filterSuggestions",void 0);j([(0,z.property)({type:Number})],B.prototype,"maxLength",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"password",void 0);j([(0,z.property)({type:String})],B.prototype,"autocomplete",void 0);j([(0,z.property)({attribute:!1})],B.prototype,"suggestionsProvider",void 0);j([(0,z.state)()],B.prototype,"focused",void 0);j([(0,z.state)()],B.prototype,"hidePassword",void 0);j([(0,z.state)()],B.prototype,"hideSuggestions",void 0);j([(0,z.state)()],B.prototype,"visibleSuggestions",void 0);j([(0,z.state)()],B.prototype,"providedSuggestions",void 0);j([(0,z.query)(".ft-text-field--main-panel")],B.prototype,"mainPanel",void 0);j([(0,z.query)(".ft-text-field--input")],B.prototype,"input",void 0);j([(0,z.query)(".ft-text-field-suggestion--new-value")],B.prototype,"newValueSuggestion",void 0);j([(0,z.query)(".ft-text-field--suggestions")],B.prototype,"suggestionsContainer",void 0);j([(0,z.queryAll)("ft-text-field-suggestion")],B.prototype,"providedSuggestionsInDom",void 0);j([(0,z.queryAssignedElements)({selector:"ft-text-field-suggestion"})],B.prototype,"slottedSuggestions",void 0);(0,ms.customElement)("ft-text-field")(B);(0,ms.customElement)("ft-text-field-suggestion")(yt);var zp=m(R());var Qo=m($()),xr=m(K()),Je=m(R());var At=m(R());var $p=m(R()),wf={setTranslationDestinationLanguage:(t,e)=>{t.translation.destinationLanguage=e.payload},setTranslationSourceLanguage:(t,e)=>{t.translation.sourceLanguage=e.payload},setTranslationProfileId:(t,e)=>{t.translation.profileId=e.payload},setTranslationLoading:(t,e)=>{t.translation.isLoading=e.payload},setTranslationError:(t,e)=>{t.translation.isError=e.payload},setTopicsRating:(t,e)=>{for(let r in e.payload)t.topicsRating[r]=e.payload[r]}},Bp=t=>$p.FtReduxStore.get({name:"ft-reader-"+t,initialState:{mapId:void 0,renderedTopics:[],visibleTopics:[],map:void 0,toc:void 0,pagesToc:void 0,paginationConfiguration:void 0,currentPage:void 0,scrollTarget:void 0,configuration:void 0,searchInDocumentQuery:void 0,relatives:void 0,mapRating:void 0,topicsRating:{},translation:{sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}},reducers:wf});var bs=class{constructor(e,r){this.mapId=e,this.paginatedToc=r,this.nodeByTocId={},this.nodeByUrl={},this.duplicatedPrettyUrls=new Set,this.pages=[],this.pageByTocId={}}build(){return{paginationConfiguration:this.paginatedToc.configuration,toc:this.convertNodes(this.paginatedToc.paginatedToc,1),pagesToc:this.extractPagesToc(this.paginatedToc.paginatedToc,1),nodeByTocId:this.nodeByTocId,nodeByUrl:this.nodeByUrl,duplicatedPrettyUrls:this.duplicatedPrettyUrls,pages:this.pages,pageByTocId:this.pageByTocId,translationError:this.paginatedToc.translationError}}extractPagesToc(e,r,i){return e.flatMap(n=>{var a;return n.pageConfiguration&&this.registerPage(this.buildPage(n,i)),n.tocId==null?this.extractPagesToc(n.children,r,i):[{tocId:n.tocId,title:(a=n.title)!==null&&a!==void 0?a:"",untranslatedTitle:n.untranslatedTitle,depth:r,children:this.extractPagesToc(n.children,r+1,n.tocId)}]})}convertNodes(e,r,i){return e.flatMap(n=>{var a,s,c;if(n.tocId==null)return[...this.convertSectionNodes((a=n.pageToc)!==null&&a!==void 0?a:[],r,n.tocId),...this.convertNodes(n.children,r,n.tocId)];let p=(s=n.prettyUrl)===null||s===void 0?void 0:s.replace(/^\//,""),u={tocId:n.tocId,contentId:n.contentId,title:n.title,untranslatedTitle:n.untranslatedTitle,hasRating:n.hasRating,origin:n.origin,prettyUrl:p,depth:r,parentTocId:i,children:[]};this.register(u);let h=this.convertSectionNodes((c=n.pageToc)!==null&&c!==void 0?c:[],r+1,n.tocId),g=this.convertNodes(n.children,r+1,u.tocId);return u.children=[...h,...g],[u]})}convertSectionNodes(e,r,i){return e.flatMap(n=>{var a;let s=(a=n.prettyUrl)===null||a===void 0?void 0:a.replace(/^\//,""),c={...n,prettyUrl:s,depth:r,parentTocId:i,children:[]};return this.register(c),c.children=this.convertSectionNodes(n.children,r+1,n.tocId),[c]})}buildPage(e,r){var i,n,a,s,c,p;let u={number:this.pages.length+1,title:(i=e.title)!==null&&i!==void 0?i:"",untranslatedTitle:e.untranslatedTitle,rootTocId:(n=e.tocId)!==null&&n!==void 0?n:"root",toc:((a=e.pageToc)!==null&&a!==void 0?a:[]).map(b=>this.nodeByTocId[b.tocId]),topics:[],hiddenTopics:[],breadcrumb:r?this.buildBreadcrumb(this.nodeByTocId[r]):[]},h=(b,x)=>(x?u.topics:u.hiddenTopics).push(b),g=(c=(s=e.pageConfiguration)===null||s===void 0?void 0:s.parentsVisibility)!==null&&c!==void 0?c:[];return u.breadcrumb.forEach((b,x)=>{h(b,g[x])}),e.tocId&&h(e.tocId,e.pageConfiguration.isVisible),u.topics.push(...this.tocIds((p=e.pageToc)!==null&&p!==void 0?p:[])),u}registerPage(e){for(let r of[...e.topics,...e.hiddenTopics])this.pageByTocId[r]||(this.pageByTocId[r]=e);this.pages.push(e)}tocIds(e){return e.flatMap(r=>[r.tocId,...this.tocIds(r.children)])}buildBreadcrumb(e){let r=[e.tocId];for(;e?.parentTocId;)r.unshift(e.parentTocId),e=this.nodeByTocId[e.parentTocId];return r}register(e){e.prettyUrl&&(this.nodeByUrl[e.prettyUrl]==null?this.nodeByUrl[e.prettyUrl]=e:this.duplicatedPrettyUrls.add(e.prettyUrl)),this.nodeByUrl[`${this.mapId}/${e.tocId}`]=e,this.nodeByTocId[e.tocId]=e}},rn=class{convertPaginatedToc(e,r){return new bs(e,r).build()}};var on=class extends je{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,r,i){super(!1,r),this.converter=e,this._mapId=i,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.register("configuration",()=>this.api.getReaderConfiguration()),this.cache.register("map",()=>this.withMapId(e=>this.fetchMap(e))),this.cache.register("enrichedToc",()=>this.withMapId(e=>this.fetchPages(e).then(r=>this.converter.convertPaginatedToc(e,r)))),this.cache.register("ratingSummary",()=>{var e,r;return Ut((r=(e=E.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&r!==void 0?r:[],"RATING_USER")?this.withMapId(n=>this.fetchMapRating(n)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,r){return e+(r?"-destinationLanguage-"+r?.destinationLanguage:"")}getMap(e){return this.cache.get(this.makeCacheKey("map",e),()=>this.fetchMap(this.mapId,e))}getMapNow(e){return this.cache.getNow(this.makeCacheKey("map",e))}getConfiguration(){return this.cache.get("configuration")}clearConfiguration(){this.cache.clear("configuration")}getEnrichedToc(e){return this.cache.get(this.makeCacheKey("enrichedToc",e),()=>this.fetchPages(this.mapId,e).then(r=>this.converter.convertPaginatedToc(this.mapId,r)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e))}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(e){return(await this.getEnrichedToc(e)).toc}async getPagesToc(e){return(await this.getEnrichedToc(e)).pagesToc}async getTranslationError(e){return(await this.getEnrichedToc(e)).translationError}async getTocNode(e,r){return(await this.getEnrichedToc(r)).nodeByTocId[e]}getTocNodeNow(e,r){var i;return(i=this.getEnrichedTocNow(r))===null||i===void 0?void 0:i.nodeByTocId[e]}getTocNodeNowByUrl(e,r){var i,n;let a=this.getMapNow(r);return a?.prettyUrl==e||`${a?.id}/root`===e?(i=this.getEnrichedTocNow(r))===null||i===void 0?void 0:i.toc[0]:(n=this.getEnrichedTocNow(r))===null||n===void 0?void 0:n.nodeByUrl[e]}async getPage(e,r){let i=await this.getEnrichedToc(r);return i.pages[e-1]||i.pages[0]}async getPageByTocId(e,r){let i=await this.getEnrichedToc(r);return i.pageByTocId[e]||i.pages[0]}getTopicInfo(e){return this.cache.get("topic-"+e.tocId,()=>this.fetchTopicMetadata(e))}getTopicContent(e){return this.cache.get("topic-content-"+e.tocId,()=>this.fetchTopicHTMLContent(e))}getTranslatedTopicContent(e,r){return this.cache.get(this.makeCacheKey("translated-topic-content-"+e.tocId,r),()=>this.fetchTranslatedTopicHTMLContent(e,r))}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}clearMapAttachments(){this.cache.clear("map-attachments")}getRelativesForDocument(e,r){return this.cache.get("document-relatives-"+e+"-"+r.join("-"),()=>this.fetchRelativesForDocument(e,r))}getRelativesForTopicInMap(e,r,i){return this.cache.get("topic-relatives-"+[e,r,...i].join("-"),()=>this.fetchRelativesForTopicInMap(e,r,i))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,r,i){let n=this.getNavigationData(e,r,i),a=this.getReaderLinkPrefix()+(n.prettyUrl?n.prettyUrl:`${n.mapId}/${n.tocId}`),s=new URL(a,this.api.tenantBaseUrl);return n.page!=null&&s.searchParams.set("page",`${n.page}`),n.prettyUrlDuplicated&&s.searchParams.set("tocId",n.tocId),n.section!=null&&s.searchParams.set("section",n.section),s.href}getNavigationData(e,r,i,n){var a,s;e=e||"root";let c=this.getEnrichedTocNow(n),p=c?.pageByTocId[e],u=c?.nodeByTocId[e],h=u?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(a=u?.title)!==null&&a!==void 0?a:"",untranslatedTopicTitle:u?.untranslatedTitle,page:r&&p&&p.number!==r?r:void 0,prettyUrl:h?.replace(/^r\//,""),prettyUrlDuplicated:(s=c?.duplicatedPrettyUrls.has(h??""))!==null&&s!==void 0?s:!1,section:i}}async getAccurateNavigationData(e,r,i,n){return await this.getEnrichedToc(n),this.getNavigationData(e,r,i,n)}getRatingSummary(){return this.cache.get("ratingSummary")}reloadRating(){return this.cache.clear("ratingSummary"),this.getRatingSummary()}getMapRating(){return this.getRatingSummary().then(e=>e?.publication)}getTopicRating(e){return this.getRatingSummary().then(r=>{var i;return r?{type:r.topics.type,rating:(i=r.topics)===null||i===void 0?void 0:i.ratings.find(n=>n.tocId===e)}:void 0})}rateMap(e,r){return this.makeRateMapRequest(e,r).then(()=>this.clearRatingIfNecessary())}unrateMap(){return this.makeUnrateMapRequest().then(()=>this.clearRatingIfNecessary())}sendMapFeedback(e,r){return this.makeMapFeedbackRequest(e,r)}rateTopic(e,r,i){return this.makeRateTopicRequest(e,r,i).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=E.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,r,i){return this.makeTopicFeedbackRequest(e,r,i)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,r){let i=this.getTocNodeNow(e,r),n=[{tocId:i.tocId,title:i.title,untranslatedTitle:i.untranslatedTitle}],a=this.getTocNodeNow(i.parentTocId,r);for(;a;)n.unshift({tocId:a.tocId,title:a.title,untranslatedTitle:a.untranslatedTitle}),a=this.getTocNodeNow(a.parentTocId,r);return n}isFeatureAccessible(e,{session:r}){var i;if(!this.isFeatureAvailable(e))return!1;switch(e){case at.FEEDBACK:return Ut(r??[],re.FEEDBACK_USER);case at.RATING:return Ut(r??[],re.RATING_USER);case at.PRINT:return Ut(r??[],re.PRINT_USER);case at.BOOKMARK:return!!r?.sessionAuthenticated;case at.COLLECTIONS:return Ut(r??[],re.COLLECTION_USER);case at.PERSONAL_BOOKS:return Ut(r??[],re.PERSONAL_BOOK_USER)&&!(!((i=this.getMapNow())===null||i===void 0)&&i.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var nn=class t extends on{static async build(e){return new t(new rn,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,r){let i=await this.api.getMap(e,r);return this.fingerprint=i.fingerprint,i}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,r){return await this.getMap(r),this.api.getPages(e,this.fingerprint,r)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTranslatedTopicHTMLContent(e,r){return this.api.getTranslatedTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint,r)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,r){let i={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:r}}],sort:[],facets:[]};return this.api.search(i)}fetchRelativesForTopicInMap(e,r,i){let n={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:r,valueFilter:{negative:!1,values:i}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(n)}makeMapFeedbackRequest(e,r){return this.api.sendMapFeedback(this.mapId,e,r)}makeRateMapRequest(e,r){return this.api.rateMap(this.mapId,e,r)}makeRateTopicRequest(e,r,i){return this.api.rateTopic(this.mapId,e,r,i)}makeTopicFeedbackRequest(e,r,i){return this.api.sendTopicFeedback(this.mapId,e,r,i)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var an=class t{static build(e,r){return new t(Bp(e.trim()||"context"),r??nn.build)}loaded(){return(0,At.waitUntil)(()=>this._loaded)}constructor(e,r,i){this.store=e,this.clusteringHelperProvider=i,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new At.Debouncer(10),this.initService(r)}async initService(e){return this.service=await e(),this.service.mapId=this.store.getState().mapId,this.reload()}async setMapId(e){e!==this.store.getState().mapId&&(this.store.actions.mapId(e),this.service&&(this.service.mapId=e),await this.reload())}setRenderedTopics(e){this.store.actions.renderedTopics(e)}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return(0,At.waitFor)(()=>this.service)}async navigateToTopic(e,r,i){await this.loaded();let n=await this.awaitService(),a=await(i!=null?n.getPage(i,this.getTranslationSettings()):n.getPageByTocId(e??"root",this.getTranslationSettings()));this.store.actions.currentPage(a);let s=this.resolveValidNonRootTocId(e,a);this.store.actions.scrollTarget({tocId:s,section:r}),this.store.getState().visibleTopics[0]!==s&&this.store.actions.visibleTopics([])}resolveValidNonRootTocId(e,r){var i,n,a;let s=(i=e==="root"?void 0:e)!==null&&i!==void 0?i:r.rootTocId;return r.topics.includes(s)?s:(a=(n=r.topics[0])!==null&&n!==void 0?n:r.hiddenTopics[0])!==null&&a!==void 0?a:"root"}async navigateToPage(e){await this.loaded();let i=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(i)}scrollDone(){this.store.actions.scrollTarget({})}async load(){var e;!((e=this.service)===null||e===void 0)&&e.mapId&&this.store.getState().map==null&&await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}clear(){var e;this._loaded=!1,this.store.actions.configuration(void 0),this.store.actions.map(void 0),this.store.actions.toc(void 0),this.store.actions.pagesToc(void 0),this.store.actions.currentPage(void 0),this.store.actions.searchInDocumentQuery(""),this.store.actions.relatives(void 0),this.store.actions.renderedTopics([]),this.store.actions.visibleTopics([]),this.store.actions.translation({sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}),this.store.actions.mapRating(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(e){var r,i,n,a,s;try{e&&this.setTranslationLoading(!0);let c=p=>{throw e&&this.setTranslationError(!0),p};await Promise.all([this.loadConfiguration(),(r=this.service)===null||r===void 0?void 0:r.getMap(e).then(p=>this.store.actions.map(p)).catch(c),(i=this.service)===null||i===void 0?void 0:i.getToc(e).then(p=>this.store.actions.toc(p)).catch(c),(n=this.service)===null||n===void 0?void 0:n.getPagesToc(e).then(p=>this.store.actions.pagesToc(p)).catch(c),(a=this.service)===null||a===void 0?void 0:a.getPaginationConfiguration().then(p=>this.store.actions.paginationConfiguration(p)).catch(c),(s=this.service)===null||s===void 0?void 0:s.getTranslationError(e).then(p=>this.setTranslationError(p))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,e&&this.setTranslationLoading(!1)}catch(c){this.errorHandler&&!(c instanceof At.CanceledPromiseError)&&this.errorHandler(c)}}loadConfiguration(){var e;return(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(r=>this.store.actions.configuration(r))}reloadConfiguration(){var e;return(e=this.service)===null||e===void 0||e.clearConfiguration(),this.loadConfiguration()}fetchRelatives(){var e,r;let i=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(n=>{var a;return n.key==((a=this.store.getState().configuration)===null||a===void 0?void 0:a.relativePivotMetadata)}).flatMap(n=>n.values);i!==void 0&&i.length>0?(r=this.service)===null||r===void 0||r.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,i).then(n=>{let a=n.results.flatMap(s=>s.entries);this.store.actions.relatives(a),this.updateClusteringHelper()}):this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(Eo.clusteringHelperCreated))}createClusteringHelper(){var e,r;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let i=this.store.getState().relatives;if(i){let n=i.find(s=>{var c;return((c=s.map)===null||c===void 0?void 0:c.mapId)==this.store.getState().mapId}),a=(r=(e=E.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&r!==void 0?r:[];return new At.ClusteringHelper(i,n,this.metadataForSwitchToRelatives,a)}}async navigateToRelativeTopicIfFound(e){var r,i,n;await this.loaded();let a=await(0,At.waitFor)(()=>{var u;return(u=this.store.getState().configuration)===null||u===void 0?void 0:u.relativeTopicPivotMetadata}),s=this.store.getState().mapId,p=await(await this.awaitService()).getRelativesForTopicInMap(s,a,[e]);if(!((n=(i=(r=p?.results)===null||r===void 0?void 0:r[0])===null||i===void 0?void 0:i.entries)===null||n===void 0)&&n[0]){let u=p.results[0].entries[0].topic.tocId;return await this.navigateToTopic(u),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationProfileId(e){this.store.actions.setTranslationProfileId(e)}async setTranslationLoading(e){this.store.actions.setTranslationLoading(e)}async setTranslationError(e){this.store.actions.setTranslationError(e)}getTranslationSettings(){var e;let r=this.store.getState();return r.translation.profileId&&r.translation.destinationLanguage?{profileId:r.translation.profileId,destinationLanguage:r.translation.destinationLanguage.code,sourceLanguage:(e=r.map)===null||e===void 0?void 0:e.lang}:void 0}async fetchMapRating(){var e;this.store.actions.mapRating(await((e=this.service)===null||e===void 0?void 0:e.getMapRating()))}async fetchTopicRating(e){var r;let i=await((r=this.service)===null||r===void 0?void 0:r.getTopicRating(e));i&&this.store.actions.setTopicsRating({[e]:i})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}getAccurateNavigationData(e,r,i){return this.service.getAccurateNavigationData(e,r?.number,i?.section,this.getTranslationSettings())}buildBreadcrumb(e){var r;return(r=this.service)===null||r===void 0?void 0:r.buildBreadcrumb(e,this.getTranslationSettings())}fetchTopicContent(e){var r,i;let n=this.getTranslationSettings();return n?(r=this.service)===null||r===void 0?void 0:r.getTranslatedTopicContent(e,n).then(a=>(a.isTranslationError&&this.setTranslationError(!0),a.content)):(i=this.service)===null||i===void 0?void 0:i.getTopicContent(e)}getTocNode(e){return this.service.getTocNode(e,this.getTranslationSettings())}getPage(e){return this.service.getPage(e,this.getTranslationSettings())}onMapAttachmentsUpdate(){var e;(e=this.service)===null||e===void 0||e.clearMapAttachments(),this.store.dispatchEvent(new Event(Eo.mapAttachmentsUpdate))}};var Fp=m($());var Up=Fp.css`
|
|
1970
|
+
`:Te.nothing}update(e){super.update(e),(e.has("value")||e.has("filterSuggestions")||e.has("suggestionsProvider"))&&this.updateSuggestions(),e.has("value")&&e.get("value")!=null&&(this.hideSuggestions=!1),e.has("dispatchedValue")&&e.get("dispatchedValue")!=null&&(this.hideSuggestions=!0)}async updateSuggestions(){this.suggestionsProvider?this.providedSuggestions=await this.suggestionsProvider(this.value):this.filterSuggestionsIfNeeded()}filterSuggestionsIfNeeded(){this.filterSuggestions?(this.slottedSuggestions.forEach(e=>e.hidden=!e.getValue().toLowerCase().includes(this.value.toLowerCase())),this.visibleSuggestions=this.slottedSuggestions.filter(e=>!e.hidden)):this.visibleSuggestions=this.slottedSuggestions,this.newValueSuggestion&&(this.visibleSuggestions=[...this.visibleSuggestions,this.newValueSuggestion]),this.hideSuggestions=this.visibleSuggestions.length<=0}contentAvailableCallback(e){super.contentAvailableCallback(e),e.has("focused")&&!this.hideSuggestions&&this.visibleSuggestions.length>0&&this.setSuggestionPosition(),e.has("value")&&this.suggestionsProvider&&(this.visibleSuggestions=[...this.providedSuggestionsInDom]),e.has("autocomplete")&&this.setupWatchAutofill(),this.suggestionsShouldBeDisplayed()&&this.setSuggestionPosition()}setupWatchAutofill(){var e;this.clearWatchAutofill(),((e=this.autocomplete)!==null&&e!==void 0?e:"off")!=="off"&&(this.watchAutofillInterval=setInterval(()=>{var r,i,n;!((r=this.input)===null||r===void 0)&&r.matches(":autofill")&&this.dispatchedValue!==((i=this.input)===null||i===void 0?void 0:i.value)&&this.setValue((n=this.input)===null||n===void 0?void 0:n.value,!0)},200))}clearWatchAutofill(){this.watchAutofillInterval&&clearInterval(this.watchAutofillInterval)}connectedCallback(){super.connectedCallback(),this.setupWatchAutofill()}disconnectedCallback(){super.disconnectedCallback(),this.clearWatchAutofill()}setValue(e,r=!1){this.value!==e&&(this.setInternalValue(e),this.dispatchEvent(new CustomEvent("live-change",{detail:e}))),r&&this.dispatchedValue!==e&&(this.dispatchedValue=e,this.dispatchEvent(new CustomEvent("change",{detail:e})))}handleInput(e){var r;let i=((r=this.input)===null||r===void 0?void 0:r.value)||"";this.setValue(i,e.key=="Escape"||e.key=="Enter")}handleClick(){this.hideSuggestions=!1}handleKeyboardNavigation(e){var r;if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault(),e.stopPropagation(),this.hideSuggestions=!1;let i=this.visibleSuggestions.findIndex(a=>a.matches(":focus-within")),n;e.key==="ArrowDown"?n=i<this.visibleSuggestions.length-1?i+1:0:n=i>0?i-1:this.visibleSuggestions.length-1,(r=this.visibleSuggestions[n])===null||r===void 0||r.focus()}(e.key=="Escape"||e.key=="Enter")&&(this.hideSuggestions=!0)}onSuggestionSelected(e){var r;this.setValue(e.detail,!0),(r=this.input)===null||r===void 0||r.focus(),setTimeout(()=>this.hideSuggestions=!0,0)}onFocus(){this.focused=!0,this.hideSuggestions=!1}onMainPanelBlur(){var e,r;!((e=this.mainPanel)===null||e===void 0)&&e.matches(":focus-within")||(this.focused=!1,this.setValue(((r=this.input)===null||r===void 0?void 0:r.value)||"",!0))}togglePasswordVisibility(){this.hidePassword=!this.hidePassword}isPasswordField(){return this.password||this.type==="password"}setSuggestionPosition(){this.suggestionsContainer.style.width=this.mainPanel.getBoundingClientRect().width+"px";let e=["bottom","top"];(0,br.computeOffsetAutoPosition)(this.mainPanel,this.suggestionsContainer,"bottom",e,"fixed","--text-field-internal-suggest-size",0).then(({x:r,y:i})=>{this.suggestionsContainer.style.left=`${r}px`,this.suggestionsContainer.style.top=`${i}px`})}suggestionsShouldBeDisplayed(){return!this.hideSuggestions&&(this.visibleSuggestions.length||this.providedSuggestions.length)}};B.elementDefinitions={"ft-input-label":nt,"ft-ripple":Z,"ft-typography":ue,"ft-icon":he,"ft-text-field-suggestion":yt};B.styles=[Zr,br.noTextInputDefaultClearButton,_p];j([(0,z.property)()],B.prototype,"label",void 0);j([(0,z.property)({noAccessor:!0})],B.prototype,"value",null);j([(0,z.state)()],B.prototype,"dispatchedValue",void 0);j([(0,z.property)()],B.prototype,"helper",void 0);j([(0,z.property)()],B.prototype,"suggestionsHelper",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"outlined",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"disabled",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"error",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"fixedMenuPosition",void 0);j([(0,z.property)()],B.prototype,"prefix",void 0);j([(0,z.property)()],B.prototype,"icon",void 0);j([(0,z.property)()],B.prototype,"name",void 0);j([(0,z.property)()],B.prototype,"type",void 0);j([(0,z.property)()],B.prototype,"passwordHiddenIcon",void 0);j([(0,z.property)()],B.prototype,"passwordRevealedIcon",void 0);j([(0,z.property)()],B.prototype,"iconVariant",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"filterSuggestions",void 0);j([(0,z.property)({type:Number})],B.prototype,"maxLength",void 0);j([(0,z.property)({type:Boolean})],B.prototype,"password",void 0);j([(0,z.property)({type:String})],B.prototype,"autocomplete",void 0);j([(0,z.property)({attribute:!1})],B.prototype,"suggestionsProvider",void 0);j([(0,z.state)()],B.prototype,"focused",void 0);j([(0,z.state)()],B.prototype,"hidePassword",void 0);j([(0,z.state)()],B.prototype,"hideSuggestions",void 0);j([(0,z.state)()],B.prototype,"visibleSuggestions",void 0);j([(0,z.state)()],B.prototype,"providedSuggestions",void 0);j([(0,z.query)(".ft-text-field--main-panel")],B.prototype,"mainPanel",void 0);j([(0,z.query)(".ft-text-field--input")],B.prototype,"input",void 0);j([(0,z.query)(".ft-text-field-suggestion--new-value")],B.prototype,"newValueSuggestion",void 0);j([(0,z.query)(".ft-text-field--suggestions")],B.prototype,"suggestionsContainer",void 0);j([(0,z.queryAll)("ft-text-field-suggestion")],B.prototype,"providedSuggestionsInDom",void 0);j([(0,z.queryAssignedElements)({selector:"ft-text-field-suggestion"})],B.prototype,"slottedSuggestions",void 0);(0,ms.customElement)("ft-text-field")(B);(0,ms.customElement)("ft-text-field-suggestion")(yt);var zp=m(R());var Qo=m($()),xr=m(K()),Je=m(R());var At=m(R());var $p=m(R()),wf={setTranslationDestinationLanguage:(t,e)=>{t.translation.destinationLanguage=e.payload},setTranslationSourceLanguage:(t,e)=>{t.translation.sourceLanguage=e.payload},setTranslationProfileId:(t,e)=>{t.translation.profileId=e.payload},setTranslationLoading:(t,e)=>{t.translation.isLoading=e.payload},setTranslationError:(t,e)=>{t.translation.isError=e.payload},setTopicsRating:(t,e)=>{for(let r in e.payload)t.topicsRating[r]=e.payload[r]},setLinkPreviewDialogId:(t,e)=>{t.linkPreviewDialogId=e.payload}},Bp=t=>$p.FtReduxStore.get({name:"ft-reader-"+t,initialState:{mapId:void 0,renderedTopics:[],visibleTopics:[],map:void 0,toc:void 0,pagesToc:void 0,paginationConfiguration:void 0,currentPage:void 0,scrollTarget:void 0,configuration:void 0,searchInDocumentQuery:void 0,relatives:void 0,mapRating:void 0,topicsRating:{},translation:{sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1},linkPreviewDialogId:void 0},reducers:wf});var bs=class{constructor(e,r){this.mapId=e,this.paginatedToc=r,this.nodeByTocId={},this.nodeByUrl={},this.duplicatedPrettyUrls=new Set,this.pages=[],this.pageByTocId={}}build(){return{paginationConfiguration:this.paginatedToc.configuration,toc:this.convertNodes(this.paginatedToc.paginatedToc,1),pagesToc:this.extractPagesToc(this.paginatedToc.paginatedToc,1),nodeByTocId:this.nodeByTocId,nodeByUrl:this.nodeByUrl,duplicatedPrettyUrls:this.duplicatedPrettyUrls,pages:this.pages,pageByTocId:this.pageByTocId,translationError:this.paginatedToc.translationError}}extractPagesToc(e,r,i){return e.flatMap(n=>{var a;return n.pageConfiguration&&this.registerPage(this.buildPage(n,i)),n.tocId==null?this.extractPagesToc(n.children,r,i):[{tocId:n.tocId,title:(a=n.title)!==null&&a!==void 0?a:"",untranslatedTitle:n.untranslatedTitle,depth:r,children:this.extractPagesToc(n.children,r+1,n.tocId)}]})}convertNodes(e,r,i){return e.flatMap(n=>{var a,s,c;if(n.tocId==null)return[...this.convertSectionNodes((a=n.pageToc)!==null&&a!==void 0?a:[],r,n.tocId),...this.convertNodes(n.children,r,n.tocId)];let p=(s=n.prettyUrl)===null||s===void 0?void 0:s.replace(/^\//,""),u={tocId:n.tocId,contentId:n.contentId,title:n.title,untranslatedTitle:n.untranslatedTitle,hasRating:n.hasRating,origin:n.origin,prettyUrl:p,depth:r,parentTocId:i,children:[]};this.register(u);let h=this.convertSectionNodes((c=n.pageToc)!==null&&c!==void 0?c:[],r+1,n.tocId),g=this.convertNodes(n.children,r+1,u.tocId);return u.children=[...h,...g],[u]})}convertSectionNodes(e,r,i){return e.flatMap(n=>{var a;let s=(a=n.prettyUrl)===null||a===void 0?void 0:a.replace(/^\//,""),c={...n,prettyUrl:s,depth:r,parentTocId:i,children:[]};return this.register(c),c.children=this.convertSectionNodes(n.children,r+1,n.tocId),[c]})}buildPage(e,r){var i,n,a,s,c,p;let u={number:this.pages.length+1,title:(i=e.title)!==null&&i!==void 0?i:"",untranslatedTitle:e.untranslatedTitle,rootTocId:(n=e.tocId)!==null&&n!==void 0?n:"root",toc:((a=e.pageToc)!==null&&a!==void 0?a:[]).map(b=>this.nodeByTocId[b.tocId]),topics:[],hiddenTopics:[],breadcrumb:r?this.buildBreadcrumb(this.nodeByTocId[r]):[]},h=(b,x)=>(x?u.topics:u.hiddenTopics).push(b),g=(c=(s=e.pageConfiguration)===null||s===void 0?void 0:s.parentsVisibility)!==null&&c!==void 0?c:[];return u.breadcrumb.forEach((b,x)=>{h(b,g[x])}),e.tocId&&h(e.tocId,e.pageConfiguration.isVisible),u.topics.push(...this.tocIds((p=e.pageToc)!==null&&p!==void 0?p:[])),u}registerPage(e){for(let r of[...e.topics,...e.hiddenTopics])this.pageByTocId[r]||(this.pageByTocId[r]=e);this.pages.push(e)}tocIds(e){return e.flatMap(r=>[r.tocId,...this.tocIds(r.children)])}buildBreadcrumb(e){let r=[e.tocId];for(;e?.parentTocId;)r.unshift(e.parentTocId),e=this.nodeByTocId[e.parentTocId];return r}register(e){e.prettyUrl&&(this.nodeByUrl[e.prettyUrl]==null?this.nodeByUrl[e.prettyUrl]=e:this.duplicatedPrettyUrls.add(e.prettyUrl)),this.nodeByUrl[`${this.mapId}/${e.tocId}`]=e,this.nodeByTocId[e.tocId]=e}},rn=class{convertPaginatedToc(e,r){return new bs(e,r).build()}};var on=class extends je{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,r,i){super(!1,r),this.converter=e,this._mapId=i,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.register("configuration",()=>this.api.getReaderConfiguration()),this.cache.register("map",()=>this.withMapId(e=>this.fetchMap(e))),this.cache.register("enrichedToc",()=>this.withMapId(e=>this.fetchPages(e).then(r=>this.converter.convertPaginatedToc(e,r)))),this.cache.register("ratingSummary",()=>{var e,r;return Ut((r=(e=E.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&r!==void 0?r:[],"RATING_USER")?this.withMapId(n=>this.fetchMapRating(n)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,r){return e+(r?"-destinationLanguage-"+r?.destinationLanguage:"")}getMap(e){return this.cache.get(this.makeCacheKey("map",e),()=>this.fetchMap(this.mapId,e))}getMapNow(e){return this.cache.getNow(this.makeCacheKey("map",e))}getConfiguration(){return this.cache.get("configuration")}clearConfiguration(){this.cache.clear("configuration")}getEnrichedToc(e){return this.cache.get(this.makeCacheKey("enrichedToc",e),()=>this.fetchPages(this.mapId,e).then(r=>this.converter.convertPaginatedToc(this.mapId,r)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e))}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(e){return(await this.getEnrichedToc(e)).toc}async getPagesToc(e){return(await this.getEnrichedToc(e)).pagesToc}async getTranslationError(e){return(await this.getEnrichedToc(e)).translationError}async getTocNode(e,r){return(await this.getEnrichedToc(r)).nodeByTocId[e]}getTocNodeNow(e,r){var i;return(i=this.getEnrichedTocNow(r))===null||i===void 0?void 0:i.nodeByTocId[e]}getTocNodeNowByUrl(e,r){var i,n;let a=this.getMapNow(r);return a?.prettyUrl==e||`${a?.id}/root`===e?(i=this.getEnrichedTocNow(r))===null||i===void 0?void 0:i.toc[0]:(n=this.getEnrichedTocNow(r))===null||n===void 0?void 0:n.nodeByUrl[e]}async getPage(e,r){let i=await this.getEnrichedToc(r);return i.pages[e-1]||i.pages[0]}async getPageByTocId(e,r){let i=await this.getEnrichedToc(r);return i.pageByTocId[e]||i.pages[0]}getTopicInfo(e){return this.cache.get("topic-"+e.tocId,()=>this.fetchTopicMetadata(e))}getTopicContent(e){return this.cache.get("topic-content-"+e.tocId,()=>this.fetchTopicHTMLContent(e))}getTranslatedTopicContent(e,r){return this.cache.get(this.makeCacheKey("translated-topic-content-"+e.tocId,r),()=>this.fetchTranslatedTopicHTMLContent(e,r))}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}clearMapAttachments(){this.cache.clear("map-attachments")}getRelativesForDocument(e,r){return this.cache.get("document-relatives-"+e+"-"+r.join("-"),()=>this.fetchRelativesForDocument(e,r))}getRelativesForTopicInMap(e,r,i){return this.cache.get("topic-relatives-"+[e,r,...i].join("-"),()=>this.fetchRelativesForTopicInMap(e,r,i))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,r,i){let n=this.getNavigationData(e,r,i),a=this.getReaderLinkPrefix()+(n.prettyUrl?n.prettyUrl:`${n.mapId}/${n.tocId}`),s=new URL(a,this.api.tenantBaseUrl);return n.page!=null&&s.searchParams.set("page",`${n.page}`),n.prettyUrlDuplicated&&s.searchParams.set("tocId",n.tocId),n.section!=null&&s.searchParams.set("section",n.section),s.href}getNavigationData(e,r,i,n){var a,s;e=e||"root";let c=this.getEnrichedTocNow(n),p=c?.pageByTocId[e],u=c?.nodeByTocId[e],h=u?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(a=u?.title)!==null&&a!==void 0?a:"",untranslatedTopicTitle:u?.untranslatedTitle,page:r&&p&&p.number!==r?r:void 0,prettyUrl:h?.replace(/^r\//,""),prettyUrlDuplicated:(s=c?.duplicatedPrettyUrls.has(h??""))!==null&&s!==void 0?s:!1,section:i}}async getAccurateNavigationData(e,r,i,n){return await this.getEnrichedToc(n),this.getNavigationData(e,r,i,n)}getRatingSummary(){return this.cache.get("ratingSummary")}reloadRating(){return this.cache.clear("ratingSummary"),this.getRatingSummary()}getMapRating(){return this.getRatingSummary().then(e=>e?.publication)}getTopicRating(e){return this.getRatingSummary().then(r=>{var i;return r?{type:r.topics.type,rating:(i=r.topics)===null||i===void 0?void 0:i.ratings.find(n=>n.tocId===e)}:void 0})}rateMap(e,r){return this.makeRateMapRequest(e,r).then(()=>this.clearRatingIfNecessary())}unrateMap(){return this.makeUnrateMapRequest().then(()=>this.clearRatingIfNecessary())}sendMapFeedback(e,r){return this.makeMapFeedbackRequest(e,r)}rateTopic(e,r,i){return this.makeRateTopicRequest(e,r,i).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=E.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,r,i){return this.makeTopicFeedbackRequest(e,r,i)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,r){let i=this.getTocNodeNow(e,r),n=[{tocId:i.tocId,title:i.title,untranslatedTitle:i.untranslatedTitle}],a=this.getTocNodeNow(i.parentTocId,r);for(;a;)n.unshift({tocId:a.tocId,title:a.title,untranslatedTitle:a.untranslatedTitle}),a=this.getTocNodeNow(a.parentTocId,r);return n}isFeatureAccessible(e,{session:r}){var i;if(!this.isFeatureAvailable(e))return!1;switch(e){case at.FEEDBACK:return Ut(r??[],re.FEEDBACK_USER);case at.RATING:return Ut(r??[],re.RATING_USER);case at.PRINT:return Ut(r??[],re.PRINT_USER);case at.BOOKMARK:return!!r?.sessionAuthenticated;case at.COLLECTIONS:return Ut(r??[],re.COLLECTION_USER);case at.PERSONAL_BOOKS:return Ut(r??[],re.PERSONAL_BOOK_USER)&&!(!((i=this.getMapNow())===null||i===void 0)&&i.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var nn=class t extends on{static async build(e){return new t(new rn,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,r){let i=await this.api.getMap(e,r);return this.fingerprint=i.fingerprint,i}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,r){return await this.getMap(r),this.api.getPages(e,this.fingerprint,r)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTranslatedTopicHTMLContent(e,r){return this.api.getTranslatedTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint,r)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,r){let i={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:r}}],sort:[],facets:[]};return this.api.search(i)}fetchRelativesForTopicInMap(e,r,i){let n={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:r,valueFilter:{negative:!1,values:i}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(n)}makeMapFeedbackRequest(e,r){return this.api.sendMapFeedback(this.mapId,e,r)}makeRateMapRequest(e,r){return this.api.rateMap(this.mapId,e,r)}makeRateTopicRequest(e,r,i){return this.api.rateTopic(this.mapId,e,r,i)}makeTopicFeedbackRequest(e,r,i){return this.api.sendTopicFeedback(this.mapId,e,r,i)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var an=class t{static build(e,r){return new t(Bp(e.trim()||"context"),r??nn.build)}loaded(){return(0,At.waitUntil)(()=>this._loaded)}constructor(e,r,i){this.store=e,this.clusteringHelperProvider=i,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new At.Debouncer(10),this.initService(r)}async initService(e){return this.service=await e(),this.service.mapId=this.store.getState().mapId,this.reload()}async setMapId(e){e!==this.store.getState().mapId&&(this.store.actions.mapId(e),this.service&&(this.service.mapId=e),await this.reload())}setRenderedTopics(e){this.store.actions.renderedTopics(e)}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return(0,At.waitFor)(()=>this.service)}async navigateToTopic(e,r,i){await this.loaded();let n=await this.awaitService(),a=await(i!=null?n.getPage(i,this.getTranslationSettings()):n.getPageByTocId(e??"root",this.getTranslationSettings()));this.store.actions.currentPage(a);let s=this.resolveValidNonRootTocId(e,a);this.store.actions.scrollTarget({tocId:s,section:r}),this.store.getState().visibleTopics[0]!==s&&this.store.actions.visibleTopics([])}resolveValidNonRootTocId(e,r){var i,n,a;let s=(i=e==="root"?void 0:e)!==null&&i!==void 0?i:r.rootTocId;return r.topics.includes(s)?s:(a=(n=r.topics[0])!==null&&n!==void 0?n:r.hiddenTopics[0])!==null&&a!==void 0?a:"root"}async navigateToPage(e){await this.loaded();let i=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(i)}scrollDone(){this.store.actions.scrollTarget({})}async load(){var e;!((e=this.service)===null||e===void 0)&&e.mapId&&this.store.getState().map==null&&await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}clear(){var e;this._loaded=!1,this.store.actions.configuration(void 0),this.store.actions.map(void 0),this.store.actions.toc(void 0),this.store.actions.pagesToc(void 0),this.store.actions.currentPage(void 0),this.store.actions.searchInDocumentQuery(""),this.store.actions.relatives(void 0),this.store.actions.renderedTopics([]),this.store.actions.visibleTopics([]),this.store.actions.translation({sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}),this.store.actions.mapRating(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(e){var r,i,n,a,s;try{e&&this.setTranslationLoading(!0);let c=p=>{throw e&&this.setTranslationError(!0),p};await Promise.all([this.loadConfiguration(),(r=this.service)===null||r===void 0?void 0:r.getMap(e).then(p=>this.store.actions.map(p)).catch(c),(i=this.service)===null||i===void 0?void 0:i.getToc(e).then(p=>this.store.actions.toc(p)).catch(c),(n=this.service)===null||n===void 0?void 0:n.getPagesToc(e).then(p=>this.store.actions.pagesToc(p)).catch(c),(a=this.service)===null||a===void 0?void 0:a.getPaginationConfiguration().then(p=>this.store.actions.paginationConfiguration(p)).catch(c),(s=this.service)===null||s===void 0?void 0:s.getTranslationError(e).then(p=>this.setTranslationError(p))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,e&&this.setTranslationLoading(!1)}catch(c){this.errorHandler&&!(c instanceof At.CanceledPromiseError)&&this.errorHandler(c)}}loadConfiguration(){var e;return(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(r=>this.store.actions.configuration(r))}reloadConfiguration(){var e;return(e=this.service)===null||e===void 0||e.clearConfiguration(),this.loadConfiguration()}fetchRelatives(){var e,r;let i=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(n=>{var a;return n.key==((a=this.store.getState().configuration)===null||a===void 0?void 0:a.relativePivotMetadata)}).flatMap(n=>n.values);i!==void 0&&i.length>0?(r=this.service)===null||r===void 0||r.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,i).then(n=>{let a=n.results.flatMap(s=>s.entries);this.store.actions.relatives(a),this.updateClusteringHelper()}):this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(Eo.clusteringHelperCreated))}createClusteringHelper(){var e,r;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let i=this.store.getState().relatives;if(i){let n=i.find(s=>{var c;return((c=s.map)===null||c===void 0?void 0:c.mapId)==this.store.getState().mapId}),a=(r=(e=E.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&r!==void 0?r:[];return new At.ClusteringHelper(i,n,this.metadataForSwitchToRelatives,a)}}async navigateToRelativeTopicIfFound(e){var r,i,n;await this.loaded();let a=await(0,At.waitFor)(()=>{var u;return(u=this.store.getState().configuration)===null||u===void 0?void 0:u.relativeTopicPivotMetadata}),s=this.store.getState().mapId,p=await(await this.awaitService()).getRelativesForTopicInMap(s,a,[e]);if(!((n=(i=(r=p?.results)===null||r===void 0?void 0:r[0])===null||i===void 0?void 0:i.entries)===null||n===void 0)&&n[0]){let u=p.results[0].entries[0].topic.tocId;return await this.navigateToTopic(u),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationProfileId(e){this.store.actions.setTranslationProfileId(e)}async setTranslationLoading(e){this.store.actions.setTranslationLoading(e)}async setTranslationError(e){this.store.actions.setTranslationError(e)}getTranslationSettings(){var e;let r=this.store.getState();return r.translation.profileId&&r.translation.destinationLanguage?{profileId:r.translation.profileId,destinationLanguage:r.translation.destinationLanguage.code,sourceLanguage:(e=r.map)===null||e===void 0?void 0:e.lang}:void 0}setLinkPreviewDialogId(e){this.store.actions.setLinkPreviewDialogId(e)}async fetchMapRating(){var e;this.store.actions.mapRating(await((e=this.service)===null||e===void 0?void 0:e.getMapRating()))}async fetchTopicRating(e){var r;let i=await((r=this.service)===null||r===void 0?void 0:r.getTopicRating(e));i&&this.store.actions.setTopicsRating({[e]:i})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}getAccurateNavigationData(e,r,i){return this.service.getAccurateNavigationData(e,r?.number,i?.section,this.getTranslationSettings())}buildBreadcrumb(e){var r;return(r=this.service)===null||r===void 0?void 0:r.buildBreadcrumb(e,this.getTranslationSettings())}fetchTopicContent(e){var r,i;let n=this.getTranslationSettings();return n?(r=this.service)===null||r===void 0?void 0:r.getTranslatedTopicContent(e,n).then(a=>(a.isTranslationError&&this.setTranslationError(!0),a.content)):(i=this.service)===null||i===void 0?void 0:i.getTopicContent(e)}getTocNode(e){return this.service.getTocNode(e,this.getTranslationSettings())}getPage(e){return this.service.getPage(e,this.getTranslationSettings())}onMapAttachmentsUpdate(){var e;(e=this.service)===null||e===void 0||e.clearMapAttachments(),this.store.dispatchEvent(new Event(Eo.mapAttachmentsUpdate))}};var Fp=m($());var Up=Fp.css`
|
|
1971
1971
|
`;var sn=class extends CustomEvent{constructor(e,r){super("ft-reader-map-loaded",{detail:{map:e,toc:r}})}},ln=class extends CustomEvent{constructor(e,r){super("ft-reader-visible-topics-change",{detail:{visibleTopics:r}})}},cn=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},dn=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},pn=class extends Event{constructor(){super("ft-reader-map-not-found")}},un=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},fn=class extends Event{constructor(){super("ft-reader-map-forbidden")}},hn=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var gn=class{constructor(e){this.stateManager=e}searchInDocument(e){this.stateManager.setSearchInDocumentQuery(e??"")}};var et=function(t,e,r,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,i);else for(var c=t.length-1;c>=0;c--)(s=t[c])&&(a=(n<3?s(a):n>3?s(e,r,a):s(e,r))||a);return n>3&&a&&Object.defineProperty(e,r,a),a},Ef=t=>e=>+(e??"NaN")>0?+e:t,Re=class extends Je.FtLitElementRedux{constructor(){super(),this.visibleTopics=[],this.updateConfiguration=()=>{this.stateManager.reloadConfiguration()},this.scrollToTargetDebouncer=new Je.Debouncer(5),this.navigationDebouncer=new Je.Debouncer(10),this.mapLoadedEventDebouncer=new Je.Debouncer(50),this.addStore(E)}render(){return Qo.html`
|
|
1972
1972
|
${this.importStyleIfNeeded()}
|
|
1973
1973
|
<slot @register-ft-reader-component=${this.registerComponent}></slot>
|
|
@@ -2047,7 +2047,7 @@ Also for action icons.`,c.colorGray200),contentGlobalSubtle:o.extend("--ftds-con
|
|
|
2047
2047
|
.variant=${this.iconVariant}
|
|
2048
2048
|
.value=${this.icon}
|
|
2049
2049
|
@click=${()=>{var e;return(e=this.input)===null||e===void 0?void 0:e.focus()}}></ft-icon>
|
|
2050
|
-
`:F}update(e){super.update(e),(e.has("value")||e.has("filterSuggestions")||e.has("suggestionsProvider"))&&this.updateSuggestions(),e.has("value")&&e.get("value")!=null&&(this.hideSuggestions=!1),e.has("dispatchedValue")&&e.get("dispatchedValue")!=null&&(this.hideSuggestions=!0)}async updateSuggestions(){this.suggestionsProvider?this.providedSuggestions=await this.suggestionsProvider(this.value):this.filterSuggestionsIfNeeded()}filterSuggestionsIfNeeded(){this.filterSuggestions?(this.slottedSuggestions.forEach(e=>e.hidden=!e.getValue().toLowerCase().includes(this.value.toLowerCase())),this.visibleSuggestions=this.slottedSuggestions.filter(e=>!e.hidden)):this.visibleSuggestions=this.slottedSuggestions,this.newValueSuggestion&&(this.visibleSuggestions=[...this.visibleSuggestions,this.newValueSuggestion]),this.hideSuggestions=this.visibleSuggestions.length<=0}contentAvailableCallback(e){super.contentAvailableCallback(e),e.has("focused")&&!this.hideSuggestions&&this.visibleSuggestions.length>0&&this.setSuggestionPosition(),e.has("value")&&this.suggestionsProvider&&(this.visibleSuggestions=[...this.providedSuggestionsInDom]),e.has("autocomplete")&&this.setupWatchAutofill(),this.suggestionsShouldBeDisplayed()&&this.setSuggestionPosition()}setupWatchAutofill(){var e;this.clearWatchAutofill(),((e=this.autocomplete)!==null&&e!==void 0?e:"off")!=="off"&&(this.watchAutofillInterval=setInterval(()=>{var r,i,n;!((r=this.input)===null||r===void 0)&&r.matches(":autofill")&&this.dispatchedValue!==((i=this.input)===null||i===void 0?void 0:i.value)&&this.setValue((n=this.input)===null||n===void 0?void 0:n.value,!0)},200))}clearWatchAutofill(){this.watchAutofillInterval&&clearInterval(this.watchAutofillInterval)}connectedCallback(){super.connectedCallback(),this.setupWatchAutofill()}disconnectedCallback(){super.disconnectedCallback(),this.clearWatchAutofill()}setValue(e,r=!1){this.value!==e&&(this.setInternalValue(e),this.dispatchEvent(new CustomEvent("live-change",{detail:e}))),r&&this.dispatchedValue!==e&&(this.dispatchedValue=e,this.dispatchEvent(new CustomEvent("change",{detail:e})))}handleInput(e){var r;let i=((r=this.input)===null||r===void 0?void 0:r.value)||"";this.setValue(i,e.key=="Escape"||e.key=="Enter")}handleClick(){this.hideSuggestions=!1}handleKeyboardNavigation(e){var r;if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault(),e.stopPropagation(),this.hideSuggestions=!1;let i=this.visibleSuggestions.findIndex(a=>a.matches(":focus-within")),n;e.key==="ArrowDown"?n=i<this.visibleSuggestions.length-1?i+1:0:n=i>0?i-1:this.visibleSuggestions.length-1,(r=this.visibleSuggestions[n])===null||r===void 0||r.focus()}(e.key=="Escape"||e.key=="Enter")&&(this.hideSuggestions=!0)}onSuggestionSelected(e){var r;this.setValue(e.detail,!0),(r=this.input)===null||r===void 0||r.focus(),setTimeout(()=>this.hideSuggestions=!0,0)}onFocus(){this.focused=!0,this.hideSuggestions=!1}onMainPanelBlur(){var e,r;!((e=this.mainPanel)===null||e===void 0)&&e.matches(":focus-within")||(this.focused=!1,this.setValue(((r=this.input)===null||r===void 0?void 0:r.value)||"",!0))}togglePasswordVisibility(){this.hidePassword=!this.hidePassword}isPasswordField(){return this.password||this.type==="password"}setSuggestionPosition(){this.suggestionsContainer.style.width=this.mainPanel.getBoundingClientRect().width+"px";let e=["bottom","top"];rs(this.mainPanel,this.suggestionsContainer,"bottom",e,"fixed","--text-field-internal-suggest-size",0).then(({x:r,y:i})=>{this.suggestionsContainer.style.left=`${r}px`,this.suggestionsContainer.style.top=`${i}px`})}suggestionsShouldBeDisplayed(){return!this.hideSuggestions&&(this.visibleSuggestions.length||this.providedSuggestions.length)}};j.elementDefinitions={"ft-input-label":et,"ft-ripple":oe,"ft-typography":ve,"ft-icon":Se,"ft-text-field-suggestion":lt};j.styles=[ho,fs,Hp];ee([m()],j.prototype,"label",void 0);ee([m({noAccessor:!0})],j.prototype,"value",null);ee([U()],j.prototype,"dispatchedValue",void 0);ee([m()],j.prototype,"helper",void 0);ee([m()],j.prototype,"suggestionsHelper",void 0);ee([m({type:Boolean})],j.prototype,"outlined",void 0);ee([m({type:Boolean})],j.prototype,"disabled",void 0);ee([m({type:Boolean})],j.prototype,"error",void 0);ee([m({type:Boolean})],j.prototype,"fixedMenuPosition",void 0);ee([m()],j.prototype,"prefix",void 0);ee([m()],j.prototype,"icon",void 0);ee([m()],j.prototype,"name",void 0);ee([m()],j.prototype,"type",void 0);ee([m()],j.prototype,"passwordHiddenIcon",void 0);ee([m()],j.prototype,"passwordRevealedIcon",void 0);ee([m()],j.prototype,"iconVariant",void 0);ee([m({type:Boolean})],j.prototype,"filterSuggestions",void 0);ee([m({type:Number})],j.prototype,"maxLength",void 0);ee([m({type:Boolean})],j.prototype,"password",void 0);ee([m({type:String})],j.prototype,"autocomplete",void 0);ee([m({attribute:!1})],j.prototype,"suggestionsProvider",void 0);ee([U()],j.prototype,"focused",void 0);ee([U()],j.prototype,"hidePassword",void 0);ee([U()],j.prototype,"hideSuggestions",void 0);ee([U()],j.prototype,"visibleSuggestions",void 0);ee([U()],j.prototype,"providedSuggestions",void 0);ee([q(".ft-text-field--main-panel")],j.prototype,"mainPanel",void 0);ee([q(".ft-text-field--input")],j.prototype,"input",void 0);ee([q(".ft-text-field-suggestion--new-value")],j.prototype,"newValueSuggestion",void 0);ee([q(".ft-text-field--suggestions")],j.prototype,"suggestionsContainer",void 0);ee([fa("ft-text-field-suggestion")],j.prototype,"providedSuggestionsInDom",void 0);ee([ha({selector:"ft-text-field-suggestion"})],j.prototype,"slottedSuggestions",void 0);K("ft-text-field")(j);K("ft-text-field-suggestion")(lt);var Wh={setTranslationDestinationLanguage:(t,e)=>{t.translation.destinationLanguage=e.payload},setTranslationSourceLanguage:(t,e)=>{t.translation.sourceLanguage=e.payload},setTranslationProfileId:(t,e)=>{t.translation.profileId=e.payload},setTranslationLoading:(t,e)=>{t.translation.isLoading=e.payload},setTranslationError:(t,e)=>{t.translation.isError=e.payload},setTopicsRating:(t,e)=>{for(let r in e.payload)t.topicsRating[r]=e.payload[r]}},Wp=t=>Ut.get({name:"ft-reader-"+t,initialState:{mapId:void 0,renderedTopics:[],visibleTopics:[],map:void 0,toc:void 0,pagesToc:void 0,paginationConfiguration:void 0,currentPage:void 0,scrollTarget:void 0,configuration:void 0,searchInDocumentQuery:void 0,relatives:void 0,mapRating:void 0,topicsRating:{},translation:{sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}},reducers:Wh});var El=class{constructor(e,r){this.mapId=e,this.paginatedToc=r,this.nodeByTocId={},this.nodeByUrl={},this.duplicatedPrettyUrls=new Set,this.pages=[],this.pageByTocId={}}build(){return{paginationConfiguration:this.paginatedToc.configuration,toc:this.convertNodes(this.paginatedToc.paginatedToc,1),pagesToc:this.extractPagesToc(this.paginatedToc.paginatedToc,1),nodeByTocId:this.nodeByTocId,nodeByUrl:this.nodeByUrl,duplicatedPrettyUrls:this.duplicatedPrettyUrls,pages:this.pages,pageByTocId:this.pageByTocId,translationError:this.paginatedToc.translationError}}extractPagesToc(e,r,i){return e.flatMap(n=>{var a;return n.pageConfiguration&&this.registerPage(this.buildPage(n,i)),n.tocId==null?this.extractPagesToc(n.children,r,i):[{tocId:n.tocId,title:(a=n.title)!==null&&a!==void 0?a:"",untranslatedTitle:n.untranslatedTitle,depth:r,children:this.extractPagesToc(n.children,r+1,n.tocId)}]})}convertNodes(e,r,i){return e.flatMap(n=>{var a,s,l;if(n.tocId==null)return[...this.convertSectionNodes((a=n.pageToc)!==null&&a!==void 0?a:[],r,n.tocId),...this.convertNodes(n.children,r,n.tocId)];let d=(s=n.prettyUrl)===null||s===void 0?void 0:s.replace(/^\//,""),p={tocId:n.tocId,contentId:n.contentId,title:n.title,untranslatedTitle:n.untranslatedTitle,hasRating:n.hasRating,origin:n.origin,prettyUrl:d,depth:r,parentTocId:i,children:[]};this.register(p);let h=this.convertSectionNodes((l=n.pageToc)!==null&&l!==void 0?l:[],r+1,n.tocId),f=this.convertNodes(n.children,r+1,p.tocId);return p.children=[...h,...f],[p]})}convertSectionNodes(e,r,i){return e.flatMap(n=>{var a;let s=(a=n.prettyUrl)===null||a===void 0?void 0:a.replace(/^\//,""),l={...n,prettyUrl:s,depth:r,parentTocId:i,children:[]};return this.register(l),l.children=this.convertSectionNodes(n.children,r+1,n.tocId),[l]})}buildPage(e,r){var i,n,a,s,l,d;let p={number:this.pages.length+1,title:(i=e.title)!==null&&i!==void 0?i:"",untranslatedTitle:e.untranslatedTitle,rootTocId:(n=e.tocId)!==null&&n!==void 0?n:"root",toc:((a=e.pageToc)!==null&&a!==void 0?a:[]).map(g=>this.nodeByTocId[g.tocId]),topics:[],hiddenTopics:[],breadcrumb:r?this.buildBreadcrumb(this.nodeByTocId[r]):[]},h=(g,S)=>(S?p.topics:p.hiddenTopics).push(g),f=(l=(s=e.pageConfiguration)===null||s===void 0?void 0:s.parentsVisibility)!==null&&l!==void 0?l:[];return p.breadcrumb.forEach((g,S)=>{h(g,f[S])}),e.tocId&&h(e.tocId,e.pageConfiguration.isVisible),p.topics.push(...this.tocIds((d=e.pageToc)!==null&&d!==void 0?d:[])),p}registerPage(e){for(let r of[...e.topics,...e.hiddenTopics])this.pageByTocId[r]||(this.pageByTocId[r]=e);this.pages.push(e)}tocIds(e){return e.flatMap(r=>[r.tocId,...this.tocIds(r.children)])}buildBreadcrumb(e){let r=[e.tocId];for(;e?.parentTocId;)r.unshift(e.parentTocId),e=this.nodeByTocId[e.parentTocId];return r}register(e){e.prettyUrl&&(this.nodeByUrl[e.prettyUrl]==null?this.nodeByUrl[e.prettyUrl]=e:this.duplicatedPrettyUrls.add(e.prettyUrl)),this.nodeByUrl[`${this.mapId}/${e.tocId}`]=e,this.nodeByTocId[e.tocId]=e}},Nn=class{convertPaginatedToc(e,r){return new El(e,r).build()}};var Pn=class extends Ve{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,r,i){super(!1,r),this.converter=e,this._mapId=i,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.register("configuration",()=>this.api.getReaderConfiguration()),this.cache.register("map",()=>this.withMapId(e=>this.fetchMap(e))),this.cache.register("enrichedToc",()=>this.withMapId(e=>this.fetchPages(e).then(r=>this.converter.convertPaginatedToc(e,r)))),this.cache.register("ratingSummary",()=>{var e,r;return Ht((r=(e=N.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&r!==void 0?r:[],"RATING_USER")?this.withMapId(n=>this.fetchMapRating(n)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,r){return e+(r?"-destinationLanguage-"+r?.destinationLanguage:"")}getMap(e){return this.cache.get(this.makeCacheKey("map",e),()=>this.fetchMap(this.mapId,e))}getMapNow(e){return this.cache.getNow(this.makeCacheKey("map",e))}getConfiguration(){return this.cache.get("configuration")}clearConfiguration(){this.cache.clear("configuration")}getEnrichedToc(e){return this.cache.get(this.makeCacheKey("enrichedToc",e),()=>this.fetchPages(this.mapId,e).then(r=>this.converter.convertPaginatedToc(this.mapId,r)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e))}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(e){return(await this.getEnrichedToc(e)).toc}async getPagesToc(e){return(await this.getEnrichedToc(e)).pagesToc}async getTranslationError(e){return(await this.getEnrichedToc(e)).translationError}async getTocNode(e,r){return(await this.getEnrichedToc(r)).nodeByTocId[e]}getTocNodeNow(e,r){var i;return(i=this.getEnrichedTocNow(r))===null||i===void 0?void 0:i.nodeByTocId[e]}getTocNodeNowByUrl(e,r){var i,n;let a=this.getMapNow(r);return a?.prettyUrl==e||`${a?.id}/root`===e?(i=this.getEnrichedTocNow(r))===null||i===void 0?void 0:i.toc[0]:(n=this.getEnrichedTocNow(r))===null||n===void 0?void 0:n.nodeByUrl[e]}async getPage(e,r){let i=await this.getEnrichedToc(r);return i.pages[e-1]||i.pages[0]}async getPageByTocId(e,r){let i=await this.getEnrichedToc(r);return i.pageByTocId[e]||i.pages[0]}getTopicInfo(e){return this.cache.get("topic-"+e.tocId,()=>this.fetchTopicMetadata(e))}getTopicContent(e){return this.cache.get("topic-content-"+e.tocId,()=>this.fetchTopicHTMLContent(e))}getTranslatedTopicContent(e,r){return this.cache.get(this.makeCacheKey("translated-topic-content-"+e.tocId,r),()=>this.fetchTranslatedTopicHTMLContent(e,r))}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}clearMapAttachments(){this.cache.clear("map-attachments")}getRelativesForDocument(e,r){return this.cache.get("document-relatives-"+e+"-"+r.join("-"),()=>this.fetchRelativesForDocument(e,r))}getRelativesForTopicInMap(e,r,i){return this.cache.get("topic-relatives-"+[e,r,...i].join("-"),()=>this.fetchRelativesForTopicInMap(e,r,i))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,r,i){let n=this.getNavigationData(e,r,i),a=this.getReaderLinkPrefix()+(n.prettyUrl?n.prettyUrl:`${n.mapId}/${n.tocId}`),s=new URL(a,this.api.tenantBaseUrl);return n.page!=null&&s.searchParams.set("page",`${n.page}`),n.prettyUrlDuplicated&&s.searchParams.set("tocId",n.tocId),n.section!=null&&s.searchParams.set("section",n.section),s.href}getNavigationData(e,r,i,n){var a,s;e=e||"root";let l=this.getEnrichedTocNow(n),d=l?.pageByTocId[e],p=l?.nodeByTocId[e],h=p?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(a=p?.title)!==null&&a!==void 0?a:"",untranslatedTopicTitle:p?.untranslatedTitle,page:r&&d&&d.number!==r?r:void 0,prettyUrl:h?.replace(/^r\//,""),prettyUrlDuplicated:(s=l?.duplicatedPrettyUrls.has(h??""))!==null&&s!==void 0?s:!1,section:i}}async getAccurateNavigationData(e,r,i,n){return await this.getEnrichedToc(n),this.getNavigationData(e,r,i,n)}getRatingSummary(){return this.cache.get("ratingSummary")}reloadRating(){return this.cache.clear("ratingSummary"),this.getRatingSummary()}getMapRating(){return this.getRatingSummary().then(e=>e?.publication)}getTopicRating(e){return this.getRatingSummary().then(r=>{var i;return r?{type:r.topics.type,rating:(i=r.topics)===null||i===void 0?void 0:i.ratings.find(n=>n.tocId===e)}:void 0})}rateMap(e,r){return this.makeRateMapRequest(e,r).then(()=>this.clearRatingIfNecessary())}unrateMap(){return this.makeUnrateMapRequest().then(()=>this.clearRatingIfNecessary())}sendMapFeedback(e,r){return this.makeMapFeedbackRequest(e,r)}rateTopic(e,r,i){return this.makeRateTopicRequest(e,r,i).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=N.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,r,i){return this.makeTopicFeedbackRequest(e,r,i)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,r){let i=this.getTocNodeNow(e,r),n=[{tocId:i.tocId,title:i.title,untranslatedTitle:i.untranslatedTitle}],a=this.getTocNodeNow(i.parentTocId,r);for(;a;)n.unshift({tocId:a.tocId,title:a.title,untranslatedTitle:a.untranslatedTitle}),a=this.getTocNodeNow(a.parentTocId,r);return n}isFeatureAccessible(e,{session:r}){var i;if(!this.isFeatureAvailable(e))return!1;switch(e){case nt.FEEDBACK:return Ht(r??[],ce.FEEDBACK_USER);case nt.RATING:return Ht(r??[],ce.RATING_USER);case nt.PRINT:return Ht(r??[],ce.PRINT_USER);case nt.BOOKMARK:return!!r?.sessionAuthenticated;case nt.COLLECTIONS:return Ht(r??[],ce.COLLECTION_USER);case nt.PERSONAL_BOOKS:return Ht(r??[],ce.PERSONAL_BOOK_USER)&&!(!((i=this.getMapNow())===null||i===void 0)&&i.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var kn=class t extends Pn{static async build(e){return new t(new Nn,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,r){let i=await this.api.getMap(e,r);return this.fingerprint=i.fingerprint,i}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,r){return await this.getMap(r),this.api.getPages(e,this.fingerprint,r)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTranslatedTopicHTMLContent(e,r){return this.api.getTranslatedTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint,r)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,r){let i={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:r}}],sort:[],facets:[]};return this.api.search(i)}fetchRelativesForTopicInMap(e,r,i){let n={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:r,valueFilter:{negative:!1,values:i}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(n)}makeMapFeedbackRequest(e,r){return this.api.sendMapFeedback(this.mapId,e,r)}makeRateMapRequest(e,r){return this.api.rateMap(this.mapId,e,r)}makeRateTopicRequest(e,r,i){return this.api.rateTopic(this.mapId,e,r,i)}makeTopicFeedbackRequest(e,r,i){return this.api.sendTopicFeedback(this.mapId,e,r,i)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var Dn=class t{static build(e,r){return new t(Wp(e.trim()||"context"),r??kn.build)}loaded(){return Oa(()=>this._loaded)}constructor(e,r,i){this.store=e,this.clusteringHelperProvider=i,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new ge(10),this.initService(r)}async initService(e){return this.service=await e(),this.service.mapId=this.store.getState().mapId,this.reload()}async setMapId(e){e!==this.store.getState().mapId&&(this.store.actions.mapId(e),this.service&&(this.service.mapId=e),await this.reload())}setRenderedTopics(e){this.store.actions.renderedTopics(e)}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return ko(()=>this.service)}async navigateToTopic(e,r,i){await this.loaded();let n=await this.awaitService(),a=await(i!=null?n.getPage(i,this.getTranslationSettings()):n.getPageByTocId(e??"root",this.getTranslationSettings()));this.store.actions.currentPage(a);let s=this.resolveValidNonRootTocId(e,a);this.store.actions.scrollTarget({tocId:s,section:r}),this.store.getState().visibleTopics[0]!==s&&this.store.actions.visibleTopics([])}resolveValidNonRootTocId(e,r){var i,n,a;let s=(i=e==="root"?void 0:e)!==null&&i!==void 0?i:r.rootTocId;return r.topics.includes(s)?s:(a=(n=r.topics[0])!==null&&n!==void 0?n:r.hiddenTopics[0])!==null&&a!==void 0?a:"root"}async navigateToPage(e){await this.loaded();let i=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(i)}scrollDone(){this.store.actions.scrollTarget({})}async load(){var e;!((e=this.service)===null||e===void 0)&&e.mapId&&this.store.getState().map==null&&await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}clear(){var e;this._loaded=!1,this.store.actions.configuration(void 0),this.store.actions.map(void 0),this.store.actions.toc(void 0),this.store.actions.pagesToc(void 0),this.store.actions.currentPage(void 0),this.store.actions.searchInDocumentQuery(""),this.store.actions.relatives(void 0),this.store.actions.renderedTopics([]),this.store.actions.visibleTopics([]),this.store.actions.translation({sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}),this.store.actions.mapRating(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(e){var r,i,n,a,s;try{e&&this.setTranslationLoading(!0);let l=d=>{throw e&&this.setTranslationError(!0),d};await Promise.all([this.loadConfiguration(),(r=this.service)===null||r===void 0?void 0:r.getMap(e).then(d=>this.store.actions.map(d)).catch(l),(i=this.service)===null||i===void 0?void 0:i.getToc(e).then(d=>this.store.actions.toc(d)).catch(l),(n=this.service)===null||n===void 0?void 0:n.getPagesToc(e).then(d=>this.store.actions.pagesToc(d)).catch(l),(a=this.service)===null||a===void 0?void 0:a.getPaginationConfiguration().then(d=>this.store.actions.paginationConfiguration(d)).catch(l),(s=this.service)===null||s===void 0?void 0:s.getTranslationError(e).then(d=>this.setTranslationError(d))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,e&&this.setTranslationLoading(!1)}catch(l){this.errorHandler&&!(l instanceof _t)&&this.errorHandler(l)}}loadConfiguration(){var e;return(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(r=>this.store.actions.configuration(r))}reloadConfiguration(){var e;return(e=this.service)===null||e===void 0||e.clearConfiguration(),this.loadConfiguration()}fetchRelatives(){var e,r;let i=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(n=>{var a;return n.key==((a=this.store.getState().configuration)===null||a===void 0?void 0:a.relativePivotMetadata)}).flatMap(n=>n.values);i!==void 0&&i.length>0?(r=this.service)===null||r===void 0||r.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,i).then(n=>{let a=n.results.flatMap(s=>s.entries);this.store.actions.relatives(a),this.updateClusteringHelper()}):this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(ei.clusteringHelperCreated))}createClusteringHelper(){var e,r;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let i=this.store.getState().relatives;if(i){let n=i.find(s=>{var l;return((l=s.map)===null||l===void 0?void 0:l.mapId)==this.store.getState().mapId}),a=(r=(e=N.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&r!==void 0?r:[];return new Bo(i,n,this.metadataForSwitchToRelatives,a)}}async navigateToRelativeTopicIfFound(e){var r,i,n;await this.loaded();let a=await ko(()=>{var p;return(p=this.store.getState().configuration)===null||p===void 0?void 0:p.relativeTopicPivotMetadata}),s=this.store.getState().mapId,d=await(await this.awaitService()).getRelativesForTopicInMap(s,a,[e]);if(!((n=(i=(r=d?.results)===null||r===void 0?void 0:r[0])===null||i===void 0?void 0:i.entries)===null||n===void 0)&&n[0]){let p=d.results[0].entries[0].topic.tocId;return await this.navigateToTopic(p),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationProfileId(e){this.store.actions.setTranslationProfileId(e)}async setTranslationLoading(e){this.store.actions.setTranslationLoading(e)}async setTranslationError(e){this.store.actions.setTranslationError(e)}getTranslationSettings(){var e;let r=this.store.getState();return r.translation.profileId&&r.translation.destinationLanguage?{profileId:r.translation.profileId,destinationLanguage:r.translation.destinationLanguage.code,sourceLanguage:(e=r.map)===null||e===void 0?void 0:e.lang}:void 0}async fetchMapRating(){var e;this.store.actions.mapRating(await((e=this.service)===null||e===void 0?void 0:e.getMapRating()))}async fetchTopicRating(e){var r;let i=await((r=this.service)===null||r===void 0?void 0:r.getTopicRating(e));i&&this.store.actions.setTopicsRating({[e]:i})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}getAccurateNavigationData(e,r,i){return this.service.getAccurateNavigationData(e,r?.number,i?.section,this.getTranslationSettings())}buildBreadcrumb(e){var r;return(r=this.service)===null||r===void 0?void 0:r.buildBreadcrumb(e,this.getTranslationSettings())}fetchTopicContent(e){var r,i;let n=this.getTranslationSettings();return n?(r=this.service)===null||r===void 0?void 0:r.getTranslatedTopicContent(e,n).then(a=>(a.isTranslationError&&this.setTranslationError(!0),a.content)):(i=this.service)===null||i===void 0?void 0:i.getTopicContent(e)}getTocNode(e){return this.service.getTocNode(e,this.getTranslationSettings())}getPage(e){return this.service.getPage(e,this.getTranslationSettings())}onMapAttachmentsUpdate(){var e;(e=this.service)===null||e===void 0||e.clearMapAttachments(),this.store.dispatchEvent(new Event(ei.mapAttachmentsUpdate))}};var Vp=k`
|
|
2050
|
+
`:F}update(e){super.update(e),(e.has("value")||e.has("filterSuggestions")||e.has("suggestionsProvider"))&&this.updateSuggestions(),e.has("value")&&e.get("value")!=null&&(this.hideSuggestions=!1),e.has("dispatchedValue")&&e.get("dispatchedValue")!=null&&(this.hideSuggestions=!0)}async updateSuggestions(){this.suggestionsProvider?this.providedSuggestions=await this.suggestionsProvider(this.value):this.filterSuggestionsIfNeeded()}filterSuggestionsIfNeeded(){this.filterSuggestions?(this.slottedSuggestions.forEach(e=>e.hidden=!e.getValue().toLowerCase().includes(this.value.toLowerCase())),this.visibleSuggestions=this.slottedSuggestions.filter(e=>!e.hidden)):this.visibleSuggestions=this.slottedSuggestions,this.newValueSuggestion&&(this.visibleSuggestions=[...this.visibleSuggestions,this.newValueSuggestion]),this.hideSuggestions=this.visibleSuggestions.length<=0}contentAvailableCallback(e){super.contentAvailableCallback(e),e.has("focused")&&!this.hideSuggestions&&this.visibleSuggestions.length>0&&this.setSuggestionPosition(),e.has("value")&&this.suggestionsProvider&&(this.visibleSuggestions=[...this.providedSuggestionsInDom]),e.has("autocomplete")&&this.setupWatchAutofill(),this.suggestionsShouldBeDisplayed()&&this.setSuggestionPosition()}setupWatchAutofill(){var e;this.clearWatchAutofill(),((e=this.autocomplete)!==null&&e!==void 0?e:"off")!=="off"&&(this.watchAutofillInterval=setInterval(()=>{var r,i,n;!((r=this.input)===null||r===void 0)&&r.matches(":autofill")&&this.dispatchedValue!==((i=this.input)===null||i===void 0?void 0:i.value)&&this.setValue((n=this.input)===null||n===void 0?void 0:n.value,!0)},200))}clearWatchAutofill(){this.watchAutofillInterval&&clearInterval(this.watchAutofillInterval)}connectedCallback(){super.connectedCallback(),this.setupWatchAutofill()}disconnectedCallback(){super.disconnectedCallback(),this.clearWatchAutofill()}setValue(e,r=!1){this.value!==e&&(this.setInternalValue(e),this.dispatchEvent(new CustomEvent("live-change",{detail:e}))),r&&this.dispatchedValue!==e&&(this.dispatchedValue=e,this.dispatchEvent(new CustomEvent("change",{detail:e})))}handleInput(e){var r;let i=((r=this.input)===null||r===void 0?void 0:r.value)||"";this.setValue(i,e.key=="Escape"||e.key=="Enter")}handleClick(){this.hideSuggestions=!1}handleKeyboardNavigation(e){var r;if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault(),e.stopPropagation(),this.hideSuggestions=!1;let i=this.visibleSuggestions.findIndex(a=>a.matches(":focus-within")),n;e.key==="ArrowDown"?n=i<this.visibleSuggestions.length-1?i+1:0:n=i>0?i-1:this.visibleSuggestions.length-1,(r=this.visibleSuggestions[n])===null||r===void 0||r.focus()}(e.key=="Escape"||e.key=="Enter")&&(this.hideSuggestions=!0)}onSuggestionSelected(e){var r;this.setValue(e.detail,!0),(r=this.input)===null||r===void 0||r.focus(),setTimeout(()=>this.hideSuggestions=!0,0)}onFocus(){this.focused=!0,this.hideSuggestions=!1}onMainPanelBlur(){var e,r;!((e=this.mainPanel)===null||e===void 0)&&e.matches(":focus-within")||(this.focused=!1,this.setValue(((r=this.input)===null||r===void 0?void 0:r.value)||"",!0))}togglePasswordVisibility(){this.hidePassword=!this.hidePassword}isPasswordField(){return this.password||this.type==="password"}setSuggestionPosition(){this.suggestionsContainer.style.width=this.mainPanel.getBoundingClientRect().width+"px";let e=["bottom","top"];rs(this.mainPanel,this.suggestionsContainer,"bottom",e,"fixed","--text-field-internal-suggest-size",0).then(({x:r,y:i})=>{this.suggestionsContainer.style.left=`${r}px`,this.suggestionsContainer.style.top=`${i}px`})}suggestionsShouldBeDisplayed(){return!this.hideSuggestions&&(this.visibleSuggestions.length||this.providedSuggestions.length)}};j.elementDefinitions={"ft-input-label":et,"ft-ripple":oe,"ft-typography":ve,"ft-icon":Se,"ft-text-field-suggestion":lt};j.styles=[ho,fs,Hp];ee([m()],j.prototype,"label",void 0);ee([m({noAccessor:!0})],j.prototype,"value",null);ee([U()],j.prototype,"dispatchedValue",void 0);ee([m()],j.prototype,"helper",void 0);ee([m()],j.prototype,"suggestionsHelper",void 0);ee([m({type:Boolean})],j.prototype,"outlined",void 0);ee([m({type:Boolean})],j.prototype,"disabled",void 0);ee([m({type:Boolean})],j.prototype,"error",void 0);ee([m({type:Boolean})],j.prototype,"fixedMenuPosition",void 0);ee([m()],j.prototype,"prefix",void 0);ee([m()],j.prototype,"icon",void 0);ee([m()],j.prototype,"name",void 0);ee([m()],j.prototype,"type",void 0);ee([m()],j.prototype,"passwordHiddenIcon",void 0);ee([m()],j.prototype,"passwordRevealedIcon",void 0);ee([m()],j.prototype,"iconVariant",void 0);ee([m({type:Boolean})],j.prototype,"filterSuggestions",void 0);ee([m({type:Number})],j.prototype,"maxLength",void 0);ee([m({type:Boolean})],j.prototype,"password",void 0);ee([m({type:String})],j.prototype,"autocomplete",void 0);ee([m({attribute:!1})],j.prototype,"suggestionsProvider",void 0);ee([U()],j.prototype,"focused",void 0);ee([U()],j.prototype,"hidePassword",void 0);ee([U()],j.prototype,"hideSuggestions",void 0);ee([U()],j.prototype,"visibleSuggestions",void 0);ee([U()],j.prototype,"providedSuggestions",void 0);ee([q(".ft-text-field--main-panel")],j.prototype,"mainPanel",void 0);ee([q(".ft-text-field--input")],j.prototype,"input",void 0);ee([q(".ft-text-field-suggestion--new-value")],j.prototype,"newValueSuggestion",void 0);ee([q(".ft-text-field--suggestions")],j.prototype,"suggestionsContainer",void 0);ee([fa("ft-text-field-suggestion")],j.prototype,"providedSuggestionsInDom",void 0);ee([ha({selector:"ft-text-field-suggestion"})],j.prototype,"slottedSuggestions",void 0);K("ft-text-field")(j);K("ft-text-field-suggestion")(lt);var Wh={setTranslationDestinationLanguage:(t,e)=>{t.translation.destinationLanguage=e.payload},setTranslationSourceLanguage:(t,e)=>{t.translation.sourceLanguage=e.payload},setTranslationProfileId:(t,e)=>{t.translation.profileId=e.payload},setTranslationLoading:(t,e)=>{t.translation.isLoading=e.payload},setTranslationError:(t,e)=>{t.translation.isError=e.payload},setTopicsRating:(t,e)=>{for(let r in e.payload)t.topicsRating[r]=e.payload[r]},setLinkPreviewDialogId:(t,e)=>{t.linkPreviewDialogId=e.payload}},Wp=t=>Ut.get({name:"ft-reader-"+t,initialState:{mapId:void 0,renderedTopics:[],visibleTopics:[],map:void 0,toc:void 0,pagesToc:void 0,paginationConfiguration:void 0,currentPage:void 0,scrollTarget:void 0,configuration:void 0,searchInDocumentQuery:void 0,relatives:void 0,mapRating:void 0,topicsRating:{},translation:{sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1},linkPreviewDialogId:void 0},reducers:Wh});var El=class{constructor(e,r){this.mapId=e,this.paginatedToc=r,this.nodeByTocId={},this.nodeByUrl={},this.duplicatedPrettyUrls=new Set,this.pages=[],this.pageByTocId={}}build(){return{paginationConfiguration:this.paginatedToc.configuration,toc:this.convertNodes(this.paginatedToc.paginatedToc,1),pagesToc:this.extractPagesToc(this.paginatedToc.paginatedToc,1),nodeByTocId:this.nodeByTocId,nodeByUrl:this.nodeByUrl,duplicatedPrettyUrls:this.duplicatedPrettyUrls,pages:this.pages,pageByTocId:this.pageByTocId,translationError:this.paginatedToc.translationError}}extractPagesToc(e,r,i){return e.flatMap(n=>{var a;return n.pageConfiguration&&this.registerPage(this.buildPage(n,i)),n.tocId==null?this.extractPagesToc(n.children,r,i):[{tocId:n.tocId,title:(a=n.title)!==null&&a!==void 0?a:"",untranslatedTitle:n.untranslatedTitle,depth:r,children:this.extractPagesToc(n.children,r+1,n.tocId)}]})}convertNodes(e,r,i){return e.flatMap(n=>{var a,s,l;if(n.tocId==null)return[...this.convertSectionNodes((a=n.pageToc)!==null&&a!==void 0?a:[],r,n.tocId),...this.convertNodes(n.children,r,n.tocId)];let d=(s=n.prettyUrl)===null||s===void 0?void 0:s.replace(/^\//,""),p={tocId:n.tocId,contentId:n.contentId,title:n.title,untranslatedTitle:n.untranslatedTitle,hasRating:n.hasRating,origin:n.origin,prettyUrl:d,depth:r,parentTocId:i,children:[]};this.register(p);let h=this.convertSectionNodes((l=n.pageToc)!==null&&l!==void 0?l:[],r+1,n.tocId),f=this.convertNodes(n.children,r+1,p.tocId);return p.children=[...h,...f],[p]})}convertSectionNodes(e,r,i){return e.flatMap(n=>{var a;let s=(a=n.prettyUrl)===null||a===void 0?void 0:a.replace(/^\//,""),l={...n,prettyUrl:s,depth:r,parentTocId:i,children:[]};return this.register(l),l.children=this.convertSectionNodes(n.children,r+1,n.tocId),[l]})}buildPage(e,r){var i,n,a,s,l,d;let p={number:this.pages.length+1,title:(i=e.title)!==null&&i!==void 0?i:"",untranslatedTitle:e.untranslatedTitle,rootTocId:(n=e.tocId)!==null&&n!==void 0?n:"root",toc:((a=e.pageToc)!==null&&a!==void 0?a:[]).map(g=>this.nodeByTocId[g.tocId]),topics:[],hiddenTopics:[],breadcrumb:r?this.buildBreadcrumb(this.nodeByTocId[r]):[]},h=(g,S)=>(S?p.topics:p.hiddenTopics).push(g),f=(l=(s=e.pageConfiguration)===null||s===void 0?void 0:s.parentsVisibility)!==null&&l!==void 0?l:[];return p.breadcrumb.forEach((g,S)=>{h(g,f[S])}),e.tocId&&h(e.tocId,e.pageConfiguration.isVisible),p.topics.push(...this.tocIds((d=e.pageToc)!==null&&d!==void 0?d:[])),p}registerPage(e){for(let r of[...e.topics,...e.hiddenTopics])this.pageByTocId[r]||(this.pageByTocId[r]=e);this.pages.push(e)}tocIds(e){return e.flatMap(r=>[r.tocId,...this.tocIds(r.children)])}buildBreadcrumb(e){let r=[e.tocId];for(;e?.parentTocId;)r.unshift(e.parentTocId),e=this.nodeByTocId[e.parentTocId];return r}register(e){e.prettyUrl&&(this.nodeByUrl[e.prettyUrl]==null?this.nodeByUrl[e.prettyUrl]=e:this.duplicatedPrettyUrls.add(e.prettyUrl)),this.nodeByUrl[`${this.mapId}/${e.tocId}`]=e,this.nodeByTocId[e.tocId]=e}},Nn=class{convertPaginatedToc(e,r){return new El(e,r).build()}};var Pn=class extends Ve{get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,r,i){super(!1,r),this.converter=e,this._mapId=i,this.initCache()}async withMapId(e){return this._mapId?e(this._mapId):void 0}initCache(){this.cache.register("configuration",()=>this.api.getReaderConfiguration()),this.cache.register("map",()=>this.withMapId(e=>this.fetchMap(e))),this.cache.register("enrichedToc",()=>this.withMapId(e=>this.fetchPages(e).then(r=>this.converter.convertPaginatedToc(e,r)))),this.cache.register("ratingSummary",()=>{var e,r;return Ht((r=(e=N.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&r!==void 0?r:[],"RATING_USER")?this.withMapId(n=>this.fetchMapRating(n)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,r){return e+(r?"-destinationLanguage-"+r?.destinationLanguage:"")}getMap(e){return this.cache.get(this.makeCacheKey("map",e),()=>this.fetchMap(this.mapId,e))}getMapNow(e){return this.cache.getNow(this.makeCacheKey("map",e))}getConfiguration(){return this.cache.get("configuration")}clearConfiguration(){this.cache.clear("configuration")}getEnrichedToc(e){return this.cache.get(this.makeCacheKey("enrichedToc",e),()=>this.fetchPages(this.mapId,e).then(r=>this.converter.convertPaginatedToc(this.mapId,r)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e))}async getPaginationConfiguration(){return(await this.getEnrichedToc()).paginationConfiguration}async getToc(e){return(await this.getEnrichedToc(e)).toc}async getPagesToc(e){return(await this.getEnrichedToc(e)).pagesToc}async getTranslationError(e){return(await this.getEnrichedToc(e)).translationError}async getTocNode(e,r){return(await this.getEnrichedToc(r)).nodeByTocId[e]}getTocNodeNow(e,r){var i;return(i=this.getEnrichedTocNow(r))===null||i===void 0?void 0:i.nodeByTocId[e]}getTocNodeNowByUrl(e,r){var i,n;let a=this.getMapNow(r);return a?.prettyUrl==e||`${a?.id}/root`===e?(i=this.getEnrichedTocNow(r))===null||i===void 0?void 0:i.toc[0]:(n=this.getEnrichedTocNow(r))===null||n===void 0?void 0:n.nodeByUrl[e]}async getPage(e,r){let i=await this.getEnrichedToc(r);return i.pages[e-1]||i.pages[0]}async getPageByTocId(e,r){let i=await this.getEnrichedToc(r);return i.pageByTocId[e]||i.pages[0]}getTopicInfo(e){return this.cache.get("topic-"+e.tocId,()=>this.fetchTopicMetadata(e))}getTopicContent(e){return this.cache.get("topic-content-"+e.tocId,()=>this.fetchTopicHTMLContent(e))}getTranslatedTopicContent(e,r){return this.cache.get(this.makeCacheKey("translated-topic-content-"+e.tocId,r),()=>this.fetchTranslatedTopicHTMLContent(e,r))}getAttachments(){return this.cache.get("map-attachments",()=>this.fetchAttachments())}clearMapAttachments(){this.cache.clear("map-attachments")}getRelativesForDocument(e,r){return this.cache.get("document-relatives-"+e+"-"+r.join("-"),()=>this.fetchRelativesForDocument(e,r))}getRelativesForTopicInMap(e,r,i){return this.cache.get("topic-relatives-"+[e,r,...i].join("-"),()=>this.fetchRelativesForTopicInMap(e,r,i))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,r,i){let n=this.getNavigationData(e,r,i),a=this.getReaderLinkPrefix()+(n.prettyUrl?n.prettyUrl:`${n.mapId}/${n.tocId}`),s=new URL(a,this.api.tenantBaseUrl);return n.page!=null&&s.searchParams.set("page",`${n.page}`),n.prettyUrlDuplicated&&s.searchParams.set("tocId",n.tocId),n.section!=null&&s.searchParams.set("section",n.section),s.href}getNavigationData(e,r,i,n){var a,s;e=e||"root";let l=this.getEnrichedTocNow(n),d=l?.pageByTocId[e],p=l?.nodeByTocId[e],h=p?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(a=p?.title)!==null&&a!==void 0?a:"",untranslatedTopicTitle:p?.untranslatedTitle,page:r&&d&&d.number!==r?r:void 0,prettyUrl:h?.replace(/^r\//,""),prettyUrlDuplicated:(s=l?.duplicatedPrettyUrls.has(h??""))!==null&&s!==void 0?s:!1,section:i}}async getAccurateNavigationData(e,r,i,n){return await this.getEnrichedToc(n),this.getNavigationData(e,r,i,n)}getRatingSummary(){return this.cache.get("ratingSummary")}reloadRating(){return this.cache.clear("ratingSummary"),this.getRatingSummary()}getMapRating(){return this.getRatingSummary().then(e=>e?.publication)}getTopicRating(e){return this.getRatingSummary().then(r=>{var i;return r?{type:r.topics.type,rating:(i=r.topics)===null||i===void 0?void 0:i.ratings.find(n=>n.tocId===e)}:void 0})}rateMap(e,r){return this.makeRateMapRequest(e,r).then(()=>this.clearRatingIfNecessary())}unrateMap(){return this.makeUnrateMapRequest().then(()=>this.clearRatingIfNecessary())}sendMapFeedback(e,r){return this.makeMapFeedbackRequest(e,r)}rateTopic(e,r,i){return this.makeRateTopicRequest(e,r,i).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=N.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,r,i){return this.makeTopicFeedbackRequest(e,r,i)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,r){let i=this.getTocNodeNow(e,r),n=[{tocId:i.tocId,title:i.title,untranslatedTitle:i.untranslatedTitle}],a=this.getTocNodeNow(i.parentTocId,r);for(;a;)n.unshift({tocId:a.tocId,title:a.title,untranslatedTitle:a.untranslatedTitle}),a=this.getTocNodeNow(a.parentTocId,r);return n}isFeatureAccessible(e,{session:r}){var i;if(!this.isFeatureAvailable(e))return!1;switch(e){case nt.FEEDBACK:return Ht(r??[],ce.FEEDBACK_USER);case nt.RATING:return Ht(r??[],ce.RATING_USER);case nt.PRINT:return Ht(r??[],ce.PRINT_USER);case nt.BOOKMARK:return!!r?.sessionAuthenticated;case nt.COLLECTIONS:return Ht(r??[],ce.COLLECTION_USER);case nt.PERSONAL_BOOKS:return Ht(r??[],ce.PERSONAL_BOOK_USER)&&!(!((i=this.getMapNow())===null||i===void 0)&&i.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var kn=class t extends Pn{static async build(e){return new t(new Nn,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,r){let i=await this.api.getMap(e,r);return this.fingerprint=i.fingerprint,i}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,r){return await this.getMap(r),this.api.getPages(e,this.fingerprint,r)}fetchTopicHTMLContent(e){return this.api.getTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint)}fetchTranslatedTopicHTMLContent(e,r){return this.api.getTranslatedTopicHTMLContent(this.mapId,e.contentId,"DESIGNED_READER",this.fingerprint,r)}fetchTopicMetadata(e){return this.api.getTopic(this.mapId,e.contentId,this.fingerprint)}fetchAttachments(){return this.api.getMapAttachments(this.mapId).catch(()=>[])}fetchRelativesForDocument(e,r){let i={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:r}}],sort:[],facets:[]};return this.api.search(i)}fetchRelativesForTopicInMap(e,r,i){let n={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:r,valueFilter:{negative:!1,values:i}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(n)}makeMapFeedbackRequest(e,r){return this.api.sendMapFeedback(this.mapId,e,r)}makeRateMapRequest(e,r){return this.api.rateMap(this.mapId,e,r)}makeRateTopicRequest(e,r,i){return this.api.rateTopic(this.mapId,e,r,i)}makeTopicFeedbackRequest(e,r,i){return this.api.sendTopicFeedback(this.mapId,e,r,i)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var Dn=class t{static build(e,r){return new t(Wp(e.trim()||"context"),r??kn.build)}loaded(){return Oa(()=>this._loaded)}constructor(e,r,i){this.store=e,this.clusteringHelperProvider=i,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new ge(10),this.initService(r)}async initService(e){return this.service=await e(),this.service.mapId=this.store.getState().mapId,this.reload()}async setMapId(e){e!==this.store.getState().mapId&&(this.store.actions.mapId(e),this.service&&(this.service.mapId=e),await this.reload())}setRenderedTopics(e){this.store.actions.renderedTopics(e)}setVisibleTopics(e){this.store.actions.visibleTopics(e)}async awaitService(){return ko(()=>this.service)}async navigateToTopic(e,r,i){await this.loaded();let n=await this.awaitService(),a=await(i!=null?n.getPage(i,this.getTranslationSettings()):n.getPageByTocId(e??"root",this.getTranslationSettings()));this.store.actions.currentPage(a);let s=this.resolveValidNonRootTocId(e,a);this.store.actions.scrollTarget({tocId:s,section:r}),this.store.getState().visibleTopics[0]!==s&&this.store.actions.visibleTopics([])}resolveValidNonRootTocId(e,r){var i,n,a;let s=(i=e==="root"?void 0:e)!==null&&i!==void 0?i:r.rootTocId;return r.topics.includes(s)?s:(a=(n=r.topics[0])!==null&&n!==void 0?n:r.hiddenTopics[0])!==null&&a!==void 0?a:"root"}async navigateToPage(e){await this.loaded();let i=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(i)}scrollDone(){this.store.actions.scrollTarget({})}async load(){var e;!((e=this.service)===null||e===void 0)&&e.mapId&&this.store.getState().map==null&&await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}clear(){var e;this._loaded=!1,this.store.actions.configuration(void 0),this.store.actions.map(void 0),this.store.actions.toc(void 0),this.store.actions.pagesToc(void 0),this.store.actions.currentPage(void 0),this.store.actions.searchInDocumentQuery(""),this.store.actions.relatives(void 0),this.store.actions.renderedTopics([]),this.store.actions.visibleTopics([]),this.store.actions.translation({sourceLanguage:void 0,destinationLanguage:void 0,profileId:void 0,isLoading:!1,isError:!1}),this.store.actions.mapRating(void 0),(e=this.service)===null||e===void 0||e.clear(),this.clusteringHelper=void 0}reload(){return this.clear(),this.load()}async fetchData(e){var r,i,n,a,s;try{e&&this.setTranslationLoading(!0);let l=d=>{throw e&&this.setTranslationError(!0),d};await Promise.all([this.loadConfiguration(),(r=this.service)===null||r===void 0?void 0:r.getMap(e).then(d=>this.store.actions.map(d)).catch(l),(i=this.service)===null||i===void 0?void 0:i.getToc(e).then(d=>this.store.actions.toc(d)).catch(l),(n=this.service)===null||n===void 0?void 0:n.getPagesToc(e).then(d=>this.store.actions.pagesToc(d)).catch(l),(a=this.service)===null||a===void 0?void 0:a.getPaginationConfiguration().then(d=>this.store.actions.paginationConfiguration(d)).catch(l),(s=this.service)===null||s===void 0?void 0:s.getTranslationError(e).then(d=>this.setTranslationError(d))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,e&&this.setTranslationLoading(!1)}catch(l){this.errorHandler&&!(l instanceof _t)&&this.errorHandler(l)}}loadConfiguration(){var e;return(e=this.service)===null||e===void 0?void 0:e.getConfiguration().then(r=>this.store.actions.configuration(r))}reloadConfiguration(){var e;return(e=this.service)===null||e===void 0||e.clearConfiguration(),this.loadConfiguration()}fetchRelatives(){var e,r;let i=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(n=>{var a;return n.key==((a=this.store.getState().configuration)===null||a===void 0?void 0:a.relativePivotMetadata)}).flatMap(n=>n.values);i!==void 0&&i.length>0?(r=this.service)===null||r===void 0||r.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,i).then(n=>{let a=n.results.flatMap(s=>s.entries);this.store.actions.relatives(a),this.updateClusteringHelper()}):this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(ei.clusteringHelperCreated))}createClusteringHelper(){var e,r;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let i=this.store.getState().relatives;if(i){let n=i.find(s=>{var l;return((l=s.map)===null||l===void 0?void 0:l.mapId)==this.store.getState().mapId}),a=(r=(e=N.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&r!==void 0?r:[];return new Bo(i,n,this.metadataForSwitchToRelatives,a)}}async navigateToRelativeTopicIfFound(e){var r,i,n;await this.loaded();let a=await ko(()=>{var p;return(p=this.store.getState().configuration)===null||p===void 0?void 0:p.relativeTopicPivotMetadata}),s=this.store.getState().mapId,d=await(await this.awaitService()).getRelativesForTopicInMap(s,a,[e]);if(!((n=(i=(r=d?.results)===null||r===void 0?void 0:r[0])===null||i===void 0?void 0:i.entries)===null||n===void 0)&&n[0]){let p=d.results[0].entries[0].topic.tocId;return await this.navigateToTopic(p),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData(this.getTranslationSettings()))}async setTranslationProfileId(e){this.store.actions.setTranslationProfileId(e)}async setTranslationLoading(e){this.store.actions.setTranslationLoading(e)}async setTranslationError(e){this.store.actions.setTranslationError(e)}getTranslationSettings(){var e;let r=this.store.getState();return r.translation.profileId&&r.translation.destinationLanguage?{profileId:r.translation.profileId,destinationLanguage:r.translation.destinationLanguage.code,sourceLanguage:(e=r.map)===null||e===void 0?void 0:e.lang}:void 0}setLinkPreviewDialogId(e){this.store.actions.setLinkPreviewDialogId(e)}async fetchMapRating(){var e;this.store.actions.mapRating(await((e=this.service)===null||e===void 0?void 0:e.getMapRating()))}async fetchTopicRating(e){var r;let i=await((r=this.service)===null||r===void 0?void 0:r.getTopicRating(e));i&&this.store.actions.setTopicsRating({[e]:i})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}getAccurateNavigationData(e,r,i){return this.service.getAccurateNavigationData(e,r?.number,i?.section,this.getTranslationSettings())}buildBreadcrumb(e){var r;return(r=this.service)===null||r===void 0?void 0:r.buildBreadcrumb(e,this.getTranslationSettings())}fetchTopicContent(e){var r,i;let n=this.getTranslationSettings();return n?(r=this.service)===null||r===void 0?void 0:r.getTranslatedTopicContent(e,n).then(a=>(a.isTranslationError&&this.setTranslationError(!0),a.content)):(i=this.service)===null||i===void 0?void 0:i.getTopicContent(e)}getTocNode(e){return this.service.getTocNode(e,this.getTranslationSettings())}getPage(e){return this.service.getPage(e,this.getTranslationSettings())}onMapAttachmentsUpdate(){var e;(e=this.service)===null||e===void 0||e.clearMapAttachments(),this.store.dispatchEvent(new Event(ei.mapAttachmentsUpdate))}};var Vp=k`
|
|
2051
2051
|
`;var Mn=class extends CustomEvent{constructor(e,r){super("ft-reader-map-loaded",{detail:{map:e,toc:r}})}},$n=class extends CustomEvent{constructor(e,r){super("ft-reader-visible-topics-change",{detail:{visibleTopics:r}})}},Bn=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},Fn=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},Un=class extends Event{constructor(){super("ft-reader-map-not-found")}},Hn=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},zn=class extends Event{constructor(){super("ft-reader-map-forbidden")}},Wn=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var Vn=class{constructor(e){this.stateManager=e}searchInDocument(e){this.stateManager.setSearchInDocumentQuery(e??"")}};var Ze=function(t,e,r,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,i);else for(var l=t.length-1;l>=0;l--)(s=t[l])&&(a=(n<3?s(a):n>3?s(e,r,a):s(e,r))||a);return n>3&&a&&Object.defineProperty(e,r,a),a},Vh=t=>e=>+(e??"NaN")>0?+e:t,Te=class extends Bt{constructor(){super(),this.visibleTopics=[],this.updateConfiguration=()=>{this.stateManager.reloadConfiguration()},this.scrollToTargetDebouncer=new ge(5),this.navigationDebouncer=new ge(10),this.mapLoadedEventDebouncer=new ge(50),this.addStore(N)}render(){return I`
|
|
2052
2052
|
${this.importStyleIfNeeded()}
|
|
2053
2053
|
<slot @register-ft-reader-component=${this.registerComponent}></slot>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reader-feedback",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.53",
|
|
4
4
|
"description": "Feedback forms for a map and its topics in an integrated reader",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "1.3.
|
|
23
|
-
"@fluid-topics/ft-reader-context": "1.3.
|
|
24
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
22
|
+
"@fluid-topics/ft-app-context": "1.3.53",
|
|
23
|
+
"@fluid-topics/ft-reader-context": "1.3.53",
|
|
24
|
+
"@fluid-topics/ft-wc-utils": "1.3.53",
|
|
25
25
|
"lit": "3.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@fluid-topics/public-api": "1.0.112"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "1eb4ee8a448ded2e0d54517a08200d0109c0722e"
|
|
31
31
|
}
|