@fluid-topics/ft-reader-context 2.2.25 → 2.2.26

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.
@@ -1,12 +1,12 @@
1
- "use strict";(()=>{var ai=Object.create;var $r=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var ci=Object.getOwnPropertyNames;var li=Object.getPrototypeOf,ui=Object.prototype.hasOwnProperty;var ir=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var di=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ci(e))!ui.call(t,s)&&s!==r&&$r(t,s,{get:()=>e[s],enumerable:!(n=oi(e,s))||n.enumerable});return t};var f=(t,e,r)=>(r=t!=null?ai(li(t)):{},di(e||!t||!t.__esModule?$r(r,"default",{value:t,enumerable:!0}):r,t));var b=ir((wa,zr)=>{zr.exports=ftGlobals.wcUtils});var oe=ir((xa,Gr)=>{Gr.exports=ftGlobals.lit});var te=ir((Ra,Wr)=>{Wr.exports=ftGlobals.litDecorators});var ni=f(b());var Ye=f(oe()),ae=f(te()),M=f(b());var de;(function(t){t.clusteringHelperCreated="clustering-helper-created",t.mapAttachmentsUpdate="map-attachments-update",t.visibleTopicChange="visible-topic-change",t.requestedTopicNotFound="requested-topic-not-found",t.requestedTopicFiltered="requested-topic-filtered"})(de||(de={}));var Xe=class extends CustomEvent{constructor(e){super(de.requestedTopicFiltered,{detail:e})}},re;(function(t){t.FEEDBACK="FEEDBACK",t.RATING="RATING",t.PRINT="PRINT",t.BOOKMARK="BOOKMARK",t.COLLECTIONS="COLLECTIONS",t.PERSONAL_BOOKS="PERSONAL_BOOKS"})(re||(re={}));var L=f(b());var Qr=f(b()),hi={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]}},Yr=t=>Qr.FtReduxStore.get({name:"ft-reader-"+t,initialState:{mapId:void 0,renderedTopics:[],visibleTopics:[],map:void 0,toc:void 0,pagesToc:void 0,filteredTocNodes:{},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,metadataFilters:[]},reducers:hi});var ar=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,filteredTocNodes:this.paginatedToc.filteredTocNodes}}extractPagesToc(e,r,n){return e.flatMap(s=>{var i;return s.pageConfiguration&&this.registerPage(this.buildPage(s,n)),s.tocId==null?this.extractPagesToc(s.children,r,n):[{tocId:s.tocId,title:(i=s.title)!==null&&i!==void 0?i:"",contentTag:s.contentTag,contentClass:s.contentClass,untranslatedTitle:s.untranslatedTitle,depth:r,children:this.extractPagesToc(s.children,r+1,s.tocId)}]})}convertNodes(e,r,n){return e.flatMap(s=>{var i,a,o;if(s.tocId==null)return[...this.convertSectionNodes((a=s.pageToc)!==null&&a!==void 0?a:[],r,s.tocId),...this.convertNodes(s.children,r,s.tocId)];let c=(i=s.prettyUrl)===null||i===void 0?void 0:i.replace(/^\//,""),l={tocId:s.tocId,contentId:s.contentId,title:s.title,contentTag:s.contentTag,contentClass:s.contentClass,untranslatedTitle:s.untranslatedTitle,hasRating:s.hasRating,origin:s.origin,prettyUrl:c,depth:r,parentTocId:n,children:[]};this.register(l);let u=this.convertSectionNodes((o=s.pageToc)!==null&&o!==void 0?o:[],r+1,s.tocId),h=this.convertNodes(s.children,r+1,l.tocId);return l.children=[...u,...h],[l]})}convertSectionNodes(e,r,n){return e.flatMap(s=>{var i;let a=(i=s.prettyUrl)===null||i===void 0?void 0:i.replace(/^\//,""),o={...s,prettyUrl:a,depth:r,parentTocId:n,children:[]};return this.register(o),o.children=this.convertSectionNodes(s.children,r+1,s.tocId),[o]})}buildPage(e,r){var n,s,i,a,o,c,l,u;let h=(a=e.tocId)!==null&&a!==void 0?a:(s=(n=e.pageToc)===null||n===void 0?void 0:n[0])===null||s===void 0?void 0:s.tocId,p={number:this.pages.length+1,title:(o=e.title)!==null&&o!==void 0?o:"",untranslatedTitle:e.untranslatedTitle,rootTocId:h??"root",toc:((c=e.pageToc)!==null&&c!==void 0?c:[]).map(m=>this.nodeByTocId[m.tocId]),topics:[],hiddenTopics:[],rootDepth:h?this.nodeByTocId[h].depth:1,breadcrumb:r?this.buildBreadcrumb(this.nodeByTocId[r]):[]},y=(m,I)=>(I?p.topics:p.hiddenTopics).push(m),E=(l=(i=e.pageConfiguration)===null||i===void 0?void 0:i.parentsVisibility)!==null&&l!==void 0?l:[];p.breadcrumb.forEach((m,I)=>{y(m,E[I])}),e.tocId&&y(e.tocId,e.pageConfiguration.isVisible),p.topics.push(...this.tocIds((u=e.pageToc)!==null&&u!==void 0?u:[]));let C=this.resolveOverridenRootTocIdByParentForcedByPagination(p.breadcrumb,E);return p.rootTocId=C??p.rootTocId,p.rootDepth=C?this.nodeByTocId[C].depth:p.rootDepth,p}resolveOverridenRootTocIdByParentForcedByPagination(e,r){for(let n=0;n<e.length;n++)if(r[n])return e[n]}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}},Je=class{convertPaginatedToc(e,r){return new ar(e,r).build()}};var Xr;(function(t){t.black="black",t.green="green",t.blue="blue",t.purple="purple",t.red="red",t.orange="orange",t.yellow="yellow"})(Xr||(Xr={}));var Jr;(function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"})(Jr||(Jr={}));var Zr;(function(t){t.STRUCTURED_DOCUMENT="STRUCTURED_DOCUMENT",t.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT",t.SHARED_PERSONAL_BOOK="SHARED_PERSONAL_BOOK",t.PERSONAL_BOOK="PERSONAL_BOOK",t.ATTACHMENT="ATTACHMENT",t.RESOURCE="RESOURCE",t.HTML_PACKAGE="HTML_PACKAGE"})(Zr||(Zr={}));var ce;(function(t){t.STRUCTURED_DOCUMENT="STRUCTURED_DOCUMENT",t.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT",t.SHARED_PERSONAL_BOOK="SHARED_PERSONAL_BOOK",t.PERSONAL_BOOK="PERSONAL_BOOK",t.ATTACHMENT="ATTACHMENT",t.RESOURCE="RESOURCE",t.HTML_PACKAGE="HTML_PACKAGE"})(ce||(ce={}));var en;(function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_QUARTER="LAST_QUARTER",t.LAST_YEAR="LAST_YEAR"})(en||(en={}));var tn;(function(t){t.VALUE="VALUE",t.DATE="DATE",t.RANGE="RANGE"})(tn||(tn={}));var Ze;(function(t){t.OFFICIAL="OFFICIAL",t.AI="AI"})(Ze||(Ze={}));var he;(function(t){t.BOOKMARK__CREATE="BOOKMARK__CREATE",t.BOOKMARK__DELETE="BOOKMARK__DELETE",t.CASE_DEFLECTION__START="CASE_DEFLECTION__START",t.CASE_DEFLECTION__OPEN_TICKET="CASE_DEFLECTION__OPEN_TICKET",t.CASE_DEFLECTION__RATE="CASE_DEFLECTION__RATE",t.CHATBOT__RATE="CHATBOT__RATE",t.COLLECTION__CREATE="COLLECTION__CREATE",t.COLLECTION__UPDATE="COLLECTION__UPDATE",t.COLLECTION__DELETE="COLLECTION__DELETE",t.CUSTOM_EVENT__TRIGGER="CUSTOM_EVENT__TRIGGER",t.DOCUMENT__ON_DEMAND_TRANSLATE="DOCUMENT__ON_DEMAND_TRANSLATE",t.DOCUMENT__DOWNLOAD="DOCUMENT__DOWNLOAD",t.DOCUMENT__PRINT="DOCUMENT__PRINT",t.DOCUMENT__PROCESS="DOCUMENT__PROCESS",t.DOCUMENT__RATE="DOCUMENT__RATE",t.DOCUMENT__SEARCH="DOCUMENT__SEARCH",t.DOCUMENT__START_DISPLAY="DOCUMENT__START_DISPLAY",t.DOCUMENT__UNRATE="DOCUMENT__UNRATE",t.FEEDBACK__SEND="FEEDBACK__SEND",t.AI__COMPLETED_QUERY="AI__COMPLETED_QUERY",t.AI__RATE="AI__RATE",t.AI_CASE_DEFLECTION__START="AI_CASE_DEFLECTION__START",t.AI_CASE_DEFLECTION__OPEN_TICKET="AI_CASE_DEFLECTION__OPEN_TICKET",t.KHUB__PROCESS="KHUB__PROCESS",t.KHUB__SEARCH="KHUB__SEARCH",t.LABELS__DOWNLOAD="LABELS__DOWNLOAD",t.LINK__SHARE="LINK__SHARE",t.PAGE__DISPLAY="PAGE__DISPLAY",t.PERSONAL_BOOK__CREATE="PERSONAL_BOOK__CREATE",t.PERSONAL_BOOK__DELETE="PERSONAL_BOOK__DELETE",t.PERSONAL_BOOK__UPDATE="PERSONAL_BOOK__UPDATE",t.PERSONAL_TOPIC__CREATE="PERSONAL_TOPIC__CREATE",t.PERSONAL_TOPIC__UPDATE="PERSONAL_TOPIC__UPDATE",t.PERSONAL_TOPIC__DELETE="PERSONAL_TOPIC__DELETE",t.SAVED_SEARCH__CREATE="SAVED_SEARCH__CREATE",t.SAVED_SEARCH__DELETE="SAVED_SEARCH__DELETE",t.SAVED_SEARCH__UPDATE="SAVED_SEARCH__UPDATE",t.SEARCH_PAGE__SELECT="SEARCH_PAGE__SELECT",t.SEARCH_RESULT__OPEN_BROWSER_CONTEXT_MENU="SEARCH_RESULT__OPEN_BROWSER_CONTEXT_MENU",t.TOPIC__AI_TRANSLATE="TOPIC__AI_TRANSLATE",t.TOPIC__RATE="TOPIC__RATE",t.TOPIC__START_DISPLAY="TOPIC__START_DISPLAY",t.TOPIC__UNRATE="TOPIC__UNRATE",t.USER__LOGIN="USER__LOGIN",t.USER__LOGOUT="USER__LOGOUT",t.HEARTBEAT="HEARTBEAT"})(he||(he={}));var rn;(function(t){t.STANDARD="STANDARD",t.STRUCTURAL="STRUCTURAL"})(rn||(rn={}));var nn;(function(t){t.METADATA_FILTER="METADATA_FILTER",t.ACCESS_RIGHTS_FILTER="ACCESS_RIGHTS_FILTER"})(nn||(nn={}));var sn;(function(t){t.THIRD_PARTY="THIRD_PARTY",t.OFF_THE_GRID="OFF_THE_GRID",t.CONTENT_PACKAGER="CONTENT_PACKAGER",t.PAGES="PAGES",t.DESIGNED_READER="DESIGNED_READER"})(sn||(sn={}));var an;(function(t){t.HOMEPAGE="HOMEPAGE",t.CUSTOM="CUSTOM",t.HEADER="HEADER",t.READER="READER",t.TOPIC_TEMPLATE="TOPIC_TEMPLATE",t.SEARCH="SEARCH",t.SEARCH_RESULT="SEARCH_RESULT",t.SEARCH_ANNOUNCEMENT="SEARCH_ANNOUNCEMENT",t.LINK_PREVIEW="LINK_PREVIEW",t.UD_VIEWER="UD_VIEWER",t.ASSET_VIEWER="ASSET_VIEWER"})(an||(an={}));var on;(function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"})(on||(on={}));var cn;(function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"})(cn||(cn={}));var ln;(function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"})(ln||(ln={}));var un;(function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"})(un||(un={}));var dn;(function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_QUARTER="LAST_QUARTER",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"})(dn||(dn={}));var et;(function(t){t.OPTIONAL="OPTIONAL",t.MANDATORY="MANDATORY"})(et||(et={}));var hn;(function(t){t.ASC="ASC",t.DESC="DESC"})(hn||(hn={}));var pn;(function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"})(pn||(pn={}));var Te;(function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"})(Te||(Te={}));var fn;(function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK",t.HTML_PACKAGE="HTML_PACKAGE"})(fn||(fn={}));var mn;(function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"})(mn||(mn={}));var gn;(function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK",t.HTML_PACKAGE="HTML_PACKAGE"})(gn||(gn={}));var yn;(function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_QUARTER="LAST_QUARTER",t.LAST_YEAR="LAST_YEAR"})(yn||(yn={}));var J;(function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.HTML_PACKAGE="HTML_PACKAGE",t.HTML_PACKAGE_PAGE="HTML_PACKAGE_PAGE"})(J||(J={}));var be;(function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS",t.TOPICS_AND_UNSTRUCTURED_DOCUMENTS="TOPICS_AND_UNSTRUCTURED_DOCUMENTS"})(be||(be={}));var vn;(function(t){t.PLAIN_TEXT="PLAIN_TEXT",t.LOCALIZED_OFFICIAL="LOCALIZED_OFFICIAL",t.LOCALIZED_CUSTOM="LOCALIZED_CUSTOM"})(vn||(vn={}));var S;(function(t){t.PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",t.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",t.HTML_EXPORT_USER="HTML_EXPORT_USER",t.PDF_EXPORT_USER="PDF_EXPORT_USER",t.SAVED_SEARCH_USER="SAVED_SEARCH_USER",t.COLLECTION_USER="COLLECTION_USER",t.OFFLINE_USER="OFFLINE_USER",t.ANALYTICS_USER="ANALYTICS_USER",t.BETA_USER="BETA_USER",t.DEBUG_USER="DEBUG_USER",t.PRINT_USER="PRINT_USER",t.RATING_USER="RATING_USER",t.FEEDBACK_USER="FEEDBACK_USER",t.GENERATIVE_AI_USER="GENERATIVE_AI_USER",t.GENERATIVE_AI_EXPORT_USER="GENERATIVE_AI_EXPORT_USER",t.CONTENT_PUBLISHER="CONTENT_PUBLISHER",t.BEHAVIOR_DATA_USER="BEHAVIOR_DATA_USER",t.ANNOUNCEMENT_ADMIN="ANNOUNCEMENT_ADMIN",t.KHUB_ADMIN="KHUB_ADMIN",t.USERS_ADMIN="USERS_ADMIN",t.PORTAL_ADMIN="PORTAL_ADMIN",t.ADMIN="ADMIN"})(S||(S={}));var z;(function(t){t.SEARCHES="SEARCHES",t.BOOKMARKS="BOOKMARKS",t.BOOKS="BOOKS",t.COLLECTIONS="COLLECTIONS"})(z||(z={}));var En;(function(t){t.UNAUTHENTICATED="UNAUTHENTICATED",t.USER_INCOMPLETE="USER_INCOMPLETE",t.MFA_REQUIRED="MFA_REQUIRED",t.AUTHENTICATED="AUTHENTICATED"})(En||(En={}));var Sn;(function(t){t.UNREACHABLE="UNREACHABLE",t.UNAUTHORIZED="UNAUTHORIZED",t.FORBIDDEN="FORBIDDEN",t.INCOMPATIBLE="INCOMPATIBLE",t.FAILED="FAILED",t.OK="OK"})(Sn||(Sn={}));var An;(function(t){t.VALID="VALID",t.INVALID="INVALID"})(An||(An={}));var Tn;(function(t){t.INACCURATE="INACCURATE",t.INCOMPLETE="INCOMPLETE",t.OFF_TOPIC="OFF_TOPIC",t.SEMANTIC_SEARCH="SEMANTIC_SEARCH",t.CHATBOT_INSTRUCTIONS="CHATBOT_INSTRUCTIONS",t.DOCUMENTATION="DOCUMENTATION",t.OTHER="OTHER"})(Tn||(Tn={}));var bn;(function(t){t.INACCURATE="INACCURATE",t.INCOMPLETE="INCOMPLETE",t.OFF_TOPIC="OFF_TOPIC",t.IRRELEVANT_SOURCES="IRRELEVANT_SOURCES",t.SLOW="SLOW",t.OTHER="OTHER"})(bn||(bn={}));var _n;(function(t){t.JSON="JSON",t.TEXT="TEXT"})(_n||(_n={}));var Cn;(function(t){t.JSON="JSON",t.TEXT="TEXT"})(Cn||(Cn={}));var wn;(function(t){t.TEXT="TEXT",t.HTML="HTML"})(wn||(wn={}));var xn;(function(t){t.IN_PROGRESS="IN_PROGRESS",t.ERROR="ERROR",t.DONE="DONE"})(xn||(xn={}));var Rn;(function(t){t.HTML="HTML",t.MARKDOWN="MARKDOWN"})(Rn||(Rn={}));var In;(function(t){t.SOURCES="SOURCES",t.ENRICH_AND_CLEAN="ENRICH_AND_CLEAN",t.VOCABULARIES="VOCABULARIES",t.METADATA="METADATA",t.PRETTY_URL="PRETTY_URL",t.ACCESS_RULE="ACCESS_RULE",t.DESIGNED_PAGES="DESIGNED_PAGES",t.THEME_STUDIO="THEME_STUDIO",t.PORTAL_GENERAL="PORTAL_GENERAL",t.ASSETS="ASSETS",t.CODE_LIBRARY="CODE_LIBRARY",t.THEME="THEME",t.CONTENT_STYLES="CONTENT_STYLES",t.HOMEPAGE="HOMEPAGE",t.CLASSIC_SEARCH_PAGE="CLASSIC_SEARCH_PAGE",t.CLASSIC_READER_PAGE="CLASSIC_READER_PAGE",t.PORTAL_METADATA="PORTAL_METADATA",t.LANGUAGES="LANGUAGES",t.PRINT_TEMPLATES="PRINT_TEMPLATES",t.OFFLINE="OFFLINE",t.CUSTOM_JS="CUSTOM_JS",t.CONFIDENTIALITY="CONFIDENTIALITY",t.NOTIFICATIONS="NOTIFICATIONS"})(In||(In={}));var On;(function(t){t.MAP="MAP",t.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT"})(On||(On={}));var pi={[S.PERSONAL_BOOK_SHARE_USER]:[S.PERSONAL_BOOK_USER],[S.HTML_EXPORT_USER]:[S.PERSONAL_BOOK_USER],[S.PDF_EXPORT_USER]:[S.PERSONAL_BOOK_USER],[S.KHUB_ADMIN]:[S.CONTENT_PUBLISHER],[S.ADMIN]:[S.KHUB_ADMIN,S.USERS_ADMIN,S.PORTAL_ADMIN,S.BEHAVIOR_DATA_USER],[S.GENERATIVE_AI_EXPORT_USER]:[S.GENERATIVE_AI_USER]};function Mn(t,e){return t===e||(pi[t]??[]).some(r=>Mn(r,e))}function G(t,e){return t==null?!1:(Array.isArray(t)?t:Array.isArray(t.roles)?t.roles:Array.isArray(t.profile?.roles)?t.profile.roles:[]).some(n=>Mn(n,e))}function kn(t,...e){return t==null?!1:e.some(r=>G(t,r))}var Rr=f(te());var Nn=f(te(),1);var or=t=>e=>{window.customElements.get(t)||window.customElements.define(t,e)},fi=t=>({fromAttribute:e=>{if(e==null)return Ne(t);try{return JSON.parse(e)}catch{return Ne(t)}},toAttribute:e=>JSON.stringify(e)});function Dn(t,e){return(0,Nn.property)({type:Object,converter:fi(t),hasChanged:De,...e??{}})}function mi(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;let r,n;if(Array.isArray(t)){if(r=t.length,r!=e.length)return!1;for(n=r;n--!==0;)if(!_e(t[n],e[n]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(n of t.entries())if(!e.has(n[0]))return!1;for(n of t.entries())if(!_e(n[1],e.get(n[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(n of t.entries())if(!e.has(n[0]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();let s=a=>Object.keys(a).filter(o=>a[o]!=null),i=s(t);if(r=i.length,r!==s(e).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(e,i[n]))return!1;for(n=r;n--!==0;){let a=i[n];if(!_e(t[a],e[a]))return!1}return!0}return t!==t&&e!==e||t==null&&e==null}function _e(t,e){try{return mi(t,e)}catch{return!1}}function De(t,e){return!_e(t,e)}function Ne(t){return typeof window.structuredClone=="function"?structuredClone(t):t!=null?JSON.parse(JSON.stringify(t)):t}function tt(t,e){let r=n=>n[t]===!0;return n=>{if(r(n))return n;let s=e(n);return s[t]=!0,s}}var Pn=f(te(),1);var cr=t=>{let e=t??{};return(r,n)=>{var s;let i={hasChanged:De,attribute:!1,...e};(0,Pn.property)(i)(r,n);let a=r.constructor;a.reduxProperties=new Map(a.reduxProperties),a.reduxProperties.set(n,{selector:(s=e.selector)!==null&&s!==void 0?s:(o=>o[n]),store:e.store})}};var rt=class{constructor(){this.queue=[]}add(e,r=!1){r&&this.clear(e.type),this.queue.push(e)}consume(e){let r=this.queue.find(n=>n.type===e);return r&&(this.queue=this.queue.filter(n=>n!==r)),r}clear(e){typeof e=="string"?this.queue=this.queue.filter(r=>r.type!==e):this.queue=this.queue.filter(r=>!e.test(r.type))}};var pe=f(te(),1);var nt=class{constructor(e=0){this.timeout=e,this.callbacks=[]}run(e,r){return this.callbacks=[e],this.debounce(r)}queue(e,r){return this.callbacks.push(e),this.debounce(r)}cancel(){this.clearTimeout(),this.resolvePromise&&this.resolvePromise(!1),this.clearPromise()}debounce(e){return this.promise==null&&(this.promise=new Promise((r,n)=>{this.resolvePromise=r,this.rejectPromise=n})),this.clearTimeout(),this._debounce=window.setTimeout(()=>this.runCallbacks(),e??this.timeout),this.promise}async runCallbacks(){var e,r;let n=[...this.callbacks];this.callbacks=[];let s=(e=this.rejectPromise)!==null&&e!==void 0?e:(()=>null),i=(r=this.resolvePromise)!==null&&r!==void 0?r:(()=>null);this.clearPromise();for(let a of n)try{await a()}catch(o){s(o);return}i(!0)}clearTimeout(){this._debounce!=null&&window.clearTimeout(this._debounce)}clearPromise(){this.promise=void 0,this.resolvePromise=void 0,this.rejectPromise=void 0}};var it=f(oe(),1);var st=class extends it.LitElement{get scopedRegistryConstructor(){return this.constructor}createRenderRoot(){let e=this.scopedRegistryConstructor;e.elementDefinitions&&!e.registry&&(e.registry=new CustomElementRegistry,e.defineScopedElements(e.elementDefinitions));let r={...e.shadowRootOptions,customElements:e.registry},n=this.renderOptions.creationScope=this.attachShadow(r);return(0,it.adoptStyles)(n,e.elementStyles),n}static canDefineScopedElement(e){return!!this.registry&&!this.registry.get(e)}static defineScopedElements(e){Object.entries(e).forEach(([r,n])=>this.defineScopedElement(r,n))}static defineScopedElement(e,r){or(e)(r),this.canDefineScopedElement(e)&&this.registry.define(e,r)}canDefineScopedElement(e){return this.scopedRegistryConstructor.canDefineScopedElement(e)}defineScopedElements(e){this.scopedRegistryConstructor.defineScopedElements(e)}defineScopedElement(e,r){this.scopedRegistryConstructor.defineScopedElement(e,r)}};function Ln(t,e,...r){var n;let s=t.querySelector(e);for(let i of r)s=(n=s?.shadowRoot)===null||n===void 0?void 0:n.querySelector(i);return s}var we=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},Vn,Fn=Symbol("constructorPrototype"),Un=Symbol("constructorName"),qn=Symbol("exportpartsDebouncer"),Bn=Symbol("dynamicDependenciesLoaded"),Ce=class t extends CustomEvent{constructor(){super(t.eventName,{bubbles:!0})}};Ce.eventName="exportparts-updated";var Z=class extends st{constructor(){super(),this.useAdoptedStyleSheets=!0,this.adoptedCustomStyleSheet=new CSSStyleSheet,this[Vn]=new nt(5),this.scheduleExportpartsUpdate=()=>{var e,r,n;(!((e=this.exportpartsPrefix)===null||e===void 0)&&e.trim()||(n=(r=this.exportpartsPrefixes)===null||r===void 0?void 0:r.length)!==null&&n!==void 0&&n)&&this[qn].run(()=>{var s,i;!((s=this.exportpartsPrefix)===null||s===void 0)&&s.trim()?this.setExportpartsAttribute([this.exportpartsPrefix]):this.exportpartsPrefixes!=null&&((i=this.exportpartsPrefixes)===null||i===void 0?void 0:i.length)>0&&this.setExportpartsAttribute(this.exportpartsPrefixes)})},this[Un]=this.constructor.name,this[Fn]=this.constructor.prototype}adoptedCallback(){this.constructor.name!==this[Un]&&Object.setPrototypeOf(this,this[Fn])}connectedCallback(){var e;super.connectedCallback();try{this.shadowRoot&&!this.shadowRoot.adoptedStyleSheets.includes(this.adoptedCustomStyleSheet)&&(this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,this.adoptedCustomStyleSheet]),this.useAdoptedStyleSheets=!0}catch(n){this.useAdoptedStyleSheets=!1,console.error("Cannot use adopted stylesheets",n)}let r=this.constructor;r[Bn]||(r[Bn]=!0,this.importDynamicDependencies()),(e=this.shadowRoot)===null||e===void 0||e.addEventListener(Ce.eventName,this.scheduleExportpartsUpdate)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.shadowRoot)===null||e===void 0||e.removeEventListener(Ce.eventName,this.scheduleExportpartsUpdate)}importDynamicDependencies(){}updated(e){super.updated(e),this.updateComplete.then(()=>{this.contentAvailableCallback(e),this.focusElementToFocus(e),this.applyCustomStylesheet(e),this.scheduleExportpartsUpdate(),e.has("exportparts")&&this.dispatchEvent(new Ce)})}contentAvailableCallback(e){}focusElementToFocus(e){if(e.has("elementToFocus")&&this.elementToFocus!=null){let{element:r,selector:n,shadowPath:s}=this.elementToFocus;if(n!=null){let i=[...s??[],n];r=Ln(this.shadowRoot,...i)}r?.focus(),window.FluidTopicsA11yHints.isKeyboardNavigation||r?.blur(),this.elementToFocus=void 0}}applyCustomStylesheet(e){var r,n,s;if(((n=(r=this.shadowRoot)===null||r===void 0?void 0:r.querySelectorAll(".ft-lit-element--custom-stylesheet"))!==null&&n!==void 0?n:[]).forEach(i=>i.remove()),this.useAdoptedStyleSheets){if(e.has("customStylesheet"))try{this.adoptedCustomStyleSheet.replaceSync((s=this.customStylesheet)!==null&&s!==void 0?s:"")}catch(i){console.error(i,this.customStylesheet),this.useAdoptedStyleSheets=!1}}else if(this.customStylesheet){let i=document.createElement("style");i.classList.add("ft-lit-element--custom-stylesheet"),i.innerHTML=this.customStylesheet,this.shadowRoot.append(i)}}setExportpartsAttribute(e){var r,n,s,i,a,o;let c=p=>p!=null&&p.trim().length>0,l=e.filter(c).map(p=>p.trim());if(l.length===0){this.exportparts=void 0;return}let u=new Set;for(let p of(i=(r=this.shadowRoot)===null||r===void 0?void 0:r.querySelectorAll("[part],[exportparts]"))!==null&&i!==void 0?i:[]){let y=(a=(n=p.getAttribute("part"))===null||n===void 0?void 0:n.split(" "))!==null&&a!==void 0?a:[],E=(o=(s=p.getAttribute("exportparts"))===null||s===void 0?void 0:s.split(",").map(m=>m.split(":")[1]))!==null&&o!==void 0?o:[],C=[...y,...E].filter(c).map(m=>m.trim());for(let m of C)u.add(m)}if(u.size===0){this.exportparts=void 0;return}let h=[...u.values()].flatMap(p=>l.map(y=>`${p}:${y}--${p}`));this.exportparts=[...this.part,...h].join(", ")}};Vn=qn;we([(0,pe.property)()],Z.prototype,"exportpartsPrefix",void 0);we([Dn([])],Z.prototype,"exportpartsPrefixes",void 0);we([(0,pe.property)({reflect:!0})],Z.prototype,"exportparts",void 0);we([(0,pe.property)()],Z.prototype,"customStylesheet",void 0);we([(0,pe.property)()],Z.prototype,"elementToFocus",void 0);we([(0,pe.state)()],Z.prototype,"useAdoptedStyleSheets",void 0);function at(t){var e;return(e=t?.isFtReduxStore)!==null&&e!==void 0?e:!1}var Pe=Symbol("internalReduxEventsUnsubscribers"),le=Symbol("internalStoresUnsubscribers"),fe=Symbol("internalStores"),gi=tt(Symbol("withRedux"),function(t){var e,r,n;class s extends t{constructor(){super(...arguments),this[e]=new Map,this[r]=new Map,this[n]=new Map}get reduxConstructor(){return this.constructor}willUpdate(a){super.willUpdate(a),[...this.reduxConstructor.reduxReactiveProperties].some(o=>a.has(o))&&this.updateFromStores()}getUnnamedStore(){if(this[fe].size>1)throw new Error("Cannot resolve unnamed store when multiple stores are configured.");return[...this[fe].values()][0]}getStore(a){return a==null?this.getUnnamedStore():this[fe].get(a)}addStore(a,o){var c;o=(c=o??a.name)!==null&&c!==void 0?c:"default-store",this.unsubscribeFromStore(o),this[fe].set(o,a),this.subscribeToStore(o,a),this.updateFromStores()}removeStore(a){let o=typeof a=="string"?a:a.name;this.unsubscribeFromStore(o),this[fe].delete(o)}setupStores(){this.unsubscribeFromStores(),this[fe].forEach((a,o)=>this.subscribeToStore(o,a)),this.updateFromStores()}updateFromStores(){this.reduxConstructor.reduxProperties.forEach((a,o)=>{let c=this.constructor.getPropertyOptions(o);if(!c?.attribute||!this.hasAttribute(typeof c?.attribute=="string"?c.attribute:o)){let l=this.getStore(a.store);l&&(a.store?this[le].has(a.store):this[le].size>0)&&(this[o]=a.selector(l.getState(),this))}})}subscribeToStore(a,o){var c;this[le].set(a,o.subscribe(()=>this.updateFromStores())),this[Pe].set(a,[]),at(o)&&o.eventBus&&((c=this.reduxConstructor.reduxEventListeners)===null||c===void 0||c.forEach((l,u)=>{if(typeof this[u]=="function"&&(!l.store||o.name===l.store)){let h=p=>this[u](p);o.addEventListener(l.eventName,h),this[Pe].get(a).push(()=>o.removeEventListener(l.eventName,h))}})),this.onStoreAvailable(a)}unsubscribeFromStores(){this[le].forEach((a,o)=>this.unsubscribeFromStore(o))}unsubscribeFromStore(a){var o;this[le].has(a)&&this[le].get(a)(),this[le].delete(a),(o=this[Pe].get(a))===null||o===void 0||o.forEach(c=>c()),this[Pe].delete(a)}onStoreAvailable(a){}connectedCallback(){super.connectedCallback(),this.setupStores()}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribeFromStores()}}return e=le,r=fe,n=Pe,s.reduxProperties=new Map,s.reduxReactiveProperties=new Set,s.reduxEventListeners=new Map,s}),jn=class extends gi(Z){};function P(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var yi=typeof Symbol=="function"&&Symbol.observable||"@@observable",Hn=yi,lr=()=>Math.random().toString(36).substring(7).split("").join("."),vi={INIT:`@@redux/INIT${lr()}`,REPLACE:`@@redux/REPLACE${lr()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${lr()}`},ot=vi;function ct(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function ur(t,e,r){if(typeof t!="function")throw new Error(P(2));if(typeof e=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(P(0));if(typeof e=="function"&&typeof r>"u"&&(r=e,e=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(P(1));return r(ur)(t,e)}let n=t,s=e,i=new Map,a=i,o=0,c=!1;function l(){a===i&&(a=new Map,i.forEach((m,I)=>{a.set(I,m)}))}function u(){if(c)throw new Error(P(3));return s}function h(m){if(typeof m!="function")throw new Error(P(4));if(c)throw new Error(P(5));let I=!0;l();let j=o++;return a.set(j,m),function(){if(I){if(c)throw new Error(P(6));I=!1,l(),a.delete(j),i=null}}}function p(m){if(!ct(m))throw new Error(P(7));if(typeof m.type>"u")throw new Error(P(8));if(typeof m.type!="string")throw new Error(P(17));if(c)throw new Error(P(9));try{c=!0,s=n(s,m)}finally{c=!1}return(i=a).forEach(j=>{j()}),m}function y(m){if(typeof m!="function")throw new Error(P(10));n=m,p({type:ot.REPLACE})}function E(){let m=h;return{subscribe(I){if(typeof I!="object"||I===null)throw new Error(P(11));function j(){let A=I;A.next&&A.next(u())}return j(),{unsubscribe:m(j)}},[Hn](){return this}}}return p({type:ot.INIT}),{dispatch:p,subscribe:h,getState:u,replaceReducer:y,[Hn]:E}}function Ei(t){Object.keys(t).forEach(e=>{let r=t[e];if(typeof r(void 0,{type:ot.INIT})>"u")throw new Error(P(12));if(typeof r(void 0,{type:ot.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(P(13))})}function Kn(t){let e=Object.keys(t),r={};for(let a=0;a<e.length;a++){let o=e[a];typeof t[o]=="function"&&(r[o]=t[o])}let n=Object.keys(r),s,i;try{Ei(r)}catch(a){i=a}return function(o={},c){if(i)throw i;let l=!1,u={};for(let h=0;h<n.length;h++){let p=n[h],y=r[p],E=o[p],C=y(E,c);if(typeof C>"u"){let m=c&&c.type;throw new Error(P(14))}u[p]=C,l=l||C!==E}return l=l||n.length!==Object.keys(o).length,l?u:o}}function Le(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,r)=>(...n)=>e(r(...n)))}function $n(...t){return e=>(r,n)=>{let s=e(r,n),i=()=>{throw new Error(P(15))},a={getState:s.getState,dispatch:(c,...l)=>i(c,...l)},o=t.map(c=>c(a));return i=Le(...o)(s.dispatch),{...s,dispatch:i}}}function zn(t){return ct(t)&&"type"in t&&typeof t.type=="string"}var ts=Symbol.for("immer-nothing"),Gn=Symbol.for("immer-draftable"),F=Symbol.for("immer-state");function Y(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var H=Object,Re=H.getPrototypeOf,ht="constructor",vt="prototype",fr="configurable",pt="enumerable",ut="writable",Fe="value",ee=t=>!!t&&!!t[F];function K(t){return t?rs(t)||St(t)||!!t[Gn]||!!t[ht]?.[Gn]||At(t)||Tt(t):!1}var Si=H[vt][ht].toString(),Wn=new WeakMap;function rs(t){if(!t||!Tr(t))return!1;let e=Re(t);if(e===null||e===H[vt])return!0;let r=H.hasOwnProperty.call(e,ht)&&e[ht];if(r===Object)return!0;if(!xe(r))return!1;let n=Wn.get(r);return n===void 0&&(n=Function.toString.call(r),Wn.set(r,n)),n===Si}function Et(t,e,r=!0){Ve(t)===0?(r?Reflect.ownKeys(t):H.keys(t)).forEach(s=>{e(s,t[s],t)}):t.forEach((n,s)=>e(s,n,t))}function Ve(t){let e=t[F];return e?e.type_:St(t)?1:At(t)?2:Tt(t)?3:0}var dr=(t,e,r=Ve(t))=>r===2?t.has(e):H[vt].hasOwnProperty.call(t,e),mr=(t,e,r=Ve(t))=>r===2?t.get(e):t[e],ft=(t,e,r,n=Ve(t))=>{n===2?t.set(e,r):n===3?t.add(r):t[e]=r};function Ai(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var St=Array.isArray,At=t=>t instanceof Map,Tt=t=>t instanceof Set,Tr=t=>typeof t=="object",xe=t=>typeof t=="function",hr=t=>typeof t=="boolean";function Ti(t){let e=+t;return Number.isInteger(e)&&String(e)===t}var ne=t=>t.copy_||t.base_;var br=t=>t.modified_?t.copy_:t.base_;function gr(t,e){if(At(t))return new Map(t);if(Tt(t))return new Set(t);if(St(t))return Array[vt].slice.call(t);let r=rs(t);if(e===!0||e==="class_only"&&!r){let n=H.getOwnPropertyDescriptors(t);delete n[F];let s=Reflect.ownKeys(n);for(let i=0;i<s.length;i++){let a=s[i],o=n[a];o[ut]===!1&&(o[ut]=!0,o[fr]=!0),(o.get||o.set)&&(n[a]={[fr]:!0,[ut]:!0,[pt]:o[pt],[Fe]:t[a]})}return H.create(Re(t),n)}else{let n=Re(t);if(n!==null&&r)return{...t};let s=H.create(n);return H.assign(s,t)}}function _r(t,e=!1){return bt(t)||ee(t)||!K(t)||(Ve(t)>1&&H.defineProperties(t,{set:lt,add:lt,clear:lt,delete:lt}),H.freeze(t),e&&Et(t,(r,n)=>{_r(n,!0)},!1)),t}function bi(){Y(2)}var lt={[Fe]:bi};function bt(t){return t===null||!Tr(t)?!0:H.isFrozen(t)}var mt="MapSet",yr="Patches",Qn="ArrayMethods",ns={};function me(t){let e=ns[t];return e||Y(0,t),e}var Yn=t=>!!ns[t];var Ue,ss=()=>Ue,_i=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Yn(mt)?me(mt):void 0,arrayMethodsPlugin_:Yn(Qn)?me(Qn):void 0});function Xn(t,e){e&&(t.patchPlugin_=me(yr),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function vr(t){Er(t),t.drafts_.forEach(Ci),t.drafts_=null}function Er(t){t===Ue&&(Ue=t.parent_)}var Jn=t=>Ue=_i(Ue,t);function Ci(t){let e=t[F];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Zn(t,e){e.unfinalizedDrafts_=e.drafts_.length;let r=e.drafts_[0];if(t!==void 0&&t!==r){r[F].modified_&&(vr(e),Y(4)),K(t)&&(t=es(e,t));let{patchPlugin_:s}=e;s&&s.generateReplacementPatches_(r[F].base_,t,e)}else t=es(e,r);return wi(e,t,!0),vr(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==ts?t:void 0}function es(t,e){if(bt(e))return e;let r=e[F];if(!r)return gt(e,t.handledSet_,t);if(!_t(r,t))return e;if(!r.modified_)return r.base_;if(!r.finalized_){let{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(t);os(r,t)}return r.copy_}function wi(t,e,r=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&_r(e,r)}function is(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var _t=(t,e)=>t.scope_===e,xi=[];function as(t,e,r,n){let s=ne(t),i=t.type_;if(n!==void 0&&mr(s,n,i)===e){ft(s,n,r,i);return}if(!t.draftLocations_){let o=t.draftLocations_=new Map;Et(s,(c,l)=>{if(ee(l)){let u=o.get(l)||[];u.push(c),o.set(l,u)}})}let a=t.draftLocations_.get(e)??xi;for(let o of a)ft(s,o,r,i)}function Ri(t,e,r){t.callbacks_.push(function(s){let i=e;if(!i||!_t(i,s))return;s.mapSetPlugin_?.fixSetContents(i);let a=br(i);as(t,i.draft_??i,a,r),os(i,s)})}function os(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(t.assigned_?.size??0)>0)){let{patchPlugin_:n}=e;if(n){let s=n.getPath(t);s&&n.generatePatches_(t,s,e)}is(t)}}function Ii(t,e,r){let{scope_:n}=t;if(ee(r)){let s=r[F];_t(s,n)&&s.callbacks_.push(function(){dt(t);let a=br(s);as(t,r,a,e)})}else K(r)&&t.callbacks_.push(function(){let i=ne(t);t.type_===3?i.has(r)&&gt(r,n.handledSet_,n):mr(i,e,t.type_)===r&&n.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&gt(mr(t.copy_,e,t.type_),n.handledSet_,n)})}function gt(t,e,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||ee(t)||e.has(t)||!K(t)||bt(t)||(e.add(t),Et(t,(n,s)=>{if(ee(s)){let i=s[F];if(_t(i,r)){let a=br(i);ft(t,n,a,t.type_),is(i)}}else K(s)&&gt(s,e,r)})),t}function Oi(t,e){let r=St(t),n={type_:r?1:0,scope_:e?e.scope_:ss(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},s=n,i=yt;r&&(s=[n],i=Be);let{revoke:a,proxy:o}=Proxy.revocable(s,i);return n.draft_=o,n.revoke_=a,[o,n]}var yt={get(t,e){if(e===F)return t;let r=t.scope_.arrayMethodsPlugin_,n=t.type_===1&&typeof e=="string";if(n&&r?.isArrayOperationMethod(e))return r.createMethodInterceptor(t,e);let s=ne(t);if(!dr(s,e,t.type_))return ki(t,s,e);let i=s[e];if(t.finalized_||!K(i)||n&&t.operationMethod&&r?.isMutatingArrayMethod(t.operationMethod)&&Ti(e))return i;if(i===pr(t.base_,e)||Mi(t,e,i)){dt(t);let a=t.type_===1?+e:e,o=Ar(t.scope_,i,t,a);return t.copy_[a]=o}return i},has(t,e){return e in ne(t)},ownKeys(t){return Reflect.ownKeys(ne(t))},set(t,e,r){let n=cs(ne(t),e);if(n?.set)return n.set.call(t.draft_,r),!0;if(!t.modified_){let s=pr(ne(t),e),i=s?.[F];if(i&&i.base_===r)return t.copy_[e]=r,t.assigned_.set(e,!1),!0;if(Ai(r,s)&&(r!==void 0||dr(t.base_,e,t.type_)))return!0;dt(t),Sr(t)}return t.copy_[e]===r&&(r!==void 0||dr(t.copy_,e,t.type_))||Number.isNaN(r)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=r,t.assigned_.set(e,!0),Ii(t,e,r)),!0},deleteProperty(t,e){return dt(t),pr(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),Sr(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){let r=ne(t),n=Reflect.getOwnPropertyDescriptor(r,e);return n&&{[ut]:!0,[fr]:t.type_!==1||e!=="length",[pt]:n[pt],[Fe]:r[e]}},defineProperty(){Y(11)},getPrototypeOf(t){return Re(t.base_)},setPrototypeOf(){Y(12)}},Be={};for(let t in yt){let e=yt[t];Be[t]=function(){let r=arguments;return r[0]=r[0][0],e.apply(this,r)}}Be.deleteProperty=function(t,e){return Be.set.call(this,t,e,void 0)};Be.set=function(t,e,r){return yt.set.call(this,t[0],e,r,t[0])};function pr(t,e){let r=t[F];return(r?ne(r):t)[e]}function Mi(t,e,r){return t.type_!==1||!t.allIndicesReassigned_||t.assigned_?.get(e)||!K(r)||r[F]?!1:t.baseRefs_.has(r)}function ki(t,e,r){let n=cs(e,r);return n?Fe in n?n[Fe]:n.get?.call(t.draft_):void 0}function cs(t,e){if(!(e in t))return;let r=Re(t);for(;r;){let n=Object.getOwnPropertyDescriptor(r,e);if(n)return n;r=Re(r)}}function Sr(t){t.modified_||(t.modified_=!0,t.parent_&&Sr(t.parent_))}function dt(t){t.copy_||(t.assigned_=new Map,t.copy_=gr(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Ni=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,r,n)=>{if(xe(e)&&!xe(r)){let i=r;r=e;let a=this;return function(c=i,...l){return a.produce(c,u=>r.call(this,u,...l))}}xe(r)||Y(6),n!==void 0&&!xe(n)&&Y(7);let s;if(K(e)){let i=Jn(this),a=Ar(i,e,void 0),o=!0;try{s=r(a),o=!1}finally{o?vr(i):Er(i)}return Xn(i,n),Zn(s,i)}else if(!e||!Tr(e)){if(s=r(e),s===void 0&&(s=e),s===ts&&(s=void 0),this.autoFreeze_&&_r(s,!0),n){let i=[],a=[];me(yr).generateReplacementPatches_(e,s,{patches_:i,inversePatches_:a}),n(i,a)}return s}else Y(1,e)},this.produceWithPatches=(e,r)=>{if(xe(e))return(a,...o)=>this.produceWithPatches(a,c=>e(c,...o));let n,s;return[this.produce(e,r,(a,o)=>{n=a,s=o}),n,s]},hr(t?.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),hr(t?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),hr(t?.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){K(t)||Y(8),ee(t)&&(t=ls(t));let e=Jn(this),r=Ar(e,t,void 0);return r[F].isManual_=!0,Er(e),r}finishDraft(t,e){let r=t&&t[F];(!r||!r.isManual_)&&Y(9);let{scope_:n}=r;return Xn(n,e),Zn(void 0,n)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let r;for(r=e.length-1;r>=0;r--){let s=e[r];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}r>-1&&(e=e.slice(r+1));let n=me(yr).applyPatches_;return ee(t)?n(t,e):this.produce(t,s=>n(s,e))}};function Ar(t,e,r,n){let[s,i]=At(e)?me(mt).proxyMap_(e,r):Tt(e)?me(mt).proxySet_(e,r):Oi(e,r);return(r?.scope_??ss()).drafts_.push(s),i.callbacks_=r?.callbacks_??[],i.key_=n,r&&n!==void 0?Ri(r,i,n):i.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(i);let{patchPlugin_:l}=c;i.modified_&&l&&l.generatePatches_(i,[],c)}),s}function ls(t){return ee(t)||Y(10,t),us(t)}function us(t){if(!K(t)||bt(t))return t;let e=t[F],r,n=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,r=gr(t,e.scope_.immer_.useStrictShallowCopy_),n=e.scope_.immer_.shouldUseStrictIteration()}else r=gr(t,!0);return Et(r,(s,i)=>{ft(r,s,us(i))},n),e&&(e.finalized_=!1),r}var Di=globalThis.Iterator,vo=typeof Di?.from=="function";var Pi=new Ni,Cr=Pi.produce;function ds(t){return({dispatch:r,getState:n})=>s=>i=>typeof i=="function"?i(r,n,t):s(i)}var hs=ds(),ps=ds;var Li=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Le:Le.apply(null,arguments)},Co=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(t){return t}},Fi=t=>t&&typeof t.match=="function";function ue(t,e){function r(...n){if(e){let s=e(...n);if(!s)throw new Error(se(0));return{type:t,payload:s.payload,..."meta"in s&&{meta:s.meta},..."error"in s&&{error:s.error}}}return{type:t,payload:n[0]}}return r.toString=()=>`${t}`,r.type=t,r.match=n=>zn(n)&&n.type===t,r}var vs=class qe extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,qe.prototype)}static get[Symbol.species](){return qe}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new qe(...e[0].concat(this)):new qe(...e.concat(this))}};function fs(t){return K(t)?Cr(t,()=>{}):t}function Ct(t,e,r){return t.has(e)?t.get(e):t.set(e,r(e)).get(e)}function Ui(t){return typeof t=="boolean"}var Bi=()=>function(e){let{thunk:r=!0,immutableCheck:n=!0,serializableCheck:s=!0,actionCreatorCheck:i=!0}=e??{},a=new vs;return r&&(Ui(r)?a.push(hs):a.push(ps(r.extraArgument))),a},Vi="RTK_autoBatch";var ms=t=>e=>{setTimeout(e,t)},qi=(t,e)=>r=>{let n=!1,s=()=>{n||(n=!0,cancelAnimationFrame(i),clearTimeout(a),r())},i=t(s),a=setTimeout(s,e)},ji=(t={type:"raf"})=>e=>(...r)=>{let n=e(...r),s=!0,i=!1,a=!1,o=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?qi(window.requestAnimationFrame,100):ms(10):t.type==="callback"?t.queueNotification:ms(t.timeout),l=()=>{a=!1,i&&(i=!1,o.forEach(u=>u()))};return Object.assign({},n,{subscribe(u){let h=()=>s&&u(),p=n.subscribe(h);return o.add(u),()=>{p(),o.delete(u)}},dispatch(u){try{return s=!u?.meta?.[Vi],i=!s,i&&(a||(a=!0,c(l))),n.dispatch(u)}finally{s=!0}}})},Hi=t=>function(r){let{autoBatch:n=!0}=r??{},s=new vs(t);return n&&s.push(ji(typeof n=="object"?n:void 0)),s};function Es(t){let e=Bi(),{reducer:r=void 0,middleware:n,devTools:s=!0,duplicateMiddlewareCheck:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{},c;if(typeof r=="function")c=r;else if(ct(r))c=Kn(r);else throw new Error(se(1));let l;typeof n=="function"?l=n(e):l=e();let u=Le;s&&(u=Li({trace:!1,...typeof s=="object"&&s}));let h=$n(...l),p=Hi(h),y=typeof o=="function"?o(p):p(),E=u(...y);return ur(c,a,E)}function Ss(t){let e={},r=[],n,s={addCase(i,a){let o=typeof i=="string"?i:i.type;if(!o)throw new Error(se(28));if(o in e)throw new Error(se(29));return e[o]=a,s},addAsyncThunk(i,a){return a.pending&&(e[i.pending.type]=a.pending),a.rejected&&(e[i.rejected.type]=a.rejected),a.fulfilled&&(e[i.fulfilled.type]=a.fulfilled),a.settled&&r.push({matcher:i.settled,reducer:a.settled}),s},addMatcher(i,a){return r.push({matcher:i,reducer:a}),s},addDefaultCase(i){return n=i,s}};return t(s),[e,r,n]}function Ki(t){return typeof t=="function"}function $i(t,e){let[r,n,s]=Ss(e),i;if(Ki(t))i=()=>fs(t());else{let o=fs(t);i=()=>o}function a(o=i(),c){let l=[r[c.type],...n.filter(({matcher:u})=>u(c)).map(({reducer:u})=>u)];return l.filter(u=>!!u).length===0&&(l=[s]),l.reduce((u,h)=>{if(h)if(ee(u)){let y=h(u,c);return y===void 0?u:y}else{if(K(u))return Cr(u,p=>h(p,c));{let p=h(u,c);if(p===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return u},o)}return a.getInitialState=i,a}var zi=(t,e)=>Fi(t)?t.match(e):t(e);function Gi(...t){return e=>t.some(r=>zi(r,e))}var Wi="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Qi=(t=21)=>{let e="",r=t;for(;r--;)e+=Wi[Math.random()*64|0];return e},Yi=["name","message","stack","code"],wr=class{constructor(t,e){this.payload=t,this.meta=e}payload;meta;_type},gs=class{constructor(t,e){this.payload=t,this.meta=e}payload;meta;_type},Xi=t=>{if(typeof t=="object"&&t!==null){let e={};for(let r of Yi)typeof t[r]=="string"&&(e[r]=t[r]);return e}return{message:String(t)}},ys="External signal was aborted",Ji=(()=>{function t(e,r,n){let s=ue(e+"/fulfilled",(c,l,u,h)=>({payload:c,meta:{...h||{},arg:u,requestId:l,requestStatus:"fulfilled"}})),i=ue(e+"/pending",(c,l,u)=>({payload:void 0,meta:{...u||{},arg:l,requestId:c,requestStatus:"pending"}})),a=ue(e+"/rejected",(c,l,u,h,p)=>({payload:h,error:(n&&n.serializeError||Xi)(c||"Rejected"),meta:{...p||{},arg:u,requestId:l,rejectedWithValue:!!h,requestStatus:"rejected",aborted:c?.name==="AbortError",condition:c?.name==="ConditionError"}}));function o(c,{signal:l}={}){return(u,h,p)=>{let y=n?.idGenerator?n.idGenerator(c):Qi(),E=new AbortController,C,m;function I(g){m=g,E.abort()}l&&(l.aborted?I(ys):l.addEventListener("abort",()=>I(ys),{once:!0}));let j=(async function(){let g;try{let T=n?.condition?.(c,{getState:h,extra:p});if(ea(T)&&(T=await T),T===!1||E.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let X=new Promise((w,k)=>{C=()=>{k({name:"AbortError",message:m||"Aborted"})},E.signal.addEventListener("abort",C,{once:!0})});u(i(y,c,n?.getPendingMeta?.({requestId:y,arg:c},{getState:h,extra:p}))),g=await Promise.race([X,Promise.resolve(r(c,{dispatch:u,getState:h,extra:p,requestId:y,signal:E.signal,abort:I,rejectWithValue:((w,k)=>new wr(w,k)),fulfillWithValue:((w,k)=>new gs(w,k))})).then(w=>{if(w instanceof wr)throw w;return w instanceof gs?s(w.payload,y,c,w.meta):s(w,y,c)})])}catch(T){g=T instanceof wr?a(null,y,c,T.payload,T.meta):a(T,y,c)}finally{C&&E.signal.removeEventListener("abort",C)}return n&&!n.dispatchConditionRejection&&a.match(g)&&g.meta.condition||u(g),g})();return Object.assign(j,{abort:I,requestId:y,arg:c,unwrap(){return j.then(Zi)}})}}return Object.assign(o,{pending:i,rejected:a,fulfilled:s,settled:Gi(a,s),typePrefix:e})}return t.withTypes=()=>t,t})();function Zi(t){if(t.meta&&t.meta.rejectedWithValue)throw t.payload;if(t.error)throw t.error;return t.payload}function ea(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}var As=Symbol.for("rtk-slice-createasyncthunk"),xo={[As]:Ji};function ta(t,e){return`${t}/${e}`}function ra({creators:t}={}){let e=t?.asyncThunk?.[As];return function(n){let{name:s,reducerPath:i=s}=n;if(!s)throw new Error(se(11));typeof process<"u";let a=(typeof n.reducers=="function"?n.reducers(sa()):n.reducers)||{},o=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},l={addCase(g,A){let T=typeof g=="string"?g:g.type;if(!T)throw new Error(se(12));if(T in c.sliceCaseReducersByType)throw new Error(se(13));return c.sliceCaseReducersByType[T]=A,l},addMatcher(g,A){return c.sliceMatchers.push({matcher:g,reducer:A}),l},exposeAction(g,A){return c.actionCreators[g]=A,l},exposeCaseReducer(g,A){return c.sliceCaseReducersByName[g]=A,l}};o.forEach(g=>{let A=a[g],T={reducerName:g,type:ta(s,g),createNotation:typeof n.reducers=="function"};aa(A)?ca(T,A,l,e):ia(T,A,l)});function u(){let[g={},A=[],T=void 0]=typeof n.extraReducers=="function"?Ss(n.extraReducers):[n.extraReducers],X={...g,...c.sliceCaseReducersByType};return $i(n.initialState,w=>{for(let k in X)w.addCase(k,X[k]);for(let k of c.sliceMatchers)w.addMatcher(k.matcher,k.reducer);for(let k of A)w.addMatcher(k.matcher,k.reducer);T&&w.addDefaultCase(T)})}let h=g=>g,p=new Map,y=new WeakMap,E;function C(g,A){return E||(E=u()),E(g,A)}function m(){return E||(E=u()),E.getInitialState()}function I(g,A=!1){function T(w){let k=w[g];return typeof k>"u"&&A&&(k=Ct(y,T,m)),k}function X(w=h){let k=Ct(p,A,()=>new WeakMap);return Ct(k,w,()=>{let Kr={};for(let[si,ii]of Object.entries(n.selectors??{}))Kr[si]=na(ii,w,()=>Ct(y,w,m),A);return Kr})}return{reducerPath:g,getSelectors:X,get selectors(){return X(T)},selectSlice:T}}let j={name:s,reducer:C,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:m,...I(i),injectInto(g,{reducerPath:A,...T}={}){let X=A??i;return g.inject({reducerPath:X,reducer:C},T),{...j,...I(X,!0)}}};return j}}function na(t,e,r,n){function s(i,...a){let o=e(i);return typeof o>"u"&&n&&(o=r()),t(o,...a)}return s.unwrapped=t,s}var Ts=ra();function sa(){function t(e,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...r}}return t.withTypes=()=>t,{reducer(e){return Object.assign({[e.name](...r){return e(...r)}}[e.name],{_reducerDefinitionType:"reducer"})},preparedReducer(e,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:r}},asyncThunk:t}}function ia({type:t,reducerName:e,createNotation:r},n,s){let i,a;if("reducer"in n){if(r&&!oa(n))throw new Error(se(17));i=n.reducer,a=n.prepare}else i=n;s.addCase(t,i).exposeCaseReducer(e,i).exposeAction(e,a?ue(t,a):ue(t))}function aa(t){return t._reducerDefinitionType==="asyncThunk"}function oa(t){return t._reducerDefinitionType==="reducerWithPrepare"}function ca({type:t,reducerName:e},r,n,s){if(!s)throw new Error(se(18));let{payloadCreator:i,fulfilled:a,pending:o,rejected:c,settled:l,options:u}=r,h=s(t,i,u);n.exposeAction(e,h),a&&n.addCase(h.fulfilled,a),o&&n.addCase(h.pending,o),c&&n.addCase(h.rejected,c),l&&n.addMatcher(h.settled,l),n.exposeCaseReducer(e,{fulfilled:a||wt,pending:o||wt,rejected:c||wt,settled:l||wt})}function wt(){}var bs="listener",_s="completed",Cs="cancelled",Ro=`task-${Cs}`,Io=`task-${_s}`,Oo=`${bs}-${Cs}`,Mo=`${bs}-${_s}`;var{assign:ws}=Object;var xr="listenerMiddleware";var la=ws(ue(`${xr}/add`),{withTypes:()=>la}),ko=ue(`${xr}/removeAll`),ua=ws(ue(`${xr}/remove`),{withTypes:()=>ua});function se(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var da=tt(Symbol("withEventBus"),function(t,e){return class extends t{constructor(){super(...arguments),this.eventBus=e??document.createElement("span")}addEventListener(r,n,s){this.eventBus.addEventListener(r,n,s)}dispatchEvent(r){return this.eventBus.dispatchEvent(r)}removeEventListener(r,n,s){this.eventBus.removeEventListener(r,n,s)}}}),xt=class extends da(Object){};window.ftReduxStores||(window.ftReduxStores={});var xs=class t extends xt{static get(e){var r;let n=typeof e=="string"?e:e.name,s=typeof e=="string"?void 0:e,i=window.ftReduxStores[n];if(at(i))return i;if(s==null)return;let a=Ts({...s,reducers:(r=s.reducers)!==null&&r!==void 0?r:{}}),o=Es({reducer:(c,l)=>{if(l.type==="CLEAR_FT_REDUX_STORE"){let u=Ne(a.getInitialState());for(let h of l.keeping)u[h]=(c??u)[h];return u}else if(typeof l.type=="string"&&l.type.startsWith("DEFAULT_VALUE_SETTER__"))return{...c,...l.overwrites};return a.reducer(c,l)}});return window.ftReduxStores[s.name]=new t(a,o,s.eventBus)}constructor(e,r,n){super(),this.reduxSlice=e,this.reduxStore=r,this.isFtReduxStore=!0,this.commands=new rt,this.injectInto=(i,a)=>this.reduxSlice.injectInto(i,a),this.selectSlice=i=>this.reduxSlice.selectSlice(i);let s=i=>i!=null?JSON.parse(JSON.stringify(i)):i;this.actions=new Proxy(this.reduxSlice.actions,{get:(i,a,o)=>{let c=a,l=i[c];return l?(...u)=>{let h=l(...u.map(s));return this.reduxStore.dispatch(h),h}:u=>{let h=c,p=this.getState()[h];_e(p,u)||this.setState({[h]:s(u)})}}}),this.eventBus=n??this.eventBus}clear(){this.reduxStore.dispatch({type:"CLEAR_FT_REDUX_STORE",keeping:[]})}clearKeeping(...e){this.reduxStore.dispatch({type:"CLEAR_FT_REDUX_STORE",keeping:e})}setState(e){this.reduxStore.dispatch({type:"DEFAULT_VALUE_SETTER__"+Object.keys(e).join("_"),overwrites:e})}get dispatch(){throw new Error("Don't use this method, actions are automatically dispatched when called.")}[Symbol.observable](){return this.reduxStore[Symbol.observable]()}getState(){return this.reduxStore.getState()}replaceReducer(e){throw new Error("Not implemented yet.")}subscribe(e){return this.reduxStore.subscribe(e)}get name(){return this.reduxSlice.name}get reducer(){return this.reduxSlice.reducer}get caseReducers(){return this.reduxSlice.caseReducers}getInitialState(){return this.reduxSlice.getInitialState()}get selectors(){return this.reduxSlice.selectors}get reducerPath(){return this.reduxSlice.reducerPath}getSelectors(){return this.reduxSlice.getSelectors()}};var Rt=class{static format(e,r,n,s,i){return window.moment?window.moment(e).locale(r).format(this.getMomentDateFormat(n,s,!!i)):this.getIntlDateTime(e,r,n,s,!!i)}static getMomentDateFormat(e,r,n){return n?"LT":e?r?"lll":"ll":r?"L LT":"L"}static getIntlDateTime(e,r,n,s,i){let a=typeof e=="string"?new Date(e):e,o=new Intl.DateTimeFormat(r,{dateStyle:n?"medium":"short"}).format(a),c=new Intl.DateTimeFormat(r,{timeStyle:"short"}).format(a);return i?c:s?`${o} ${c}`:o}static getTimezoneAsString(){let e=n=>String(Math.floor(n)).padStart(2,"0"),r=new Date().getTimezoneOffset();return`${r<0?"+":"-"}${e(Math.abs(r)/60)}:${e(Math.abs(r)%60)}`}};var It=f(b()),ha="ft-app-info",$=class t extends CustomEvent{constructor(e){super(t.eventName,{detail:e})}};$.eventName="authentication-change";var je=class t extends CustomEvent{constructor(e){super(t.eventName,{detail:e})}};je.eventName="ui-locale-changed";var pa={session:(t,e)=>{(0,It.deepEqual)(t.session,e.payload)||(t.session=e.payload,setTimeout(()=>d.dispatchEvent(new $(e.payload)),0))}},d=It.FtReduxStore.get({name:ha,reducers:pa,initialState:{baseUrl:void 0,tenantId:void 0,apiIntegrationIdentifier:void 0,apiIntegrationAppVersion:void 0,uiLocale:document.documentElement.lang||"en-US",availableContentLocales:[],localesConfiguration:void 0,metadataConfiguration:void 0,privacyPolicyConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,noCustomCode:!1,session:void 0,openExternalDocumentInNewTab:!1,navigatorOnline:!0,forcedOffline:!1,authenticationRequired:!1,stickyFilters:void 0}});var Rs=f(b()),Ot=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},cc=(0,Rs.applyMixinOnce)(Symbol("withDateFormat"),function(t){class e extends t{constructor(...n){super(n),this.useLongDateFormat=!1,this.useDateTimeFormat=!1,this.metadataDescriptors=[],this.uiLocale="en-US",this.addStore(d)}dateFormatOptionsChanged(n){return n.has("metadataDescriptors")||n.has("useLongDateFormat")||n.has("useDateTimeFormat")||n.has("uiLocale")}getDateFormatter(n){var s,i;return((i=(s=this.metadataDescriptors.find(o=>o.key===n))===null||s===void 0?void 0:s.date)!==null&&i!==void 0?i:!1)?o=>Rt.format(o,this.uiLocale,this.useLongDateFormat,this.useDateTimeFormat):void 0}}return Ot([(0,Rr.property)({type:Boolean})],e.prototype,"useLongDateFormat",void 0),Ot([(0,Rr.property)({type:Boolean})],e.prototype,"useDateTimeFormat",void 0),Ot([cr({store:d.name,selector:r=>{var n,s;return(s=(n=r.metadataConfiguration)===null||n===void 0?void 0:n.descriptors)!==null&&s!==void 0?s:[]}})],e.prototype,"metadataDescriptors",void 0),Ot([cr({store:d.name})],e.prototype,"uiLocale",void 0),e});var Pt=f(b());var Ir=f(b());var ge=class t{static get(e){let{baseUrl:r,apiIntegrationIdentifier:n}=d.getState(),s=e??n;if(r&&s&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(r,s,!0)}static await(e){return new Promise(r=>{let n=t.get(e);if(n)r(n);else{let s=d.subscribe(()=>{n=t.get(e),n&&(s(),r(n))})}})}};var Ie=class{constructor(e){this.overrideApi=e}get api(){var e;return(e=this.overrideApi)!==null&&e!==void 0?e:ge.get()}get awaitApi(){return this.overrideApi?Promise.resolve(this.overrideApi):ge.await()}};var N=class extends Ie{constructor(e=!0,r){var n;super(r),this.sortObjectFields=(i,a)=>typeof a!="object"||a==null||Array.isArray(a)?a:Object.fromEntries(Object.entries(a).sort(([o],[c])=>o.localeCompare(c)));let s=this.constructor;s.commonCache=(n=s.commonCache)!==null&&n!==void 0?n:new Ir.CacheRegistry,this.cache=e?s.commonCache:new Ir.CacheRegistry}clearCache(){this.cache.clearAll()}hash(e){return String(Array.from(JSON.stringify(e,this.sortObjectFields)).reduce((r,n)=>0|31*r+n.charCodeAt(0),0))}};var Mt=class extends N{async listMySearches(){let{session:e}=d.getState();return G(e,S.SAVED_SEARCH_USER)?this.cache.get("my-searches",async()=>(await this.awaitApi).listMySearches(e.profile.userId),300*1e3):[]}};var kt=class extends N{async listMyBookmarks(){let e=d.getState().session;return e?.sessionAuthenticated?this.cache.get("my-bookmarks",async()=>(await this.awaitApi).listMyBookmarks(e.profile.userId),300*1e3):[]}};var Nt=class extends N{constructor(){super(...arguments),this.CACHE_DURATION=180*1e3}async getUserAssetCount(e){if(this.isAuthenticated())return this.cache.get(`user-asset-count-${e}`,async()=>(await this.awaitApi).get(`/internal/api/webapp/user/assets/count/${e}`),this.CACHE_DURATION)}async getUserBookmarkCountByMap(e){if(this.isAuthenticated())return this.cache.get(`user-bookmark-count-by-map-${e}`,async()=>(await this.awaitApi).get(`/internal/api/webapp/user/assets/count/BOOKMARKS/${e}`),this.CACHE_DURATION)}isAuthenticated(){let e=d.getState().session;return!!e?.sessionAuthenticated}};var Dt=class extends N{constructor(){super(...arguments),this.CACHE_DURATION=180*1e3}async getUserAssetLabels(){return this.isAuthenticated()?this.cache.get("user-asset-labels",async()=>(await this.awaitApi).get("/internal/api/webapp/user/assets/labels"),this.CACHE_DURATION):[]}isAuthenticated(){let e=d.getState().session;return!!e?.sessionAuthenticated}};var fa="ft-user-assets",ma={setAssetCount:(t,e)=>{let{userAssetType:r,count:n}=e.payload.assetCount;t.assetCounts.allAsset[r]=n},clearAssetCount:t=>{Object.values(z).forEach(e=>{t.assetCounts.allAsset[e]=void 0})},setBookmarkCountByMap:(t,e)=>{let r=e.payload.mapId;t.assetCounts.bookmarkByMap[r]=e.payload.count},clearBookmarkCountByMap:t=>{t.assetCounts.bookmarkByMap={}},addAsset:(t,e)=>{let{assetType:r,mapId:n,asset:s}=e.payload;Mr(t,r,[...Or(t,r),s]),Is(t,r,1,n),Os(t,s)},editAsset:(t,e)=>{let{assetType:r,asset:n}=e.payload;Mr(t,r,Or(t,r).map(s=>s.id===n.id?n:s)),Os(t,n)},removeAsset:(t,e)=>{let{assetType:r,mapId:n,assetId:s}=e.payload;Mr(t,r,Or(t,r).filter(i=>i.id!==s)),Is(t,r,-1,n)}},Ms={[z.SEARCHES]:"savedSearches",[z.BOOKMARKS]:"bookmarks",[z.BOOKS]:void 0,[z.COLLECTIONS]:void 0},Or=(t,e)=>{var r;let n=Ms[e];return n?(r=t[n])!==null&&r!==void 0?r:[]:[]},Mr=(t,e,r)=>{let n=Ms[e];n&&(t[n]=r)},Is=(t,e,r,n)=>{let s=t.assetCounts.allAsset[e];if(s!==void 0&&(t.assetCounts.allAsset[e]=Math.max(0,s+r),e===z.BOOKMARKS&&n)){let i=t.assetCounts.bookmarkByMap[n];t.assetCounts.bookmarkByMap[n]=Math.max(0,i+r)}},Os=(t,e)=>{let r=t.assetLabels.map(s=>s.title),n=e.labels.filter(s=>!r.includes(s)).map(s=>({title:s}));t.assetLabels.push(...n)},B=Pt.FtReduxStore.get({name:fa,reducers:ma,initialState:{savedSearches:void 0,bookmarks:void 0,assetCounts:{allAsset:Object.fromEntries(Object.values(z).map(t=>[t,void 0])),bookmarkByMap:{}},assetLabels:[]}}),kr=class{constructor(e=new Nt,r=new Dt){this.assetCountsService=e,this.assetLabelsService=r,this.currentSession=d.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new kt,this.savedSearchesService=new Mt,d.subscribe(()=>this.reloadWhenUserSessionChanges())}reloadWhenUserSessionChanges(){var e;let{session:r}=d.getState();(0,Pt.deepEqual)((e=this.currentSession)===null||e===void 0?void 0:e.profile,r?.profile)||(this.currentSession=r,this.clearMySearches(),this.reloadBookmarks(),this.clearUserAssetCounts(),this.reloadAssetLabels())}clearUserAssetCounts(){this.assetCountsService.clearCache(),B.actions.clearAssetCount(),B.actions.clearBookmarkCountByMap()}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),B.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),B.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();let e=await this.savedSearchesService.listMySearches();B.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async reloadAssetLabels(){this.assetLabelsService.clearCache();let e=await this.assetLabelsService.getUserAssetLabels();B.actions.assetLabels(e)}async loadAssetCount(e){let r=await this.assetCountsService.getUserAssetCount(e);r&&B.getState().assetCounts.allAsset[e]!==r.count&&B.actions.setAssetCount({assetCount:r})}async loadBookmarkByMapId(e){let r=await this.assetCountsService.getUserBookmarkCountByMap(e);r&&B.getState().assetCounts.bookmarkByMap[e]!==r.count&&B.actions.setBookmarkCountByMap({count:r.count,mapId:e})}async reloadAssetCount(e){this.assetCountsService.clearCache();let r=Object.keys(B.getState().assetCounts.bookmarkByMap).length!==0;e===z.BOOKMARKS&&r&&B.actions.clearBookmarkCountByMap(),B.getState().assetCounts.allAsset[e]!==void 0&&await this.loadAssetCount(e)}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var e;if(this.bookmarksAreUsed){let r=!((e=this.currentSession)===null||e===void 0)&&e.sessionAuthenticated?await this.bookmarksService.listMyBookmarks():void 0;B.actions.bookmarks(r)}}},Nr=new kr;window.FluidTopicsUserAssetsActions==null&&(window.FluidTopicsUserAssetsActions=Nr);var Dr=class{addCommand(e,r=!1){d.commands.add(e,r)}consumeCommand(e){return d.commands.consume(e)}};window.FluidTopicsAppInfoStoreService=new Dr;var W=f(b());var ks,Oe=class extends CustomEvent{constructor(e){super("ft-i18n-context-loaded",{detail:e})}},ga=Symbol("clearAfterUnitTest"),Lt=class extends(0,W.withEventBus)(N){constructor(e){super(),this.messageContextProvider=e,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[ks]=()=>{this.defaultMessages={},this.cache=new W.CacheRegistry,this.listeners={}},this.currentUiLocale=d.getState().uiLocale,d.subscribe(()=>this.clearWhenUiLocaleChanges())}clearWhenUiLocaleChanges(){let{uiLocale:e}=d.getState();this.currentUiLocale!==e&&(this.currentUiLocale=e,this.cache.clearAll(),this.notifyAll())}addContext(e){let r=e.name.toLowerCase();this.cache.setFinal(r,e),this.notify(r)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(e,r){var n;if(e=e.toLowerCase(),r&&Object.keys(r).length>0){let s={...(n=this.defaultMessages[e])!==null&&n!==void 0?n:{},...r};(0,W.deepEqual)(this.defaultMessages[e],s)||(this.defaultMessages[e]=s,await this.notify(e))}return this.fetchContext(e)}resolveContext(e){var r,n;return this.fetchContext(e),(n=(r=this.cache.getNow(e))===null||r===void 0?void 0:r.messages)!==null&&n!==void 0?n:{}}resolveRawMessage(e,r){let n=e.toLowerCase();return this.resolveContext(n)[r]}resolveMessage(e,r,...n){var s;let i=e.toLowerCase(),a=this.resolveContext(i);return new W.ParametrizedLabelResolver((s=this.defaultMessages[i])!==null&&s!==void 0?s:{},a).resolve(r,...n)}async fetchContext(e){let r=!this.cache.has(e),n;try{n=await this.cache.get(e,()=>this.messageContextProvider(this.currentUiLocale,e)),r&&await this.notify(e)}catch(s){!(s instanceof W.CanceledPromiseError)&&r&&console.error(s)}return n}subscribe(e,r){var n;return e=e.toLowerCase(),this.listeners[e]=(n=this.listeners[e])!==null&&n!==void 0?n:new Set,this.listeners[e].add(r),()=>{var s;return(s=this.listeners[e])===null||s===void 0?void 0:s.delete(r)}}async notifyAll(){let e=Object.keys(this.listeners);document.body.dispatchEvent(new Oe({loadedContexts:e})),this.dispatchEvent(new Oe({loadedContexts:e})),await Promise.all(e.map(r=>this.notify(r,!1)))}async notify(e,r=!0){r&&(document.body.dispatchEvent(new Oe({loadedContexts:[e]})),this.dispatchEvent(new Oe({loadedContexts:[e]}))),this.listeners[e]!=null&&await Promise.all([...this.listeners[e].values()].map(n=>(0,W.delay)(0).then(()=>n()).catch(()=>null)))}};ks=ga;window.FluidTopicsI18nService==null&&(window.FluidTopicsI18nService=new class extends Lt{constructor(){super(async(t,e)=>(await this.awaitApi).getFluidTopicsMessageContext(t,e))}});window.FluidTopicsCustomI18nService==null&&(window.FluidTopicsCustomI18nService=new class extends Lt{constructor(){super(async(t,e)=>(await this.awaitApi).getCustomMessageContext(t,e))}});var Ns=window.FluidTopicsI18nService,Hc=window.FluidTopicsCustomI18nService;var Ds=f(b()),Pr=class{highlightHtml(e,r,n){(0,Ds.highlightHtml)(e,r,n)}};window.FluidTopicsHighlightHtmlService=new Pr;var Ps=f(b());var Lr=class{isDate(e){var r,n,s,i;return(i=(n=((s=(r=d.getState().metadataConfiguration)===null||r===void 0?void 0:r.descriptors)!==null&&s!==void 0?s:[]).find(o=>o.key===e))===null||n===void 0?void 0:n.date)!==null&&i!==void 0?i:!1}format(e,r){var n,s,i,a;if(e==null)return"";try{return Ps.DateFormatter.format(e,(n=r?.locale)!==null&&n!==void 0?n:d.getState().uiLocale,(s=r?.longFormat)!==null&&s!==void 0?s:!1,(i=r?.withTime)!==null&&i!==void 0?i:!1,(a=r?.onlyTime)!==null&&a!==void 0?a:!1)}catch(o){throw console.error(`Date ${JSON.stringify(e)} is not valid`,o),o}}};window.FluidTopicsDateService=new Lr;var Ls=f(b());var He=class{static get(e,r){var n,s,i,a;let o=d.getState(),{lang:c,region:l}=(a=(s=(n=o.localesConfiguration)===null||n===void 0?void 0:n.defaultLocales)===null||s===void 0?void 0:s.defaultContentLocale)!==null&&a!==void 0?a:{lang:"en",region:"US"};return new Ls.SearchPlaceConverter(o.baseUrl,e??20,(i=o.localesConfiguration)===null||i===void 0?void 0:i.allLanguagesAllowed,r??`${c}-${l}`)}};var Me=class extends N{async sendDocumentStartDisplayEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.start_display event")}async sendTopicStartDisplayEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send topic.start_display event")}async sendKhubSearchEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send khub.search event")}async sendDocumentSearchEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.search event")}async sendSearchPageSelectEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send search_page.select event")}async sendSearchResultOpenContextMenuEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send search_result.open_context_menu event")}async sendDocumentOnDemandTranslateEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.on_demand_translate event")}async sendTopicAiTranslateEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send topic.ai_translate event")}convertMapToAnalyticsDocument(e){let r;switch(e.editorialType){case"BOOK":r="STRUCTURED_DOCUMENT";break;case"SHARED_BOOK":r="SHARED_PERSONAL_BOOK";break;case"ARTICLE":r="RESOURCE";break;case"HTML_PACKAGE":r="HTML_PACKAGE";break;default:throw new TypeError("Unknown editorial type for map : "+e.editorialType)}return{id:e.id,title:e.title,type:r,metadata:e.metadata}}sortEventArrays(e){let r=Object.entries(e).map(([n,s])=>Array.isArray(s)?[n,s.map(i=>typeof i=="object"&&i!=null&&!Array.isArray(i)?this.sortEventArrays(i):i).sort((i,a)=>typeof i=="object"&&i!==null&&"key"in i?i.key.localeCompare(a.key):typeof i=="string"&&typeof a=="string"?i.localeCompare(a):String(i).localeCompare(String(a)))]:typeof s=="object"&&s!==null?[n,this.sortEventArrays(s)]:[n,s]);return Object.fromEntries(r)}sendEvents(e,r){let n="anything not undefined";return this.cache.get("analytics-event-"+this.hash(e),async()=>(await this.awaitApi).sendEvents(e).then(()=>n).catch(s=>(console.info(r),console.debug(s),n)),1e3)}};var Fr=class{urlToSearchRequest(e){return He.get().parse(e)}searchRequestToUrl(e){return He.get().serialize(e)}};window.FluidTopicsUrlService=new Fr;var ie=f(b());var ye=class t extends CustomEvent{constructor(e){super(t.eventName,{detail:{nextLocation:e}})}};ye.eventName="before-location-change";var ve=class t extends CustomEvent{constructor(e){super(t.eventName,{detail:{currentItem:e}})}};ve.eventName="change";var Ur=class{itemName(e){return`fluid-topics-history-item-${e}`}get(e){let r=sessionStorage.getItem(this.itemName(e));return r?JSON.parse(r):void 0}set(e,r){sessionStorage.setItem(this.itemName(e),JSON.stringify(r))}},Fs=new Ur;var Ft=class t extends ie.WithEventBus{static build(){return new t(window.history,Fs,()=>window.location,!1)}constructor(e,r,n,s){var i,a;super(),this.history=e,this.historyStorage=r,this.windowLocation=n,this.states=[],this.realPushState=e.pushState,this.realReplaceState=e.replaceState,this.initialIndex=(a=(i=e.state)===null||i===void 0?void 0:i.index)!==null&&a!==void 0?a:e.length-1,this.currentIndex=this.initialIndex,this.setCurrentState(this.buildCurrentState()),this.installProxies(),this.initEventListeners(),this.initData(s)}setCurrentState(e,r=!1){let n=r&&this.currentIndex===e.index-1;this.currentState={...this.buildCurrentState(),...e},this.currentIndex=this.currentState.index,this.states[this.currentIndex]=this.currentState,n&&(this.states=this.states.slice(0,this.currentIndex+1)),this.historyStorage.set(this.currentIndex,this.currentState),(0,ie.deepEqual)(this.currentState,this.history.state)||this.realReplaceState.apply(this.history,[this.currentState,this.currentState.title,this.windowLocation().href]),setTimeout(()=>this.dispatchEvent(new ve(this.currentItem())),0)}installProxies(){let e=r=>(n,s,[i,a,o])=>{let c=new ye(new URL(typeof o=="string"?o:(o??this.windowLocation()).href,window.location.origin));this.dispatchEvent(c);let l=r(),u={...l===this.currentIndex?this.currentState:void 0,...i,index:l,href:c.detail.nextLocation.href};n.apply(s,[u,a,u.href]),this.setCurrentState(u,!0)};this.history.pushState=new Proxy(this.history.pushState,{apply:e(()=>this.currentIndex+1)}),this.history.replaceState=new Proxy(this.history.replaceState,{apply:e(()=>this.currentIndex)})}initEventListeners(){window.addEventListener("popstate",e=>this.setCurrentState(e.state)),document.querySelector("title")==null&&document.head.append(document.createElement("title")),new MutationObserver(()=>this.updateCurrentState({title:document.title})).observe(document.querySelector("title"),{subtree:!0,characterData:!0,childList:!0})}initData(e){for(let r=this.history.length-1;r>=0;r--)e?this.states[r]=this.historyStorage.get(r):setTimeout(()=>this.states[r]=this.historyStorage.get(r),this.history.length-r)}updateCurrentState(e){var r;let n={...this.buildCurrentState(),...e,index:this.currentIndex,title:(r=e?.title)!==null&&r!==void 0?r:this.currentState.title};this.setCurrentState(n)}addBeforeLocationChangeListener(e){this.addEventListener(ye.eventName,e)}removeBeforeLocationChangeListener(e){this.removeEventListener(ye.eventName,e)}addHistoryChangeListener(e){this.addEventListener(ve.eventName,e)}removeHistoryChangeListener(e){this.removeEventListener(ve.eventName,e)}currentItem(){return(0,ie.deepCopy)(this.currentState)}back(){let e=this.previousDifferentMajorPosition();e>=0?this.history.go(e-this.currentIndex):this.currentIndex!==this.initialIndex?this.history.go(this.initialIndex-this.currentIndex):this.history.back()}backwardItem(){return(0,ie.deepCopy)(this.states[this.previousDifferentMajorPosition()])}backwardItemMatching(e){let r=this.states.filter(n=>!!n).filter(n=>n.index<this.currentIndex).reverse();return(0,ie.deepCopy)(r.find(n=>e(n)))}previousDifferentMajorPosition(){let e=this.currentIndex>0?this.currentIndex-1:0;for(;e>0&&!this.isDifferentMajorState(e);)e--;return e}forward(){let e=this.nextMajorPosition();e&&e<this.states.length?this.history.go(e-this.currentIndex):this.history.forward()}forwardItem(){let e=this.nextMajorPosition();if(e)return(0,ie.deepCopy)(this.states[e])}nextMajorPosition(){let e=this.currentIndex;if(!(e>=this.states.length)){do e++;while(e<this.states.length&&!this.isDifferentMajorState(e));return this.getHigherPositionInTheSameState(e)}}getHigherPositionInTheSameState(e){var r;let n=(r=this.states[e])===null||r===void 0?void 0:r.majorStateId;if(!n)return e;let s=e,i=e+1;for(;this.states.length>i&&!this.isDifferentMajorState(i,n);)this.hasState(i)&&(s=i),i++;return s}buildCurrentState(){var e,r;return{...this.history.state,index:this.currentIndex,href:this.windowLocation().href,title:(r=(e=this.history.state)===null||e===void 0?void 0:e.title)!==null&&r!==void 0?r:document.title}}hasState(e){return this.states[e]!=null}isDifferentMajorState(e,r){var n;if(!this.hasState(e))return!1;let s=r??this.currentState.majorStateId,i=(n=this.states[e])===null||n===void 0?void 0:n.majorStateId;return i==null||i!=s}};window.FluidTopicsInternalHistoryService==null&&(window.FluidTopicsInternalHistoryService=Ft.build(),window.FluidTopicsHistoryService={currentItem:()=>window.FluidTopicsInternalHistoryService.currentItem(),back:()=>window.FluidTopicsInternalHistoryService.back(),forward:()=>window.FluidTopicsInternalHistoryService.forward(),backwardItem:()=>window.FluidTopicsInternalHistoryService.backwardItem(),forwardItem:()=>window.FluidTopicsInternalHistoryService.forwardItem(),backwardItemMatching:t=>window.FluidTopicsInternalHistoryService.backwardItemMatching(t),addHistoryChangeListener:t=>window.FluidTopicsInternalHistoryService.addHistoryChangeListener(t),removeHistoryChangeListener:t=>window.FluidTopicsInternalHistoryService.removeHistoryChangeListener(t),addBeforeLocationChangeListener:t=>window.FluidTopicsInternalHistoryService.addBeforeLocationChangeListener(t),removeBeforeLocationChangeListener:t=>window.FluidTopicsInternalHistoryService.removeBeforeLocationChangeListener(t)});var Us=f(oe());var Bs=Us.css`
2
- `;var qs=f(oe()),V=f(te()),Ae=f(b());var Ee=f(b());function Vs(t,e){let{authenticationRequired:r,session:n}=d.getState();return r&&!n?.sessionAuthenticated?Promise.resolve(e):t()}var Ut=class extends Ie{async updateUiLocale(e){return(await this.awaitApi).updateUiLocale(e)}};var Br=class t extends Ee.FtStateManager{static build(e){return new t(d,e)}constructor(e,r){super(),this.store=e,this.cache=new Ee.CacheRegistry,this.withManualResources=!0,this.userLocaleService=new Ut,this.cleanSessionDebouncer=new Ee.Debouncer,this.reloadConfiguration=()=>{var n;(n=this.cache)===null||n===void 0||n.clear("availableContentLocales"),this.updateAvailableContentLocales()},this.reloadDebouncer=new Ee.Debouncer(500),this.apiProvider=r??(()=>ge.get())}setWithManualResources(e){this.withManualResources=e,this.updateIfNeeded()}addListeners(){this.store.addEventListener($.eventName,this.reloadConfiguration)}removeListeners(){this.store.removeEventListener($.eventName,this.reloadConfiguration)}async updateIfNeeded(){this.apiProvider()&&(this.withManualResources||(this.store.getState().session==null&&this.updateSession(),this.store.getState().metadataConfiguration==null&&this.updateMetadataConfiguration()),this.store.getState().localesConfiguration==null&&this.updateLocalesConfiguration(),(this.store.getState().availableContentLocales==null||this.store.getState().availableContentLocales.length==0)&&this.updateAvailableContentLocales())}async updateSession(){let e=await this.cache.get("session",async()=>{let r=await this.apiProvider().getCurrentSession();return r.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run(()=>{this.cache.clear("session"),this.setSession(void 0)},r.idleTimeoutInMillis),r});this.setSession(e)}async updateMetadataConfiguration(){this.setMetadataConfiguration(await this.cache.get("metadataConfiguration",()=>this.apiProvider().getMetadataConfiguration()))}async updateLocalesConfiguration(){this.setLocalesConfiguration(await this.cache.get("localesConfiguration",()=>this.apiProvider().getLocalesConfiguration()))}async updateAvailableContentLocales(){var e;let r=await this.cache.get("availableContentLocales",()=>Vs(()=>this.apiProvider().getAvailableSearchLocales(),{contentLocales:[]}));this.setAvailableContentLocales((e=r.contentLocales)!==null&&e!==void 0?e:[])}setStickyFilters(e){this.store.actions.stickyFilters(e)}setBaseUrl(e){this.store.actions.baseUrl(e),window.fluidTopicsBaseUrl=e}setTenantId(e){this.store.actions.tenantId(e)}setApiIntegrationIdentifier(e){this.store.actions.apiIntegrationIdentifier(e)}setApiIntegrationAppVersion(e){this.store.actions.apiIntegrationAppVersion(e)}setUiLocale(e){this.store.actions.uiLocale(e)}setLocalesConfiguration(e){this.store.actions.localesConfiguration(e),setTimeout(()=>this.updateIfNeeded())}setAvailableContentLocales(e){this.store.actions.availableContentLocales(e),setTimeout(()=>this.updateIfNeeded())}stopReloadDebouncer(){this.reloadDebouncer.cancel()}requestUiLocaleUpdate(e,r){this.userLocaleService.updateUiLocale({uiLocale:e,contentLocale:r}).then(n=>{n.uiLocaleChanged&&(this.reloadDebouncer.run(()=>window.location.reload()),this.store.dispatchEvent(new je(n)))}).catch(()=>{})}setMetadataConfiguration(e){this.store.actions.metadataConfiguration(e),setTimeout(()=>this.updateIfNeeded())}setNoCustom(e){this.store.actions.noCustom(e)}setEditorMode(e){this.store.actions.editorMode(e)}setNoCustomComponent(e){this.store.actions.noCustomComponent(e)}setNoCustomCode(e){this.store.actions.noCustomCode(e)}setSession(e){this.store.actions.session(e),setTimeout(()=>this.updateIfNeeded())}setOpenExternalDocumentInNewTab(e){this.store.actions.openExternalDocumentInNewTab(e)}setNavigatorOnline(e){this.store.actions.navigatorOnline(e)}setForcedOffline(e){this.store.actions.forcedOffline(e)}setAuthenticationRequired(e){this.store.actions.authenticationRequired(e)}userHasAnyRole(...e){return kn(d.getState().session,...e)}},Ke=Br.build();var Se=class extends Event{constructor(e,r,n,s){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=r,this.callback=n,this.subscribe=s??!1}};var $e=class{constructor(){this.pendingContextRequests=new Map,this.onContextProvider=e=>{let r=this.pendingContextRequests.get(e.context);if(r===void 0)return;this.pendingContextRequests.delete(e.context);let{requests:n}=r;for(let{elementRef:s,callbackRef:i}of n){let a=s.deref(),o=i.deref();a===void 0||o===void 0||a.dispatchEvent(new Se(e.context,a,o,!0))}},this.onContextRequest=e=>{if(e.subscribe!==!0)return;let r=e.contextTarget??e.composedPath()[0],n=e.callback,s=this.pendingContextRequests.get(e.context);s===void 0&&this.pendingContextRequests.set(e.context,s={callbacks:new WeakMap,requests:[]});let i=s.callbacks.get(r);i===void 0&&s.callbacks.set(r,i=new WeakSet),i.has(n)||(i.add(n),s.requests.push({elementRef:new WeakRef(r),callbackRef:new WeakRef(n)}))}}attach(e){e.addEventListener("context-request",this.onContextRequest),e.addEventListener("context-provider",this.onContextProvider)}detach(e){e.removeEventListener("context-request",this.onContextRequest),e.removeEventListener("context-provider",this.onContextProvider)}};var D=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},_=class extends Ae.FtLitElementRedux{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.apiIntegrationAppVersion="ft-integration-app-version",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.noCustomCode=!1,this.withManualResources=!1,this.navigatorOnline=!1,this.forcedOffline=!1,this.authenticationRequired=!1,this.messageContexts=[],this.stateManager=Ke,this.contextRoot=new $e}render(){return qs.html`
1
+ "use strict";(()=>{var ii=Object.create;var Kr=Object.defineProperty;var ai=Object.getOwnPropertyDescriptor;var oi=Object.getOwnPropertyNames;var ci=Object.getPrototypeOf,li=Object.prototype.hasOwnProperty;var ar=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var ui=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of oi(e))!li.call(t,s)&&s!==r&&Kr(t,s,{get:()=>e[s],enumerable:!(n=ai(e,s))||n.enumerable});return t};var f=(t,e,r)=>(r=t!=null?ii(ci(t)):{},ui(e||!t||!t.__esModule?Kr(r,"default",{value:t,enumerable:!0}):r,t));var T=ar((Ca,zr)=>{zr.exports=ftGlobals.wcUtils});var oe=ar((wa,Gr)=>{Gr.exports=ftGlobals.lit});var re=ar((xa,Wr)=>{Wr.exports=ftGlobals.litDecorators});var ri=f(T());var Ye=f(oe()),ae=f(re()),I=f(T());var de;(function(t){t.clusteringHelperCreated="clustering-helper-created",t.mapAttachmentsUpdate="map-attachments-update",t.visibleTopicChange="visible-topic-change",t.requestedTopicNotFound="requested-topic-not-found",t.requestedTopicFiltered="requested-topic-filtered"})(de||(de={}));var Xe=class extends CustomEvent{constructor(e){super(de.requestedTopicFiltered,{detail:e})}},ne;(function(t){t.FEEDBACK="FEEDBACK",t.RATING="RATING",t.PRINT="PRINT",t.BOOKMARK="BOOKMARK",t.COLLECTIONS="COLLECTIONS",t.PERSONAL_BOOKS="PERSONAL_BOOKS"})(ne||(ne={}));var P=f(T());var Qr=f(T()),di={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]}},Yr=t=>Qr.FtReduxStore.get({name:"ft-reader-"+t,initialState:{mapId:void 0,renderedTopics:[],visibleTopics:[],map:void 0,toc:void 0,pagesToc:void 0,filteredTocNodes:{},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,metadataFilters:[]},reducers:di});var or=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,filteredTocNodes:this.paginatedToc.filteredTocNodes}}extractPagesToc(e,r,n){return e.flatMap(s=>{var i;return s.pageConfiguration&&this.registerPage(this.buildPage(s,n)),s.tocId==null?this.extractPagesToc(s.children,r,n):[{tocId:s.tocId,title:(i=s.title)!==null&&i!==void 0?i:"",contentTag:s.contentTag,contentClass:s.contentClass,untranslatedTitle:s.untranslatedTitle,depth:r,children:this.extractPagesToc(s.children,r+1,s.tocId)}]})}convertNodes(e,r,n){return e.flatMap(s=>{var i,a,o;if(s.tocId==null)return[...this.convertSectionNodes((a=s.pageToc)!==null&&a!==void 0?a:[],r,s.tocId),...this.convertNodes(s.children,r,s.tocId)];let c=(i=s.prettyUrl)===null||i===void 0?void 0:i.replace(/^\//,""),l={tocId:s.tocId,contentId:s.contentId,title:s.title,contentTag:s.contentTag,contentClass:s.contentClass,untranslatedTitle:s.untranslatedTitle,hasRating:s.hasRating,origin:s.origin,prettyUrl:c,depth:r,parentTocId:n,children:[]};this.register(l);let u=this.convertSectionNodes((o=s.pageToc)!==null&&o!==void 0?o:[],r+1,s.tocId),h=this.convertNodes(s.children,r+1,l.tocId);return l.children=[...u,...h],[l]})}convertSectionNodes(e,r,n){return e.flatMap(s=>{var i;let a=(i=s.prettyUrl)===null||i===void 0?void 0:i.replace(/^\//,""),o={...s,prettyUrl:a,depth:r,parentTocId:n,children:[]};return this.register(o),o.children=this.convertSectionNodes(s.children,r+1,s.tocId),[o]})}buildPage(e,r){var n,s,i,a,o,c,l,u;let h=(a=e.tocId)!==null&&a!==void 0?a:(s=(n=e.pageToc)===null||n===void 0?void 0:n[0])===null||s===void 0?void 0:s.tocId,p={number:this.pages.length+1,title:(o=e.title)!==null&&o!==void 0?o:"",untranslatedTitle:e.untranslatedTitle,rootTocId:h??"root",toc:((c=e.pageToc)!==null&&c!==void 0?c:[]).map(m=>this.nodeByTocId[m.tocId]),topics:[],hiddenTopics:[],rootDepth:h?this.nodeByTocId[h].depth:1,breadcrumb:r?this.buildBreadcrumb(this.nodeByTocId[r]):[]},E=(m,x)=>(x?p.topics:p.hiddenTopics).push(m),S=(l=(i=e.pageConfiguration)===null||i===void 0?void 0:i.parentsVisibility)!==null&&l!==void 0?l:[];p.breadcrumb.forEach((m,x)=>{E(m,S[x])}),e.tocId&&E(e.tocId,e.pageConfiguration.isVisible),p.topics.push(...this.tocIds((u=e.pageToc)!==null&&u!==void 0?u:[]));let _=this.resolveOverridenRootTocIdByParentForcedByPagination(p.breadcrumb,S);return p.rootTocId=_??p.rootTocId,p.rootDepth=_?this.nodeByTocId[_].depth:p.rootDepth,p}resolveOverridenRootTocIdByParentForcedByPagination(e,r){for(let n=0;n<e.length;n++)if(r[n])return e[n]}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}},Je=class{convertPaginatedToc(e,r){return new or(e,r).build()}};var Xr;(function(t){t.black="black",t.green="green",t.blue="blue",t.purple="purple",t.red="red",t.orange="orange",t.yellow="yellow"})(Xr||(Xr={}));var Jr;(function(t){t.OFFICIAL="OFFICIAL",t.PERSONAL="PERSONAL",t.SHARED="SHARED"})(Jr||(Jr={}));var Zr;(function(t){t.STRUCTURED_DOCUMENT="STRUCTURED_DOCUMENT",t.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT",t.SHARED_PERSONAL_BOOK="SHARED_PERSONAL_BOOK",t.PERSONAL_BOOK="PERSONAL_BOOK",t.ATTACHMENT="ATTACHMENT",t.RESOURCE="RESOURCE",t.HTML_PACKAGE="HTML_PACKAGE"})(Zr||(Zr={}));var ce;(function(t){t.STRUCTURED_DOCUMENT="STRUCTURED_DOCUMENT",t.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT",t.SHARED_PERSONAL_BOOK="SHARED_PERSONAL_BOOK",t.PERSONAL_BOOK="PERSONAL_BOOK",t.ATTACHMENT="ATTACHMENT",t.RESOURCE="RESOURCE",t.HTML_PACKAGE="HTML_PACKAGE"})(ce||(ce={}));var en;(function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_QUARTER="LAST_QUARTER",t.LAST_YEAR="LAST_YEAR"})(en||(en={}));var tn;(function(t){t.VALUE="VALUE",t.DATE="DATE",t.RANGE="RANGE"})(tn||(tn={}));var Ze;(function(t){t.OFFICIAL="OFFICIAL",t.AI="AI"})(Ze||(Ze={}));var he;(function(t){t.BOOKMARK__CREATE="BOOKMARK__CREATE",t.BOOKMARK__DELETE="BOOKMARK__DELETE",t.CASE_DEFLECTION__START="CASE_DEFLECTION__START",t.CASE_DEFLECTION__OPEN_TICKET="CASE_DEFLECTION__OPEN_TICKET",t.CASE_DEFLECTION__RATE="CASE_DEFLECTION__RATE",t.CHATBOT__RATE="CHATBOT__RATE",t.COLLECTION__CREATE="COLLECTION__CREATE",t.COLLECTION__UPDATE="COLLECTION__UPDATE",t.COLLECTION__DELETE="COLLECTION__DELETE",t.CUSTOM_EVENT__TRIGGER="CUSTOM_EVENT__TRIGGER",t.DOCUMENT__ON_DEMAND_TRANSLATE="DOCUMENT__ON_DEMAND_TRANSLATE",t.DOCUMENT__DOWNLOAD="DOCUMENT__DOWNLOAD",t.DOCUMENT__PRINT="DOCUMENT__PRINT",t.DOCUMENT__PROCESS="DOCUMENT__PROCESS",t.DOCUMENT__RATE="DOCUMENT__RATE",t.DOCUMENT__SEARCH="DOCUMENT__SEARCH",t.DOCUMENT__START_DISPLAY="DOCUMENT__START_DISPLAY",t.DOCUMENT__UNRATE="DOCUMENT__UNRATE",t.FEEDBACK__SEND="FEEDBACK__SEND",t.AI__COMPLETED_QUERY="AI__COMPLETED_QUERY",t.AI__RATE="AI__RATE",t.AI_CASE_DEFLECTION__START="AI_CASE_DEFLECTION__START",t.AI_CASE_DEFLECTION__OPEN_TICKET="AI_CASE_DEFLECTION__OPEN_TICKET",t.KHUB__PROCESS="KHUB__PROCESS",t.KHUB__SEARCH="KHUB__SEARCH",t.LABELS__DOWNLOAD="LABELS__DOWNLOAD",t.LINK__SHARE="LINK__SHARE",t.PAGE__DISPLAY="PAGE__DISPLAY",t.PERSONAL_BOOK__CREATE="PERSONAL_BOOK__CREATE",t.PERSONAL_BOOK__DELETE="PERSONAL_BOOK__DELETE",t.PERSONAL_BOOK__UPDATE="PERSONAL_BOOK__UPDATE",t.PERSONAL_TOPIC__CREATE="PERSONAL_TOPIC__CREATE",t.PERSONAL_TOPIC__UPDATE="PERSONAL_TOPIC__UPDATE",t.PERSONAL_TOPIC__DELETE="PERSONAL_TOPIC__DELETE",t.SAVED_SEARCH__CREATE="SAVED_SEARCH__CREATE",t.SAVED_SEARCH__DELETE="SAVED_SEARCH__DELETE",t.SAVED_SEARCH__UPDATE="SAVED_SEARCH__UPDATE",t.SEARCH_PAGE__SELECT="SEARCH_PAGE__SELECT",t.SEARCH_RESULT__OPEN_BROWSER_CONTEXT_MENU="SEARCH_RESULT__OPEN_BROWSER_CONTEXT_MENU",t.TOPIC__AI_TRANSLATE="TOPIC__AI_TRANSLATE",t.TOPIC__RATE="TOPIC__RATE",t.TOPIC__START_DISPLAY="TOPIC__START_DISPLAY",t.TOPIC__UNRATE="TOPIC__UNRATE",t.USER__LOGIN="USER__LOGIN",t.USER__LOGOUT="USER__LOGOUT",t.HEARTBEAT="HEARTBEAT"})(he||(he={}));var rn;(function(t){t.STANDARD="STANDARD",t.STRUCTURAL="STRUCTURAL"})(rn||(rn={}));var nn;(function(t){t.METADATA_FILTER="METADATA_FILTER",t.ACCESS_RIGHTS_FILTER="ACCESS_RIGHTS_FILTER"})(nn||(nn={}));var sn;(function(t){t.THIRD_PARTY="THIRD_PARTY",t.OFF_THE_GRID="OFF_THE_GRID",t.CONTENT_PACKAGER="CONTENT_PACKAGER",t.PAGES="PAGES",t.DESIGNED_READER="DESIGNED_READER"})(sn||(sn={}));var an;(function(t){t.HOMEPAGE="HOMEPAGE",t.CUSTOM="CUSTOM",t.HEADER="HEADER",t.READER="READER",t.TOPIC_TEMPLATE="TOPIC_TEMPLATE",t.SEARCH="SEARCH",t.SEARCH_RESULT="SEARCH_RESULT",t.SEARCH_ANNOUNCEMENT="SEARCH_ANNOUNCEMENT",t.LINK_PREVIEW="LINK_PREVIEW",t.UD_VIEWER="UD_VIEWER",t.ASSET_VIEWER="ASSET_VIEWER"})(an||(an={}));var on;(function(t){t.CLASSIC="CLASSIC",t.CUSTOM="CUSTOM",t.DESIGNER="DESIGNER"})(on||(on={}));var cn;(function(t){t.AND="AND",t.OR="OR",t.MONOVALUED="MONOVALUED"})(cn||(cn={}));var ln;(function(t){t.NONE="NONE",t.ALPHABET="ALPHABET",t.VERSION="VERSION"})(ln||(ln={}));var un;(function(t){t.STARS="STARS",t.LIKE="LIKE",t.DICHOTOMOUS="DICHOTOMOUS",t.NO_RATING="NO_RATING"})(un||(un={}));var dn;(function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_QUARTER="LAST_QUARTER",t.LAST_YEAR="LAST_YEAR",t.CUSTOM="CUSTOM"})(dn||(dn={}));var et;(function(t){t.OPTIONAL="OPTIONAL",t.MANDATORY="MANDATORY"})(et||(et={}));var hn;(function(t){t.ASC="ASC",t.DESC="DESC"})(hn||(hn={}));var pn;(function(t){t.ALPHA="ALPHA",t.NATURAL="NATURAL"})(pn||(pn={}));var Te;(function(t){t.EVERYWHERE="EVERYWHERE",t.TITLE_ONLY="TITLE_ONLY",t.NONE="NONE"})(Te||(Te={}));var fn;(function(t){t.ARTICLE="ARTICLE",t.BOOK="BOOK",t.SHARED_BOOK="SHARED_BOOK",t.HTML_PACKAGE="HTML_PACKAGE"})(fn||(fn={}));var mn;(function(t){t.FLUIDTOPICS="FLUIDTOPICS",t.EXTERNAL="EXTERNAL"})(mn||(mn={}));var gn;(function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.PERSONAL_BOOK="PERSONAL_BOOK",t.SHARED_BOOK="SHARED_BOOK",t.HTML_PACKAGE="HTML_PACKAGE"})(gn||(gn={}));var yn;(function(t){t.LAST_WEEK="LAST_WEEK",t.LAST_MONTH="LAST_MONTH",t.LAST_QUARTER="LAST_QUARTER",t.LAST_YEAR="LAST_YEAR"})(yn||(yn={}));var J;(function(t){t.MAP="MAP",t.DOCUMENT="DOCUMENT",t.TOPIC="TOPIC",t.HTML_PACKAGE="HTML_PACKAGE",t.HTML_PACKAGE_PAGE="HTML_PACKAGE_PAGE"})(J||(J={}));var be;(function(t){t.DEFAULT="DEFAULT",t.DOCUMENTS="DOCUMENTS",t.ALL_TOPICS="ALL_TOPICS",t.TOPICS_AND_UNSTRUCTURED_DOCUMENTS="TOPICS_AND_UNSTRUCTURED_DOCUMENTS"})(be||(be={}));var vn;(function(t){t.PLAIN_TEXT="PLAIN_TEXT",t.LOCALIZED_OFFICIAL="LOCALIZED_OFFICIAL",t.LOCALIZED_CUSTOM="LOCALIZED_CUSTOM"})(vn||(vn={}));var A;(function(t){t.PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",t.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",t.HTML_EXPORT_USER="HTML_EXPORT_USER",t.PDF_EXPORT_USER="PDF_EXPORT_USER",t.SAVED_SEARCH_USER="SAVED_SEARCH_USER",t.COLLECTION_USER="COLLECTION_USER",t.OFFLINE_USER="OFFLINE_USER",t.ANALYTICS_USER="ANALYTICS_USER",t.BETA_USER="BETA_USER",t.DEBUG_USER="DEBUG_USER",t.PRINT_USER="PRINT_USER",t.RATING_USER="RATING_USER",t.FEEDBACK_USER="FEEDBACK_USER",t.GENERATIVE_AI_USER="GENERATIVE_AI_USER",t.GENERATIVE_AI_EXPORT_USER="GENERATIVE_AI_EXPORT_USER",t.CONTENT_PUBLISHER="CONTENT_PUBLISHER",t.BEHAVIOR_DATA_USER="BEHAVIOR_DATA_USER",t.ANNOUNCEMENT_ADMIN="ANNOUNCEMENT_ADMIN",t.KHUB_ADMIN="KHUB_ADMIN",t.USERS_ADMIN="USERS_ADMIN",t.PORTAL_ADMIN="PORTAL_ADMIN",t.ADMIN="ADMIN"})(A||(A={}));var G;(function(t){t.SEARCHES="SEARCHES",t.BOOKMARKS="BOOKMARKS",t.BOOKS="BOOKS",t.COLLECTIONS="COLLECTIONS"})(G||(G={}));var En;(function(t){t.UNAUTHENTICATED="UNAUTHENTICATED",t.USER_INCOMPLETE="USER_INCOMPLETE",t.MFA_REQUIRED="MFA_REQUIRED",t.AUTHENTICATED="AUTHENTICATED"})(En||(En={}));var Sn;(function(t){t.UNREACHABLE="UNREACHABLE",t.UNAUTHORIZED="UNAUTHORIZED",t.FORBIDDEN="FORBIDDEN",t.INCOMPATIBLE="INCOMPATIBLE",t.FAILED="FAILED",t.OK="OK"})(Sn||(Sn={}));var An;(function(t){t.VALID="VALID",t.INVALID="INVALID"})(An||(An={}));var Tn;(function(t){t.INACCURATE="INACCURATE",t.INCOMPLETE="INCOMPLETE",t.OFF_TOPIC="OFF_TOPIC",t.SEMANTIC_SEARCH="SEMANTIC_SEARCH",t.CHATBOT_INSTRUCTIONS="CHATBOT_INSTRUCTIONS",t.DOCUMENTATION="DOCUMENTATION",t.OTHER="OTHER"})(Tn||(Tn={}));var bn;(function(t){t.INACCURATE="INACCURATE",t.INCOMPLETE="INCOMPLETE",t.OFF_TOPIC="OFF_TOPIC",t.IRRELEVANT_SOURCES="IRRELEVANT_SOURCES",t.SLOW="SLOW",t.OTHER="OTHER"})(bn||(bn={}));var _n;(function(t){t.JSON="JSON",t.TEXT="TEXT"})(_n||(_n={}));var Cn;(function(t){t.JSON="JSON",t.TEXT="TEXT"})(Cn||(Cn={}));var wn;(function(t){t.TEXT="TEXT",t.HTML="HTML"})(wn||(wn={}));var xn;(function(t){t.IN_PROGRESS="IN_PROGRESS",t.ERROR="ERROR",t.DONE="DONE"})(xn||(xn={}));var Rn;(function(t){t.HTML="HTML",t.MARKDOWN="MARKDOWN"})(Rn||(Rn={}));var In;(function(t){t.SOURCES="SOURCES",t.ENRICH_AND_CLEAN="ENRICH_AND_CLEAN",t.VOCABULARIES="VOCABULARIES",t.METADATA="METADATA",t.PRETTY_URL="PRETTY_URL",t.ACCESS_RULE="ACCESS_RULE",t.DESIGNED_PAGES="DESIGNED_PAGES",t.THEME_STUDIO="THEME_STUDIO",t.PORTAL_GENERAL="PORTAL_GENERAL",t.ASSETS="ASSETS",t.CODE_LIBRARY="CODE_LIBRARY",t.THEME="THEME",t.CONTENT_STYLES="CONTENT_STYLES",t.HOMEPAGE="HOMEPAGE",t.CLASSIC_SEARCH_PAGE="CLASSIC_SEARCH_PAGE",t.CLASSIC_READER_PAGE="CLASSIC_READER_PAGE",t.PORTAL_METADATA="PORTAL_METADATA",t.LANGUAGES="LANGUAGES",t.PRINT_TEMPLATES="PRINT_TEMPLATES",t.OFFLINE="OFFLINE",t.CUSTOM_JS="CUSTOM_JS",t.CONFIDENTIALITY="CONFIDENTIALITY",t.NOTIFICATIONS="NOTIFICATIONS"})(In||(In={}));var On;(function(t){t.MAP="MAP",t.UNSTRUCTURED_DOCUMENT="UNSTRUCTURED_DOCUMENT"})(On||(On={}));var hi={[A.PERSONAL_BOOK_SHARE_USER]:[A.PERSONAL_BOOK_USER],[A.HTML_EXPORT_USER]:[A.PERSONAL_BOOK_USER],[A.PDF_EXPORT_USER]:[A.PERSONAL_BOOK_USER],[A.KHUB_ADMIN]:[A.CONTENT_PUBLISHER],[A.ADMIN]:[A.KHUB_ADMIN,A.USERS_ADMIN,A.PORTAL_ADMIN,A.BEHAVIOR_DATA_USER],[A.GENERATIVE_AI_EXPORT_USER]:[A.GENERATIVE_AI_USER]};function Mn(t,e){return t===e||(hi[t]??[]).some(r=>Mn(r,e))}function W(t,e){return t==null?!1:(Array.isArray(t)?t:Array.isArray(t.roles)?t.roles:Array.isArray(t.profile?.roles)?t.profile.roles:[]).some(n=>Mn(n,e))}function kn(t,...e){return t==null?!1:e.some(r=>W(t,r))}var Ir=f(re());var Nn=f(re(),1);var cr=t=>e=>{window.customElements.get(t)||window.customElements.define(t,e)},pi=t=>({fromAttribute:e=>{if(e==null)return Ne(t);try{return JSON.parse(e)}catch{return Ne(t)}},toAttribute:e=>JSON.stringify(e)});function Dn(t,e){return(0,Nn.property)({type:Object,converter:pi(t),hasChanged:De,...e??{}})}function fi(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;let r,n;if(Array.isArray(t)){if(r=t.length,r!=e.length)return!1;for(n=r;n--!==0;)if(!_e(t[n],e[n]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(n of t.entries())if(!e.has(n[0]))return!1;for(n of t.entries())if(!_e(n[1],e.get(n[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(n of t.entries())if(!e.has(n[0]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();let s=a=>Object.keys(a).filter(o=>a[o]!=null),i=s(t);if(r=i.length,r!==s(e).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(e,i[n]))return!1;for(n=r;n--!==0;){let a=i[n];if(!_e(t[a],e[a]))return!1}return!0}return t!==t&&e!==e||t==null&&e==null}function _e(t,e){try{return fi(t,e)}catch{return!1}}function De(t,e){return!_e(t,e)}function Ne(t){return typeof window.structuredClone=="function"?structuredClone(t):t!=null?JSON.parse(JSON.stringify(t)):t}function tt(t,e){let r=n=>n[t]===!0;return n=>{if(r(n))return n;let s=e(n);return s[t]=!0,s}}var Pn=f(re(),1);var lr=t=>{let e=t??{};return(r,n)=>{var s;let i={hasChanged:De,attribute:!1,...e};(0,Pn.property)(i)(r,n);let a=r.constructor;a.reduxProperties=new Map(a.reduxProperties),a.reduxProperties.set(n,{selector:(s=e.selector)!==null&&s!==void 0?s:(o=>o[n]),store:e.store})}};var rt=class{constructor(){this.queue=[]}add(e,r=!1){r&&this.clear(e.type),this.queue.push(e)}consume(e){let r=this.queue.find(n=>n.type===e);return r&&(this.queue=this.queue.filter(n=>n!==r)),r}clear(e){typeof e=="string"?this.queue=this.queue.filter(r=>r.type!==e):this.queue=this.queue.filter(r=>!e.test(r.type))}};var pe=f(re(),1);var nt=class{constructor(e=0){this.timeout=e,this.callbacks=[]}run(e,r){return this.callbacks=[e],this.debounce(r)}queue(e,r){return this.callbacks.push(e),this.debounce(r)}cancel(){this.clearTimeout(),this.resolvePromise&&this.resolvePromise(!1),this.clearPromise()}debounce(e){return this.promise==null&&(this.promise=new Promise((r,n)=>{this.resolvePromise=r,this.rejectPromise=n})),this.clearTimeout(),this._debounce=window.setTimeout(()=>this.runCallbacks(),e??this.timeout),this.promise}async runCallbacks(){var e,r;let n=[...this.callbacks];this.callbacks=[];let s=(e=this.rejectPromise)!==null&&e!==void 0?e:(()=>null),i=(r=this.resolvePromise)!==null&&r!==void 0?r:(()=>null);this.clearPromise();for(let a of n)try{await a()}catch(o){s(o);return}i(!0)}clearTimeout(){this._debounce!=null&&window.clearTimeout(this._debounce)}clearPromise(){this.promise=void 0,this.resolvePromise=void 0,this.rejectPromise=void 0}};var it=f(oe(),1);var st=class extends it.LitElement{get scopedRegistryConstructor(){return this.constructor}createRenderRoot(){let e=this.scopedRegistryConstructor;e.elementDefinitions&&!e.registry&&(e.registry=new CustomElementRegistry,e.defineScopedElements(e.elementDefinitions));let r={...e.shadowRootOptions,customElements:e.registry},n=this.renderOptions.creationScope=this.attachShadow(r);return(0,it.adoptStyles)(n,e.elementStyles),n}static canDefineScopedElement(e){return!!this.registry&&!this.registry.get(e)}static defineScopedElements(e){Object.entries(e).forEach(([r,n])=>this.defineScopedElement(r,n))}static defineScopedElement(e,r){cr(e)(r),this.canDefineScopedElement(e)&&this.registry.define(e,r)}canDefineScopedElement(e){return this.scopedRegistryConstructor.canDefineScopedElement(e)}defineScopedElements(e){this.scopedRegistryConstructor.defineScopedElements(e)}defineScopedElement(e,r){this.scopedRegistryConstructor.defineScopedElement(e,r)}};function Ln(t,e,...r){var n;let s=t.querySelector(e);for(let i of r)s=(n=s?.shadowRoot)===null||n===void 0?void 0:n.querySelector(i);return s}var we=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},Vn,Fn=Symbol("constructorPrototype"),Un=Symbol("constructorName"),qn=Symbol("exportpartsDebouncer"),Bn=Symbol("dynamicDependenciesLoaded"),Ce=class t extends CustomEvent{constructor(){super(t.eventName,{bubbles:!0})}};Ce.eventName="exportparts-updated";var Z=class extends st{constructor(){super(),this.useAdoptedStyleSheets=!0,this.adoptedCustomStyleSheet=new CSSStyleSheet,this[Vn]=new nt(5),this.scheduleExportpartsUpdate=()=>{var e,r,n;(!((e=this.exportpartsPrefix)===null||e===void 0)&&e.trim()||(n=(r=this.exportpartsPrefixes)===null||r===void 0?void 0:r.length)!==null&&n!==void 0&&n)&&this[qn].run(()=>{var s,i;!((s=this.exportpartsPrefix)===null||s===void 0)&&s.trim()?this.setExportpartsAttribute([this.exportpartsPrefix]):this.exportpartsPrefixes!=null&&((i=this.exportpartsPrefixes)===null||i===void 0?void 0:i.length)>0&&this.setExportpartsAttribute(this.exportpartsPrefixes)})},this[Un]=this.constructor.name,this[Fn]=this.constructor.prototype}adoptedCallback(){this.constructor.name!==this[Un]&&Object.setPrototypeOf(this,this[Fn])}connectedCallback(){var e;super.connectedCallback();try{this.shadowRoot&&!this.shadowRoot.adoptedStyleSheets.includes(this.adoptedCustomStyleSheet)&&(this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,this.adoptedCustomStyleSheet]),this.useAdoptedStyleSheets=!0}catch(n){this.useAdoptedStyleSheets=!1,console.error("Cannot use adopted stylesheets",n)}let r=this.constructor;r[Bn]||(r[Bn]=!0,this.importDynamicDependencies()),(e=this.shadowRoot)===null||e===void 0||e.addEventListener(Ce.eventName,this.scheduleExportpartsUpdate)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.shadowRoot)===null||e===void 0||e.removeEventListener(Ce.eventName,this.scheduleExportpartsUpdate)}importDynamicDependencies(){}updated(e){super.updated(e),this.updateComplete.then(()=>{this.contentAvailableCallback(e),this.focusElementToFocus(e),this.applyCustomStylesheet(e),this.scheduleExportpartsUpdate(),e.has("exportparts")&&this.dispatchEvent(new Ce)})}contentAvailableCallback(e){}focusElementToFocus(e){if(e.has("elementToFocus")&&this.elementToFocus!=null){let{element:r,selector:n,shadowPath:s}=this.elementToFocus;if(n!=null){let i=[...s??[],n];r=Ln(this.shadowRoot,...i)}r?.focus(),window.FluidTopicsA11yHints.isKeyboardNavigation||r?.blur(),this.elementToFocus=void 0}}applyCustomStylesheet(e){var r,n,s;if(((n=(r=this.shadowRoot)===null||r===void 0?void 0:r.querySelectorAll(".ft-lit-element--custom-stylesheet"))!==null&&n!==void 0?n:[]).forEach(i=>i.remove()),this.useAdoptedStyleSheets){if(e.has("customStylesheet"))try{this.adoptedCustomStyleSheet.replaceSync((s=this.customStylesheet)!==null&&s!==void 0?s:"")}catch(i){console.error(i,this.customStylesheet),this.useAdoptedStyleSheets=!1}}else if(this.customStylesheet){let i=document.createElement("style");i.classList.add("ft-lit-element--custom-stylesheet"),i.innerHTML=this.customStylesheet,this.shadowRoot.append(i)}}setExportpartsAttribute(e){var r,n,s,i,a,o;let c=p=>p!=null&&p.trim().length>0,l=e.filter(c).map(p=>p.trim());if(l.length===0){this.exportparts=void 0;return}let u=new Set;for(let p of(i=(r=this.shadowRoot)===null||r===void 0?void 0:r.querySelectorAll("[part],[exportparts]"))!==null&&i!==void 0?i:[]){let E=(a=(n=p.getAttribute("part"))===null||n===void 0?void 0:n.split(" "))!==null&&a!==void 0?a:[],S=(o=(s=p.getAttribute("exportparts"))===null||s===void 0?void 0:s.split(",").map(m=>m.split(":")[1]))!==null&&o!==void 0?o:[],_=[...E,...S].filter(c).map(m=>m.trim());for(let m of _)u.add(m)}if(u.size===0){this.exportparts=void 0;return}let h=[...u.values()].flatMap(p=>l.map(E=>`${p}:${E}--${p}`));this.exportparts=[...this.part,...h].join(", ")}};Vn=qn;we([(0,pe.property)()],Z.prototype,"exportpartsPrefix",void 0);we([Dn([])],Z.prototype,"exportpartsPrefixes",void 0);we([(0,pe.property)({reflect:!0})],Z.prototype,"exportparts",void 0);we([(0,pe.property)()],Z.prototype,"customStylesheet",void 0);we([(0,pe.property)()],Z.prototype,"elementToFocus",void 0);we([(0,pe.state)()],Z.prototype,"useAdoptedStyleSheets",void 0);function at(t){var e;return(e=t?.isFtReduxStore)!==null&&e!==void 0?e:!1}var Pe=Symbol("internalReduxEventsUnsubscribers"),le=Symbol("internalStoresUnsubscribers"),fe=Symbol("internalStores"),mi=tt(Symbol("withRedux"),function(t){var e,r,n;class s extends t{constructor(){super(...arguments),this[e]=new Map,this[r]=new Map,this[n]=new Map}get reduxConstructor(){return this.constructor}willUpdate(a){super.willUpdate(a),[...this.reduxConstructor.reduxReactiveProperties].some(o=>a.has(o))&&this.updateFromStores()}getUnnamedStore(){if(this[fe].size>1)throw new Error("Cannot resolve unnamed store when multiple stores are configured.");return[...this[fe].values()][0]}getStore(a){return a==null?this.getUnnamedStore():this[fe].get(a)}addStore(a,o){var c;o=(c=o??a.name)!==null&&c!==void 0?c:"default-store",this.unsubscribeFromStore(o),this[fe].set(o,a),this.subscribeToStore(o,a),this.updateFromStores()}removeStore(a){let o=typeof a=="string"?a:a.name;this.unsubscribeFromStore(o),this[fe].delete(o)}setupStores(){this.unsubscribeFromStores(),this[fe].forEach((a,o)=>this.subscribeToStore(o,a)),this.updateFromStores()}updateFromStores(){this.reduxConstructor.reduxProperties.forEach((a,o)=>{let c=this.constructor.getPropertyOptions(o);if(!c?.attribute||!this.hasAttribute(typeof c?.attribute=="string"?c.attribute:o)){let l=this.getStore(a.store);l&&(a.store?this[le].has(a.store):this[le].size>0)&&(this[o]=a.selector(l.getState(),this))}})}subscribeToStore(a,o){var c;this[le].set(a,o.subscribe(()=>this.updateFromStores())),this[Pe].set(a,[]),at(o)&&o.eventBus&&((c=this.reduxConstructor.reduxEventListeners)===null||c===void 0||c.forEach((l,u)=>{if(typeof this[u]=="function"&&(!l.store||o.name===l.store)){let h=p=>this[u](p);o.addEventListener(l.eventName,h),this[Pe].get(a).push(()=>o.removeEventListener(l.eventName,h))}})),this.onStoreAvailable(a)}unsubscribeFromStores(){this[le].forEach((a,o)=>this.unsubscribeFromStore(o))}unsubscribeFromStore(a){var o;this[le].has(a)&&this[le].get(a)(),this[le].delete(a),(o=this[Pe].get(a))===null||o===void 0||o.forEach(c=>c()),this[Pe].delete(a)}onStoreAvailable(a){}connectedCallback(){super.connectedCallback(),this.setupStores()}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribeFromStores()}}return e=le,r=fe,n=Pe,s.reduxProperties=new Map,s.reduxReactiveProperties=new Set,s.reduxEventListeners=new Map,s}),jn=class extends mi(Z){};function D(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var gi=typeof Symbol=="function"&&Symbol.observable||"@@observable",Hn=gi,ur=()=>Math.random().toString(36).substring(7).split("").join("."),yi={INIT:`@@redux/INIT${ur()}`,REPLACE:`@@redux/REPLACE${ur()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ur()}`},ot=yi;function ct(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function dr(t,e,r){if(typeof t!="function")throw new Error(D(2));if(typeof e=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(D(0));if(typeof e=="function"&&typeof r>"u"&&(r=e,e=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(D(1));return r(dr)(t,e)}let n=t,s=e,i=new Map,a=i,o=0,c=!1;function l(){a===i&&(a=new Map,i.forEach((m,x)=>{a.set(x,m)}))}function u(){if(c)throw new Error(D(3));return s}function h(m){if(typeof m!="function")throw new Error(D(4));if(c)throw new Error(D(5));let x=!0;l();let H=o++;return a.set(H,m),function(){if(x){if(c)throw new Error(D(6));x=!1,l(),a.delete(H),i=null}}}function p(m){if(!ct(m))throw new Error(D(7));if(typeof m.type>"u")throw new Error(D(8));if(typeof m.type!="string")throw new Error(D(17));if(c)throw new Error(D(9));try{c=!0,s=n(s,m)}finally{c=!1}return(i=a).forEach(H=>{H()}),m}function E(m){if(typeof m!="function")throw new Error(D(10));n=m,p({type:ot.REPLACE})}function S(){let m=h;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(D(11));function H(){let y=x;y.next&&y.next(u())}return H(),{unsubscribe:m(H)}},[Hn](){return this}}}return p({type:ot.INIT}),{dispatch:p,subscribe:h,getState:u,replaceReducer:E,[Hn]:S}}function vi(t){Object.keys(t).forEach(e=>{let r=t[e];if(typeof r(void 0,{type:ot.INIT})>"u")throw new Error(D(12));if(typeof r(void 0,{type:ot.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(D(13))})}function hr(t){let e=Object.keys(t),r={};for(let a=0;a<e.length;a++){let o=e[a];typeof t[o]=="function"&&(r[o]=t[o])}let n=Object.keys(r),s,i;try{vi(r)}catch(a){i=a}return function(o={},c){if(i)throw i;let l=!1,u={};for(let h=0;h<n.length;h++){let p=n[h],E=r[p],S=o[p],_=E(S,c);if(typeof _>"u"){let m=c&&c.type;throw new Error(D(14))}u[p]=_,l=l||_!==S}return l=l||n.length!==Object.keys(o).length,l?u:o}}function Le(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,r)=>(...n)=>e(r(...n)))}function $n(...t){return e=>(r,n)=>{let s=e(r,n),i=()=>{throw new Error(D(15))},a={getState:s.getState,dispatch:(c,...l)=>i(c,...l)},o=t.map(c=>c(a));return i=Le(...o)(s.dispatch),{...s,dispatch:i}}}function Kn(t){return ct(t)&&"type"in t&&typeof t.type=="string"}var es=Symbol.for("immer-nothing"),zn=Symbol.for("immer-draftable"),F=Symbol.for("immer-state");function X(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var $=Object,Re=$.getPrototypeOf,ht="constructor",vt="prototype",gr="configurable",pt="enumerable",ut="writable",Fe="value",ee=t=>!!t&&!!t[F];function K(t){return t?ts(t)||St(t)||!!t[zn]||!!t[ht]?.[zn]||At(t)||Tt(t):!1}var Ei=$[vt][ht].toString(),Gn=new WeakMap;function ts(t){if(!t||!_r(t))return!1;let e=Re(t);if(e===null||e===$[vt])return!0;let r=$.hasOwnProperty.call(e,ht)&&e[ht];if(r===Object)return!0;if(!xe(r))return!1;let n=Gn.get(r);return n===void 0&&(n=Function.toString.call(r),Gn.set(r,n)),n===Ei}function Et(t,e,r=!0){Ve(t)===0?(r?Reflect.ownKeys(t):$.keys(t)).forEach(s=>{e(s,t[s],t)}):t.forEach((n,s)=>e(s,n,t))}function Ve(t){let e=t[F];return e?e.type_:St(t)?1:At(t)?2:Tt(t)?3:0}var pr=(t,e,r=Ve(t))=>r===2?t.has(e):$[vt].hasOwnProperty.call(t,e),yr=(t,e,r=Ve(t))=>r===2?t.get(e):t[e],ft=(t,e,r,n=Ve(t))=>{n===2?t.set(e,r):n===3?t.add(r):t[e]=r};function Si(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var St=Array.isArray,At=t=>t instanceof Map,Tt=t=>t instanceof Set,_r=t=>typeof t=="object",xe=t=>typeof t=="function",fr=t=>typeof t=="boolean";function Ai(t){let e=+t;return Number.isInteger(e)&&String(e)===t}var se=t=>t.copy_||t.base_;var Cr=t=>t.modified_?t.copy_:t.base_;function vr(t,e){if(At(t))return new Map(t);if(Tt(t))return new Set(t);if(St(t))return Array[vt].slice.call(t);let r=ts(t);if(e===!0||e==="class_only"&&!r){let n=$.getOwnPropertyDescriptors(t);delete n[F];let s=Reflect.ownKeys(n);for(let i=0;i<s.length;i++){let a=s[i],o=n[a];o[ut]===!1&&(o[ut]=!0,o[gr]=!0),(o.get||o.set)&&(n[a]={[gr]:!0,[ut]:!0,[pt]:o[pt],[Fe]:t[a]})}return $.create(Re(t),n)}else{let n=Re(t);if(n!==null&&r)return{...t};let s=$.create(n);return $.assign(s,t)}}function bt(t,e=!1){return _t(t)||ee(t)||!K(t)||(Ve(t)>1&&$.defineProperties(t,{set:lt,add:lt,clear:lt,delete:lt}),$.freeze(t),e&&Et(t,(r,n)=>{bt(n,!0)},!1)),t}function Ti(){X(2)}var lt={[Fe]:Ti};function _t(t){return t===null||!_r(t)?!0:$.isFrozen(t)}var mt="MapSet",Er="Patches",Wn="ArrayMethods",rs={};function me(t){let e=rs[t];return e||X(0,t),e}var Qn=t=>!!rs[t];var Ue,ns=()=>Ue,bi=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Qn(mt)?me(mt):void 0,arrayMethodsPlugin_:Qn(Wn)?me(Wn):void 0});function Yn(t,e){e&&(t.patchPlugin_=me(Er),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Sr(t){Ar(t),t.drafts_.forEach(_i),t.drafts_=null}function Ar(t){t===Ue&&(Ue=t.parent_)}var Xn=t=>Ue=bi(Ue,t);function _i(t){let e=t[F];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Jn(t,e){e.unfinalizedDrafts_=e.drafts_.length;let r=e.drafts_[0];if(t!==void 0&&t!==r){r[F].modified_&&(Sr(e),X(4)),K(t)&&(t=Zn(e,t));let{patchPlugin_:s}=e;s&&s.generateReplacementPatches_(r[F].base_,t,e)}else t=Zn(e,r);return Ci(e,t,!0),Sr(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==es?t:void 0}function Zn(t,e){if(_t(e))return e;let r=e[F];if(!r)return gt(e,t.handledSet_,t);if(!Ct(r,t))return e;if(!r.modified_)return r.base_;if(!r.finalized_){let{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(t);as(r,t)}return r.copy_}function Ci(t,e,r=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&bt(e,r)}function ss(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Ct=(t,e)=>t.scope_===e,wi=[];function is(t,e,r,n){let s=se(t),i=t.type_;if(n!==void 0&&yr(s,n,i)===e){ft(s,n,r,i);return}if(!t.draftLocations_){let o=t.draftLocations_=new Map;Et(s,(c,l)=>{if(ee(l)){let u=o.get(l)||[];u.push(c),o.set(l,u)}})}let a=t.draftLocations_.get(e)??wi;for(let o of a)ft(s,o,r,i)}function xi(t,e,r){t.callbacks_.push(function(s){let i=e;if(!i||!Ct(i,s))return;s.mapSetPlugin_?.fixSetContents(i);let a=Cr(i);is(t,i.draft_??i,a,r),as(i,s)})}function as(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(t.assigned_?.size??0)>0)){let{patchPlugin_:n}=e;if(n){let s=n.getPath(t);s&&n.generatePatches_(t,s,e)}ss(t)}}function Ri(t,e,r){let{scope_:n}=t;if(ee(r)){let s=r[F];Ct(s,n)&&s.callbacks_.push(function(){dt(t);let a=Cr(s);is(t,r,a,e)})}else K(r)&&t.callbacks_.push(function(){let i=se(t);t.type_===3?i.has(r)&&gt(r,n.handledSet_,n):yr(i,e,t.type_)===r&&n.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&gt(yr(t.copy_,e,t.type_),n.handledSet_,n)})}function gt(t,e,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||ee(t)||e.has(t)||!K(t)||_t(t)||(e.add(t),Et(t,(n,s)=>{if(ee(s)){let i=s[F];if(Ct(i,r)){let a=Cr(i);ft(t,n,a,t.type_),ss(i)}}else K(s)&&gt(s,e,r)})),t}function Ii(t,e){let r=St(t),n={type_:r?1:0,scope_:e?e.scope_:ns(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},s=n,i=yt;r&&(s=[n],i=Be);let{revoke:a,proxy:o}=Proxy.revocable(s,i);return n.draft_=o,n.revoke_=a,[o,n]}var yt={get(t,e){if(e===F)return t;let r=t.scope_.arrayMethodsPlugin_,n=t.type_===1&&typeof e=="string";if(n&&r?.isArrayOperationMethod(e))return r.createMethodInterceptor(t,e);let s=se(t);if(!pr(s,e,t.type_))return Mi(t,s,e);let i=s[e];if(t.finalized_||!K(i)||n&&t.operationMethod&&r?.isMutatingArrayMethod(t.operationMethod)&&Ai(e))return i;if(i===mr(t.base_,e)||Oi(t,e,i)){dt(t);let a=t.type_===1?+e:e,o=br(t.scope_,i,t,a);return t.copy_[a]=o}return i},has(t,e){return e in se(t)},ownKeys(t){return Reflect.ownKeys(se(t))},set(t,e,r){let n=os(se(t),e);if(n?.set)return n.set.call(t.draft_,r),!0;if(!t.modified_){let s=mr(se(t),e),i=s?.[F];if(i&&i.base_===r)return t.copy_[e]=r,t.assigned_.delete(e),!0;if(Si(r,s)&&(r!==void 0||pr(t.base_,e,t.type_)))return!0;dt(t),Tr(t)}return t.copy_[e]===r&&(r!==void 0||pr(t.copy_,e,t.type_))||Number.isNaN(r)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=r,t.assigned_.set(e,!0),Ri(t,e,r)),!0},deleteProperty(t,e){return dt(t),mr(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),Tr(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){let r=se(t),n=Reflect.getOwnPropertyDescriptor(r,e);return n&&{[ut]:!0,[gr]:t.type_!==1||e!=="length",[pt]:n[pt],[Fe]:r[e]}},defineProperty(){X(11)},getPrototypeOf(t){return Re(t.base_)},setPrototypeOf(){X(12)}},Be={};for(let t in yt){let e=yt[t];Be[t]=function(){let r=arguments;return r[0]=r[0][0],e.apply(this,r)}}Be.deleteProperty=function(t,e){return Be.set.call(this,t,e,void 0)};Be.set=function(t,e,r){return yt.set.call(this,t[0],e,r,t[0])};function mr(t,e){let r=t[F];return(r?se(r):t)[e]}function Oi(t,e,r){return t.type_!==1||!t.allIndicesReassigned_||t.assigned_?.get(e)||!K(r)||r[F]?!1:t.baseRefs_.has(r)}function Mi(t,e,r){let n=os(e,r);return n?Fe in n?n[Fe]:n.get?.call(t.draft_):void 0}function os(t,e){if(!(e in t))return;let r=Re(t);for(;r;){let n=Object.getOwnPropertyDescriptor(r,e);if(n)return n;r=Re(r)}}function Tr(t){t.modified_||(t.modified_=!0,t.parent_&&Tr(t.parent_))}function dt(t){t.copy_||(t.assigned_=new Map,t.copy_=vr(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var ki=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,r,n)=>{if(xe(e)&&!xe(r)){let i=r;r=e;let a=this;return function(c=i,...l){return a.produce(c,u=>r.call(this,u,...l))}}xe(r)||X(6),n!==void 0&&!xe(n)&&X(7);let s;if(K(e)){let i=Xn(this),a=br(i,e,void 0),o=!0;try{s=r(a),o=!1}finally{o?Sr(i):Ar(i)}return Yn(i,n),Jn(s,i)}else if(!e||!_r(e)){if(s=r(e),s===void 0&&(s=e),s===es&&(s=void 0),this.autoFreeze_&&bt(s,!0),n){let i=[],a=[];me(Er).generateReplacementPatches_(e,s,{patches_:i,inversePatches_:a}),n(i,a)}return s}else X(1,e)},this.produceWithPatches=(e,r)=>{if(xe(e))return(a,...o)=>this.produceWithPatches(a,c=>e(c,...o));let n,s;return[this.produce(e,r,(a,o)=>{n=a,s=o}),n,s]},fr(t?.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),fr(t?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),fr(t?.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){K(t)||X(8),ee(t)&&(t=cs(t));let e=Xn(this),r=br(e,t,void 0);return r[F].isManual_=!0,Ar(e),r}finishDraft(t,e){let r=t&&t[F];(!r||!r.isManual_)&&X(9);let{scope_:n}=r;return Yn(n,e),Jn(void 0,n)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let r;for(r=e.length-1;r>=0;r--){let s=e[r];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}r>-1&&(e=e.slice(r+1));let n=me(Er).applyPatches_;return ee(t)?n(t,e):this.produce(t,s=>n(s,e))}};function br(t,e,r,n){let[s,i]=At(e)?me(mt).proxyMap_(e,r):Tt(e)?me(mt).proxySet_(e,r):Ii(e,r);return(r?.scope_??ns()).drafts_.push(s),i.callbacks_=r?.callbacks_??[],i.key_=n,r&&n!==void 0?xi(r,i,n):i.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(i);let{patchPlugin_:l}=c;i.modified_&&l&&l.generatePatches_(i,[],c)}),s}function cs(t){return ee(t)||X(10,t),ls(t)}function ls(t){if(!K(t)||_t(t))return t;let e=t[F],r,n=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,r=vr(t,e.scope_.immer_.useStrictShallowCopy_),n=e.scope_.immer_.shouldUseStrictIteration()}else r=vr(t,!0);return Et(r,(s,i)=>{ft(r,s,ls(i))},n),e&&(e.finalized_=!1),r}var Ni=globalThis.Iterator,yo=typeof Ni?.from=="function";var Di=new ki,wr=Di.produce;function us(t){return({dispatch:r,getState:n})=>s=>i=>typeof i=="function"?i(r,n,t):s(i)}var ds=us(),hs=us;var Pi=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Le:Le.apply(null,arguments)};typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;var Li=t=>t&&typeof t.match=="function";function ue(t,e){function r(...n){if(e){let s=e(...n);if(!s)throw new Error(te(0));return{type:t,payload:s.payload,..."meta"in s&&{meta:s.meta},..."error"in s&&{error:s.error}}}return{type:t,payload:n[0]}}return r.toString=()=>`${t}`,r.type=t,r.match=n=>Kn(n)&&n.type===t,r}var ys=class qe extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,qe.prototype)}static get[Symbol.species](){return qe}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new qe(...e[0].concat(this)):new qe(...e.concat(this))}};function ps(t){return K(t)?wr(t,()=>{}):t}function wt(t,e,r){return t.has(e)?t.get(e):t.set(e,r(e)).get(e)}function Fi(t){return typeof t=="boolean"}var Ui=()=>function(e){let{thunk:r=!0,immutableCheck:n=!0,serializableCheck:s=!0,actionCreatorCheck:i=!0}=e??{},a=new ys;return r&&(Fi(r)?a.push(ds):a.push(hs(r.extraArgument))),a},Bi="RTK_autoBatch";var fs=t=>e=>{setTimeout(e,t)},Vi=(t,e)=>r=>{let n=!1,s,i,a=()=>{n||(n=!0,cancelAnimationFrame(s),clearTimeout(i),r())};s=t(a),i=setTimeout(a,e)},qi=(t={type:"raf"})=>e=>(...r)=>{let n=e(...r),s=!0,i=!1,a=!1,o=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?Vi(window.requestAnimationFrame,100):fs(10):t.type==="callback"?t.queueNotification:fs(t.timeout),l=()=>{a=!1,i&&(i=!1,o.forEach(u=>u()))};return Object.assign({},n,{subscribe(u){let h=()=>s&&u(),p=n.subscribe(h);return o.add(u),()=>{p(),o.delete(u)}},dispatch(u){try{return s=!u?.meta?.[Bi],i=!s,i&&(a||(a=!0,c(l))),n.dispatch(u)}finally{s=!0}}})},ji=t=>function(r){let{autoBatch:n=!0}=r??{},s=new ys(t);return n&&s.push(qi(typeof n=="object"?n:void 0)),s};function vs(t){let e=Ui(),{reducer:r=void 0,middleware:n,devTools:s=!0,duplicateMiddlewareCheck:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{},c;if(typeof r=="function")c=r;else if(ct(r))c=hr(r);else throw new Error(te(1));let l;typeof n=="function"?l=n(e):l=e();let u=Le;s&&(u=Pi({trace:!1,...typeof s=="object"&&s}));let h=$n(...l),p=ji(h),E=typeof o=="function"?o(p):p(),S=u(...E);return dr(c,a,S)}function Es(t){let e={},r=[],n,s={addCase(i,a){let o=typeof i=="string"?i:i.type;if(!o)throw new Error(te(28));if(o in e)throw new Error(te(29));return e[o]=a,s},addAsyncThunk(i,a){return a.pending&&(e[i.pending.type]=a.pending),a.rejected&&(e[i.rejected.type]=a.rejected),a.fulfilled&&(e[i.fulfilled.type]=a.fulfilled),a.settled&&r.push({matcher:i.settled,reducer:a.settled}),s},addMatcher(i,a){return r.push({matcher:i,reducer:a}),s},addDefaultCase(i){return n=i,s}};return t(s),[e,r,n]}function Hi(t){return typeof t=="function"}function $i(t,e){let[r,n,s]=Es(e),i;if(Hi(t))i=()=>ps(t());else{let o=ps(t);i=()=>o}function a(o=i(),c){let l=[r[c.type],...n.filter(({matcher:u})=>u(c)).map(({reducer:u})=>u)];return l.filter(u=>!!u).length===0&&(l=[s]),l.reduce((u,h)=>{if(h)if(ee(u)){let p=h(u,c);return p===void 0?u:p}else{if(K(u))return wr(u,p=>h(p,c));{let p=h(u,c);if(p===void 0){if(u===null)return u;throw new Error(te(9))}return p}}return u},o)}return a.getInitialState=i,a}var Ki=(t,e)=>Li(t)?t.match(e):t(e);function zi(...t){return e=>t.some(r=>Ki(r,e))}var Gi="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Wi=(t=21)=>{let e="",r=t;for(;r--;)e+=Gi[Math.random()*64|0];return e},Qi=["name","message","stack","code"],xr=class{payload;meta;_type;constructor(t,e){this.payload=t,this.meta=e}},ms=class{payload;meta;_type;constructor(t,e){this.payload=t,this.meta=e}},Yi=t=>{if(typeof t=="object"&&t!==null){let e={};for(let r of Qi)typeof t[r]=="string"&&(e[r]=t[r]);return e}return{message:String(t)}},gs="External signal was aborted",Xi=(()=>{function t(e,r,n){let s=ue(e+"/fulfilled",(c,l,u,h)=>({payload:c,meta:{...h||{},arg:u,requestId:l,requestStatus:"fulfilled"}})),i=ue(e+"/pending",(c,l,u)=>({payload:void 0,meta:{...u||{},arg:l,requestId:c,requestStatus:"pending"}})),a=ue(e+"/rejected",(c,l,u,h,p)=>({payload:h,error:(n&&n.serializeError||Yi)(c||"Rejected"),meta:{...p||{},arg:u,requestId:l,rejectedWithValue:h!==void 0,requestStatus:"rejected",aborted:c?.name==="AbortError",condition:c?.name==="ConditionError"}}));function o(c,{signal:l}={}){return(u,h,p)=>{let E=n?.idGenerator?n.idGenerator(c):Wi(),S=new AbortController,_,m;function x(g){m=g,S.abort()}l&&(l.aborted?x(gs):l.addEventListener("abort",()=>x(gs),{once:!0}));let H=(async function(){let g;try{let y=n?.condition?.(c,{getState:h,extra:p});if(Zi(y)&&(y=await y),y===!1)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};if(S.signal.aborted)throw{name:"AbortError",message:m||"Aborted"};let N=new Promise((O,L)=>{_=()=>{L({name:"AbortError",message:m||"Aborted"})},S.signal.addEventListener("abort",_,{once:!0})});u(i(E,c,n?.getPendingMeta?.({requestId:E,arg:c},{getState:h,extra:p}))),g=await Promise.race([N,Promise.resolve(r(c,{dispatch:u,getState:h,extra:p,requestId:E,signal:S.signal,abort:x,rejectWithValue:((O,L)=>new xr(O,L)),fulfillWithValue:((O,L)=>new ms(O,L))})).then(O=>{if(O instanceof xr)throw O;return O instanceof ms?s(O.payload,E,c,O.meta):s(O,E,c)})])}catch(y){g=y instanceof xr?a(null,E,c,y.payload,y.meta):a(y,E,c)}finally{_&&S.signal.removeEventListener("abort",_)}return n&&!n.dispatchConditionRejection&&a.match(g)&&g.meta.condition||u(g),g})();return Object.assign(H,{abort:x,requestId:E,arg:c,unwrap(){return H.then(Ji)}})}}return Object.assign(o,{pending:i,rejected:a,fulfilled:s,settled:zi(a,s),typePrefix:e})}return t.withTypes=()=>t,t})();function Ji(t){if(t.meta&&t.meta.rejectedWithValue)throw t.payload;if(t.error)throw t.error;return t.payload}function Zi(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}var Ss=Symbol.for("rtk-slice-createasyncthunk"),Co={[Ss]:Xi};function ea(t,e){return`${t}/${e}`}function ta({creators:t}={}){let e=t?.asyncThunk?.[Ss];return function(n){let{name:s,reducerPath:i=s}=n;if(!s)throw new Error(te(11));typeof process<"u";let a=(typeof n.reducers=="function"?n.reducers(na()):n.reducers)||{},o=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},l={addCase(g,y){let N=typeof g=="string"?g:g.type;if(!N)throw new Error(te(12));if(N in c.sliceCaseReducersByType)throw new Error(te(13));return c.sliceCaseReducersByType[N]=y,l},addMatcher(g,y){return c.sliceMatchers.push({matcher:g,reducer:y}),l},exposeAction(g,y){return c.actionCreators[g]=y,l},exposeCaseReducer(g,y){return c.sliceCaseReducersByName[g]=y,l}};o.forEach(g=>{let y=a[g],N={reducerName:g,type:ea(s,g),createNotation:typeof n.reducers=="function"};ia(y)?oa(N,y,l,e):sa(N,y,l)});function u(){let[g={},y=[],N=void 0]=typeof n.extraReducers=="function"?Es(n.extraReducers):[n.extraReducers],O={...g,...c.sliceCaseReducersByType};return $i(n.initialState,L=>{for(let B in O)L.addCase(B,O[B]);for(let B of c.sliceMatchers)L.addMatcher(B.matcher,B.reducer);for(let B of y)L.addMatcher(B.matcher,B.reducer);N&&L.addDefaultCase(N)})}let h=g=>g,p=new Map,E=new WeakMap,S;function _(g,y){return S||(S=u()),S(g,y)}function m(){return S||(S=u()),S.getInitialState()}function x(g,y=!1){function N(L){let B=L[g];return typeof B>"u"&&y&&(B=wt(E,N,m)),B}function O(L=h){return wt(wt(p,y,()=>new WeakMap),L,()=>{let B={};for(let[ni,si]of Object.entries(n.selectors??{}))B[ni]=ra(si,L,()=>wt(E,L,m),y);return B})}return{reducerPath:g,getSelectors:O,get selectors(){return O(N)},selectSlice:N}}let H={name:s,reducer:_,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:m,...x(i),injectInto(g,{reducerPath:y,...N}={}){let O=y??i;return g.inject({reducerPath:O,reducer:_},N),{...H,...x(O,!0)}}};return H}}function ra(t,e,r,n){function s(i,...a){let o=e(i);return typeof o>"u"&&n&&(o=r()),t(o,...a)}return s.unwrapped=t,s}var As=ta();function na(){function t(e,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...r}}return t.withTypes=()=>t,{reducer(e){return Object.assign({[e.name](...r){return e(...r)}}[e.name],{_reducerDefinitionType:"reducer"})},preparedReducer(e,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:r}},asyncThunk:t}}function sa({type:t,reducerName:e,createNotation:r},n,s){let i,a;if("reducer"in n){if(r&&!aa(n))throw new Error(te(17));i=n.reducer,a=n.prepare}else i=n;s.addCase(t,i).exposeCaseReducer(e,i).exposeAction(e,a?ue(t,a):ue(t))}function ia(t){return t._reducerDefinitionType==="asyncThunk"}function aa(t){return t._reducerDefinitionType==="reducerWithPrepare"}function oa({type:t,reducerName:e},r,n,s){if(!s)throw new Error(te(18));let{payloadCreator:i,fulfilled:a,pending:o,rejected:c,settled:l,options:u}=r,h=s(t,i,u);n.exposeAction(e,h),a&&n.addCase(h.fulfilled,a),o&&n.addCase(h.pending,o),c&&n.addCase(h.rejected,c),l&&n.addMatcher(h.settled,l),n.exposeCaseReducer(e,{fulfilled:a||xt,pending:o||xt,rejected:c||xt,settled:l||xt})}function xt(){}var Ts="listener",bs="completed",_s="cancelled",wo=`task-${_s}`,xo=`task-${bs}`,Ro=`${Ts}-${_s}`,Io=`${Ts}-${bs}`;var{assign:Cs}=Object;var Rr="listenerMiddleware";var ca=Cs(ue(`${Rr}/add`),{withTypes:()=>ca}),Oo=ue(`${Rr}/removeAll`),la=Cs(ue(`${Rr}/remove`),{withTypes:()=>la});function te(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var ua=tt(Symbol("withEventBus"),function(t,e){return class extends t{constructor(){super(...arguments),this.eventBus=e??document.createElement("span")}addEventListener(r,n,s){this.eventBus.addEventListener(r,n,s)}dispatchEvent(r){return this.eventBus.dispatchEvent(r)}removeEventListener(r,n,s){this.eventBus.removeEventListener(r,n,s)}}}),Rt=class extends ua(Object){};window.ftReduxStores||(window.ftReduxStores={});var ws=class t extends Rt{static get(e){var r;let n=typeof e=="string"?e:e.name,s=typeof e=="string"?void 0:e,i=window.ftReduxStores[n];if(at(i))return i;if(s==null)return;let a=As({...s,reducers:(r=s.reducers)!==null&&r!==void 0?r:{}}),o=vs({reducer:(c,l)=>{if(l.type==="CLEAR_FT_REDUX_STORE"){let u=Ne(a.getInitialState());for(let h of l.keeping)u[h]=(c??u)[h];return u}else if(typeof l.type=="string"&&l.type.startsWith("DEFAULT_VALUE_SETTER__"))return{...c,...l.overwrites};return a.reducer(c,l)}});return window.ftReduxStores[s.name]=new t(a,o,s.eventBus)}constructor(e,r,n){super(),this.reduxSlice=e,this.reduxStore=r,this.isFtReduxStore=!0,this.commands=new rt,this.injectInto=(i,a)=>this.reduxSlice.injectInto(i,a),this.selectSlice=i=>this.reduxSlice.selectSlice(i);let s=i=>i!=null?JSON.parse(JSON.stringify(i)):i;this.actions=new Proxy(this.reduxSlice.actions,{get:(i,a,o)=>{let c=a,l=i[c];return l?(...u)=>{let h=l(...u.map(s));return this.reduxStore.dispatch(h),h}:u=>{let h=c,p=this.getState()[h];_e(p,u)||this.setState({[h]:s(u)})}}}),this.eventBus=n??this.eventBus}clear(){this.reduxStore.dispatch({type:"CLEAR_FT_REDUX_STORE",keeping:[]})}clearKeeping(...e){this.reduxStore.dispatch({type:"CLEAR_FT_REDUX_STORE",keeping:e})}setState(e){this.reduxStore.dispatch({type:"DEFAULT_VALUE_SETTER__"+Object.keys(e).join("_"),overwrites:e})}get dispatch(){throw new Error("Don't use this method, actions are automatically dispatched when called.")}[Symbol.observable](){return this.reduxStore[Symbol.observable]()}getState(){return this.reduxStore.getState()}replaceReducer(e){throw new Error("Not implemented yet.")}subscribe(e){return this.reduxStore.subscribe(e)}get name(){return this.reduxSlice.name}get reducer(){return this.reduxSlice.reducer}get caseReducers(){return this.reduxSlice.caseReducers}getInitialState(){return this.reduxSlice.getInitialState()}get selectors(){return this.reduxSlice.selectors}get reducerPath(){return this.reduxSlice.reducerPath}getSelectors(){return this.reduxSlice.getSelectors()}};var It=class{static format(e,r,n,s,i){return window.moment?window.moment(e).locale(r).format(this.getMomentDateFormat(n,s,!!i)):this.getIntlDateTime(e,r,n,s,!!i)}static getMomentDateFormat(e,r,n){return n?"LT":e?r?"lll":"ll":r?"L LT":"L"}static getIntlDateTime(e,r,n,s,i){let a=typeof e=="string"?new Date(e):e,o=new Intl.DateTimeFormat(r,{dateStyle:n?"medium":"short"}).format(a),c=new Intl.DateTimeFormat(r,{timeStyle:"short"}).format(a);return i?c:s?`${o} ${c}`:o}static getTimezoneAsString(){let e=n=>String(Math.floor(n)).padStart(2,"0"),r=new Date().getTimezoneOffset();return`${r<0?"+":"-"}${e(Math.abs(r)/60)}:${e(Math.abs(r)%60)}`}};var Ot=f(T()),da="ft-app-info",z=class t extends CustomEvent{constructor(e){super(t.eventName,{detail:e})}};z.eventName="authentication-change";var je=class t extends CustomEvent{constructor(e){super(t.eventName,{detail:e})}};je.eventName="ui-locale-changed";var ha={session:(t,e)=>{(0,Ot.deepEqual)(t.session,e.payload)||(t.session=e.payload,setTimeout(()=>d.dispatchEvent(new z(e.payload)),0))}},d=Ot.FtReduxStore.get({name:da,reducers:ha,initialState:{baseUrl:void 0,tenantId:void 0,apiIntegrationIdentifier:void 0,apiIntegrationAppVersion:void 0,uiLocale:document.documentElement.lang||"en-US",availableContentLocales:[],localesConfiguration:void 0,metadataConfiguration:void 0,privacyPolicyConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,noCustomCode:!1,session:void 0,openExternalDocumentInNewTab:!1,navigatorOnline:!0,forcedOffline:!1,authenticationRequired:!1,stickyFilters:void 0}});var xs=f(T()),Mt=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},ac=(0,xs.applyMixinOnce)(Symbol("withDateFormat"),function(t){class e extends t{constructor(...n){super(n),this.useLongDateFormat=!1,this.useDateTimeFormat=!1,this.metadataDescriptors=[],this.uiLocale="en-US",this.addStore(d)}dateFormatOptionsChanged(n){return n.has("metadataDescriptors")||n.has("useLongDateFormat")||n.has("useDateTimeFormat")||n.has("uiLocale")}getDateFormatter(n){var s,i;return((i=(s=this.metadataDescriptors.find(o=>o.key===n))===null||s===void 0?void 0:s.date)!==null&&i!==void 0?i:!1)?o=>It.format(o,this.uiLocale,this.useLongDateFormat,this.useDateTimeFormat):void 0}}return Mt([(0,Ir.property)({type:Boolean})],e.prototype,"useLongDateFormat",void 0),Mt([(0,Ir.property)({type:Boolean})],e.prototype,"useDateTimeFormat",void 0),Mt([lr({store:d.name,selector:r=>{var n,s;return(s=(n=r.metadataConfiguration)===null||n===void 0?void 0:n.descriptors)!==null&&s!==void 0?s:[]}})],e.prototype,"metadataDescriptors",void 0),Mt([lr({store:d.name})],e.prototype,"uiLocale",void 0),e});var Lt=f(T());var Or=f(T());var ge=class t{static get(e){let{baseUrl:r,apiIntegrationIdentifier:n}=d.getState(),s=e??n;if(r&&s&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(r,s,!0)}static await(e){return new Promise(r=>{let n=t.get(e);if(n)r(n);else{let s=d.subscribe(()=>{n=t.get(e),n&&(s(),r(n))})}})}};var Ie=class{constructor(e){this.overrideApi=e}get api(){var e;return(e=this.overrideApi)!==null&&e!==void 0?e:ge.get()}get awaitApi(){return this.overrideApi?Promise.resolve(this.overrideApi):ge.await()}};var M=class extends Ie{constructor(e=!0,r){var n;super(r),this.sortObjectFields=(i,a)=>typeof a!="object"||a==null||Array.isArray(a)?a:Object.fromEntries(Object.entries(a).sort(([o],[c])=>o.localeCompare(c)));let s=this.constructor;s.commonCache=(n=s.commonCache)!==null&&n!==void 0?n:new Or.CacheRegistry,this.cache=e?s.commonCache:new Or.CacheRegistry}clearCache(){this.cache.clearAll()}hash(e){return String(Array.from(JSON.stringify(e,this.sortObjectFields)).reduce((r,n)=>0|31*r+n.charCodeAt(0),0))}};var kt=class extends M{async listMySearches(){let{session:e}=d.getState();return W(e,A.SAVED_SEARCH_USER)?this.cache.get("my-searches",async()=>(await this.awaitApi).listMySearches(e.profile.userId),300*1e3):[]}};var Nt=class extends M{async listMyBookmarks(){let e=d.getState().session;return e?.sessionAuthenticated?this.cache.get("my-bookmarks",async()=>(await this.awaitApi).listMyBookmarks(e.profile.userId),300*1e3):[]}};var Dt=class extends M{constructor(){super(...arguments),this.CACHE_DURATION=180*1e3}async getUserAssetCount(e){if(this.isAuthenticated())return this.cache.get(`user-asset-count-${e}`,async()=>(await this.awaitApi).get(`/internal/api/webapp/user/assets/count/${e}`),this.CACHE_DURATION)}async getUserBookmarkCountByMap(e){if(this.isAuthenticated())return this.cache.get(`user-bookmark-count-by-map-${e}`,async()=>(await this.awaitApi).get(`/internal/api/webapp/user/assets/count/BOOKMARKS/${e}`),this.CACHE_DURATION)}isAuthenticated(){let e=d.getState().session;return!!e?.sessionAuthenticated}};var Pt=class extends M{constructor(){super(...arguments),this.CACHE_DURATION=180*1e3}async getUserAssetLabels(){return this.isAuthenticated()?this.cache.get("user-asset-labels",async()=>(await this.awaitApi).get("/internal/api/webapp/user/assets/labels"),this.CACHE_DURATION):[]}isAuthenticated(){let e=d.getState().session;return!!e?.sessionAuthenticated}};var pa="ft-user-assets",fa={setAssetCount:(t,e)=>{let{userAssetType:r,count:n}=e.payload.assetCount;t.assetCounts.allAsset[r]=n},clearAssetCount:t=>{Object.values(G).forEach(e=>{t.assetCounts.allAsset[e]=void 0})},setBookmarkCountByMap:(t,e)=>{let r=e.payload.mapId;t.assetCounts.bookmarkByMap[r]=e.payload.count},clearBookmarkCountByMap:t=>{t.assetCounts.bookmarkByMap={}},addAsset:(t,e)=>{let{assetType:r,mapId:n,asset:s}=e.payload;kr(t,r,[...Mr(t,r),s]),Rs(t,r,1,n),Is(t,s)},editAsset:(t,e)=>{let{assetType:r,asset:n}=e.payload;kr(t,r,Mr(t,r).map(s=>s.id===n.id?n:s)),Is(t,n)},removeAsset:(t,e)=>{let{assetType:r,mapId:n,assetId:s}=e.payload;kr(t,r,Mr(t,r).filter(i=>i.id!==s)),Rs(t,r,-1,n)}},Os={[G.SEARCHES]:"savedSearches",[G.BOOKMARKS]:"bookmarks",[G.BOOKS]:void 0,[G.COLLECTIONS]:void 0},Mr=(t,e)=>{var r;let n=Os[e];return n?(r=t[n])!==null&&r!==void 0?r:[]:[]},kr=(t,e,r)=>{let n=Os[e];n&&(t[n]=r)},Rs=(t,e,r,n)=>{let s=t.assetCounts.allAsset[e];if(s!==void 0&&(t.assetCounts.allAsset[e]=Math.max(0,s+r),e===G.BOOKMARKS&&n)){let i=t.assetCounts.bookmarkByMap[n];t.assetCounts.bookmarkByMap[n]=Math.max(0,i+r)}},Is=(t,e)=>{let r=t.assetLabels.map(s=>s.title),n=e.labels.filter(s=>!r.includes(s)).map(s=>({title:s}));t.assetLabels.push(...n)},V=Lt.FtReduxStore.get({name:pa,reducers:fa,initialState:{savedSearches:void 0,bookmarks:void 0,assetCounts:{allAsset:Object.fromEntries(Object.values(G).map(t=>[t,void 0])),bookmarkByMap:{}},assetLabels:[]}}),Nr=class{constructor(e=new Dt,r=new Pt){this.assetCountsService=e,this.assetLabelsService=r,this.currentSession=d.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new Nt,this.savedSearchesService=new kt,d.subscribe(()=>this.reloadWhenUserSessionChanges())}reloadWhenUserSessionChanges(){var e;let{session:r}=d.getState();(0,Lt.deepEqual)((e=this.currentSession)===null||e===void 0?void 0:e.profile,r?.profile)||(this.currentSession=r,this.clearMySearches(),this.reloadBookmarks(),this.clearUserAssetCounts(),this.reloadAssetLabels())}clearUserAssetCounts(){this.assetCountsService.clearCache(),V.actions.clearAssetCount(),V.actions.clearBookmarkCountByMap()}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),V.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),V.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();let e=await this.savedSearchesService.listMySearches();V.actions.savedSearches(e)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async reloadAssetLabels(){this.assetLabelsService.clearCache();let e=await this.assetLabelsService.getUserAssetLabels();V.actions.assetLabels(e)}async loadAssetCount(e){let r=await this.assetCountsService.getUserAssetCount(e);r&&V.getState().assetCounts.allAsset[e]!==r.count&&V.actions.setAssetCount({assetCount:r})}async loadBookmarkByMapId(e){let r=await this.assetCountsService.getUserBookmarkCountByMap(e);r&&V.getState().assetCounts.bookmarkByMap[e]!==r.count&&V.actions.setBookmarkCountByMap({count:r.count,mapId:e})}async reloadAssetCount(e){this.assetCountsService.clearCache();let r=Object.keys(V.getState().assetCounts.bookmarkByMap).length!==0;e===G.BOOKMARKS&&r&&V.actions.clearBookmarkCountByMap(),V.getState().assetCounts.allAsset[e]!==void 0&&await this.loadAssetCount(e)}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var e;if(this.bookmarksAreUsed){let r=!((e=this.currentSession)===null||e===void 0)&&e.sessionAuthenticated?await this.bookmarksService.listMyBookmarks():void 0;V.actions.bookmarks(r)}}},Dr=new Nr;window.FluidTopicsUserAssetsActions==null&&(window.FluidTopicsUserAssetsActions=Dr);var Pr=class{addCommand(e,r=!1){d.commands.add(e,r)}consumeCommand(e){return d.commands.consume(e)}};window.FluidTopicsAppInfoStoreService=new Pr;var Q=f(T());var Ms,Oe=class extends CustomEvent{constructor(e){super("ft-i18n-context-loaded",{detail:e})}},ma=Symbol("clearAfterUnitTest"),Ft=class extends(0,Q.withEventBus)(M){constructor(e){super(),this.messageContextProvider=e,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[Ms]=()=>{this.defaultMessages={},this.cache=new Q.CacheRegistry,this.listeners={}},this.currentUiLocale=d.getState().uiLocale,d.subscribe(()=>this.clearWhenUiLocaleChanges())}clearWhenUiLocaleChanges(){let{uiLocale:e}=d.getState();this.currentUiLocale!==e&&(this.currentUiLocale=e,this.cache.clearAll(),this.notifyAll())}addContext(e){let r=e.name.toLowerCase();this.cache.setFinal(r,e),this.notify(r)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(e,r){var n;if(e=e.toLowerCase(),r&&Object.keys(r).length>0){let s={...(n=this.defaultMessages[e])!==null&&n!==void 0?n:{},...r};(0,Q.deepEqual)(this.defaultMessages[e],s)||(this.defaultMessages[e]=s,await this.notify(e))}return this.fetchContext(e)}resolveContext(e){var r,n;return this.fetchContext(e),(n=(r=this.cache.getNow(e))===null||r===void 0?void 0:r.messages)!==null&&n!==void 0?n:{}}resolveRawMessage(e,r){let n=e.toLowerCase();return this.resolveContext(n)[r]}resolveMessage(e,r,...n){var s;let i=e.toLowerCase(),a=this.resolveContext(i);return new Q.ParametrizedLabelResolver((s=this.defaultMessages[i])!==null&&s!==void 0?s:{},a).resolve(r,...n)}async fetchContext(e){let r=!this.cache.has(e),n;try{n=await this.cache.get(e,()=>this.messageContextProvider(this.currentUiLocale,e)),r&&await this.notify(e)}catch(s){!(s instanceof Q.CanceledPromiseError)&&r&&console.error(s)}return n}subscribe(e,r){var n;return e=e.toLowerCase(),this.listeners[e]=(n=this.listeners[e])!==null&&n!==void 0?n:new Set,this.listeners[e].add(r),()=>{var s;return(s=this.listeners[e])===null||s===void 0?void 0:s.delete(r)}}async notifyAll(){let e=Object.keys(this.listeners);document.body.dispatchEvent(new Oe({loadedContexts:e})),this.dispatchEvent(new Oe({loadedContexts:e})),await Promise.all(e.map(r=>this.notify(r,!1)))}async notify(e,r=!0){r&&(document.body.dispatchEvent(new Oe({loadedContexts:[e]})),this.dispatchEvent(new Oe({loadedContexts:[e]}))),this.listeners[e]!=null&&await Promise.all([...this.listeners[e].values()].map(n=>(0,Q.delay)(0).then(()=>n()).catch(()=>null)))}};Ms=ma;window.FluidTopicsI18nService==null&&(window.FluidTopicsI18nService=new class extends Ft{constructor(){super(async(t,e)=>(await this.awaitApi).getFluidTopicsMessageContext(t,e))}});window.FluidTopicsCustomI18nService==null&&(window.FluidTopicsCustomI18nService=new class extends Ft{constructor(){super(async(t,e)=>(await this.awaitApi).getCustomMessageContext(t,e))}});var ks=window.FluidTopicsI18nService,qc=window.FluidTopicsCustomI18nService;var Ns=f(T()),Lr=class{highlightHtml(e,r,n){(0,Ns.highlightHtml)(e,r,n)}};window.FluidTopicsHighlightHtmlService=new Lr;var Ds=f(T());var Fr=class{isDate(e){var r,n,s,i;return(i=(n=((s=(r=d.getState().metadataConfiguration)===null||r===void 0?void 0:r.descriptors)!==null&&s!==void 0?s:[]).find(o=>o.key===e))===null||n===void 0?void 0:n.date)!==null&&i!==void 0?i:!1}format(e,r){var n,s,i,a;if(e==null)return"";try{return Ds.DateFormatter.format(e,(n=r?.locale)!==null&&n!==void 0?n:d.getState().uiLocale,(s=r?.longFormat)!==null&&s!==void 0?s:!1,(i=r?.withTime)!==null&&i!==void 0?i:!1,(a=r?.onlyTime)!==null&&a!==void 0?a:!1)}catch(o){throw console.error(`Date ${JSON.stringify(e)} is not valid`,o),o}}};window.FluidTopicsDateService=new Fr;var Ps=f(T());var He=class{static get(e,r){var n,s,i,a;let o=d.getState(),{lang:c,region:l}=(a=(s=(n=o.localesConfiguration)===null||n===void 0?void 0:n.defaultLocales)===null||s===void 0?void 0:s.defaultContentLocale)!==null&&a!==void 0?a:{lang:"en",region:"US"};return new Ps.SearchPlaceConverter(o.baseUrl,e??20,(i=o.localesConfiguration)===null||i===void 0?void 0:i.allLanguagesAllowed,r??`${c}-${l}`)}};var Me=class extends M{async sendDocumentStartDisplayEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.start_display event")}async sendTopicStartDisplayEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send topic.start_display event")}async sendKhubSearchEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send khub.search event")}async sendDocumentSearchEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.search event")}async sendSearchPageSelectEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send search_page.select event")}async sendSearchResultOpenContextMenuEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send search_result.open_context_menu event")}async sendDocumentOnDemandTranslateEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send document.on_demand_translate event")}async sendTopicAiTranslateEvent(e){return this.sendEvents([this.sortEventArrays(e)],"Failed to send topic.ai_translate event")}convertMapToAnalyticsDocument(e){let r;switch(e.editorialType){case"BOOK":r="STRUCTURED_DOCUMENT";break;case"SHARED_BOOK":r="SHARED_PERSONAL_BOOK";break;case"ARTICLE":r="RESOURCE";break;case"HTML_PACKAGE":r="HTML_PACKAGE";break;default:throw new TypeError("Unknown editorial type for map : "+e.editorialType)}return{id:e.id,title:e.title,type:r,metadata:e.metadata}}sortEventArrays(e){let r=Object.entries(e).map(([n,s])=>Array.isArray(s)?[n,s.map(i=>typeof i=="object"&&i!=null&&!Array.isArray(i)?this.sortEventArrays(i):i).sort((i,a)=>typeof i=="object"&&i!==null&&"key"in i?i.key.localeCompare(a.key):typeof i=="string"&&typeof a=="string"?i.localeCompare(a):String(i).localeCompare(String(a)))]:typeof s=="object"&&s!==null?[n,this.sortEventArrays(s)]:[n,s]);return Object.fromEntries(r)}sendEvents(e,r){let n="anything not undefined";return this.cache.get("analytics-event-"+this.hash(e),async()=>(await this.awaitApi).sendEvents(e).then(()=>n).catch(s=>(console.info(r),console.debug(s),n)),1e3)}};var Ur=class{urlToSearchRequest(e){return He.get().parse(e)}searchRequestToUrl(e){return He.get().serialize(e)}};window.FluidTopicsUrlService=new Ur;var ie=f(T());var ye=class t extends CustomEvent{constructor(e){super(t.eventName,{detail:{nextLocation:e}})}};ye.eventName="before-location-change";var ve=class t extends CustomEvent{constructor(e){super(t.eventName,{detail:{currentItem:e}})}};ve.eventName="change";var Br=class{itemName(e){return`fluid-topics-history-item-${e}`}get(e){let r=sessionStorage.getItem(this.itemName(e));return r?JSON.parse(r):void 0}set(e,r){sessionStorage.setItem(this.itemName(e),JSON.stringify(r))}},Ls=new Br;var Ut=class t extends ie.WithEventBus{static build(){return new t(window.history,Ls,()=>window.location,!1)}constructor(e,r,n,s){var i,a;super(),this.history=e,this.historyStorage=r,this.windowLocation=n,this.states=[],this.realPushState=e.pushState,this.realReplaceState=e.replaceState,this.initialIndex=(a=(i=e.state)===null||i===void 0?void 0:i.index)!==null&&a!==void 0?a:e.length-1,this.currentIndex=this.initialIndex,this.setCurrentState(this.buildCurrentState()),this.installProxies(),this.initEventListeners(),this.initData(s)}setCurrentState(e,r=!1){let n=r&&this.currentIndex===e.index-1;this.currentState={...this.buildCurrentState(),...e},this.currentIndex=this.currentState.index,this.states[this.currentIndex]=this.currentState,n&&(this.states=this.states.slice(0,this.currentIndex+1)),this.historyStorage.set(this.currentIndex,this.currentState),(0,ie.deepEqual)(this.currentState,this.history.state)||this.realReplaceState.apply(this.history,[this.currentState,this.currentState.title,this.windowLocation().href]),setTimeout(()=>this.dispatchEvent(new ve(this.currentItem())),0)}installProxies(){let e=r=>(n,s,[i,a,o])=>{let c=new ye(new URL(typeof o=="string"?o:(o??this.windowLocation()).href,window.location.origin));this.dispatchEvent(c);let l=r(),u={...l===this.currentIndex?this.currentState:void 0,...i,index:l,href:c.detail.nextLocation.href};n.apply(s,[u,a,u.href]),this.setCurrentState(u,!0)};this.history.pushState=new Proxy(this.history.pushState,{apply:e(()=>this.currentIndex+1)}),this.history.replaceState=new Proxy(this.history.replaceState,{apply:e(()=>this.currentIndex)})}initEventListeners(){window.addEventListener("popstate",e=>this.setCurrentState(e.state)),document.querySelector("title")==null&&document.head.append(document.createElement("title")),new MutationObserver(()=>this.updateCurrentState({title:document.title})).observe(document.querySelector("title"),{subtree:!0,characterData:!0,childList:!0})}initData(e){for(let r=this.history.length-1;r>=0;r--)e?this.states[r]=this.historyStorage.get(r):setTimeout(()=>this.states[r]=this.historyStorage.get(r),this.history.length-r)}updateCurrentState(e){var r;let n={...this.buildCurrentState(),...e,index:this.currentIndex,title:(r=e?.title)!==null&&r!==void 0?r:this.currentState.title};this.setCurrentState(n)}addBeforeLocationChangeListener(e){this.addEventListener(ye.eventName,e)}removeBeforeLocationChangeListener(e){this.removeEventListener(ye.eventName,e)}addHistoryChangeListener(e){this.addEventListener(ve.eventName,e)}removeHistoryChangeListener(e){this.removeEventListener(ve.eventName,e)}currentItem(){return(0,ie.deepCopy)(this.currentState)}back(){let e=this.previousDifferentMajorPosition();e>=0?this.history.go(e-this.currentIndex):this.currentIndex!==this.initialIndex?this.history.go(this.initialIndex-this.currentIndex):this.history.back()}backwardItem(){return(0,ie.deepCopy)(this.states[this.previousDifferentMajorPosition()])}backwardItemMatching(e){let r=this.states.filter(n=>!!n).filter(n=>n.index<this.currentIndex).reverse();return(0,ie.deepCopy)(r.find(n=>e(n)))}previousDifferentMajorPosition(){let e=this.currentIndex>0?this.currentIndex-1:0;for(;e>0&&!this.isDifferentMajorState(e);)e--;return e}forward(){let e=this.nextMajorPosition();e&&e<this.states.length?this.history.go(e-this.currentIndex):this.history.forward()}forwardItem(){let e=this.nextMajorPosition();if(e)return(0,ie.deepCopy)(this.states[e])}nextMajorPosition(){let e=this.currentIndex;if(!(e>=this.states.length)){do e++;while(e<this.states.length&&!this.isDifferentMajorState(e));return this.getHigherPositionInTheSameState(e)}}getHigherPositionInTheSameState(e){var r;let n=(r=this.states[e])===null||r===void 0?void 0:r.majorStateId;if(!n)return e;let s=e,i=e+1;for(;this.states.length>i&&!this.isDifferentMajorState(i,n);)this.hasState(i)&&(s=i),i++;return s}buildCurrentState(){var e,r;return{...this.history.state,index:this.currentIndex,href:this.windowLocation().href,title:(r=(e=this.history.state)===null||e===void 0?void 0:e.title)!==null&&r!==void 0?r:document.title}}hasState(e){return this.states[e]!=null}isDifferentMajorState(e,r){var n;if(!this.hasState(e))return!1;let s=r??this.currentState.majorStateId,i=(n=this.states[e])===null||n===void 0?void 0:n.majorStateId;return i==null||i!=s}};window.FluidTopicsInternalHistoryService==null&&(window.FluidTopicsInternalHistoryService=Ut.build(),window.FluidTopicsHistoryService={currentItem:()=>window.FluidTopicsInternalHistoryService.currentItem(),back:()=>window.FluidTopicsInternalHistoryService.back(),forward:()=>window.FluidTopicsInternalHistoryService.forward(),backwardItem:()=>window.FluidTopicsInternalHistoryService.backwardItem(),forwardItem:()=>window.FluidTopicsInternalHistoryService.forwardItem(),backwardItemMatching:t=>window.FluidTopicsInternalHistoryService.backwardItemMatching(t),addHistoryChangeListener:t=>window.FluidTopicsInternalHistoryService.addHistoryChangeListener(t),removeHistoryChangeListener:t=>window.FluidTopicsInternalHistoryService.removeHistoryChangeListener(t),addBeforeLocationChangeListener:t=>window.FluidTopicsInternalHistoryService.addBeforeLocationChangeListener(t),removeBeforeLocationChangeListener:t=>window.FluidTopicsInternalHistoryService.removeBeforeLocationChangeListener(t)});var Fs=f(oe());var Us=Fs.css`
2
+ `;var Vs=f(oe()),q=f(re()),Ae=f(T());var Ee=f(T());function Bs(t,e){let{authenticationRequired:r,session:n}=d.getState();return r&&!n?.sessionAuthenticated?Promise.resolve(e):t()}var Bt=class extends Ie{async updateUiLocale(e){return(await this.awaitApi).updateUiLocale(e)}};var Vr=class t extends Ee.FtStateManager{static build(e){return new t(d,e)}constructor(e,r){super(),this.store=e,this.cache=new Ee.CacheRegistry,this.withManualResources=!0,this.userLocaleService=new Bt,this.cleanSessionDebouncer=new Ee.Debouncer,this.reloadConfiguration=()=>{var n;(n=this.cache)===null||n===void 0||n.clear("availableContentLocales"),this.updateAvailableContentLocales()},this.reloadDebouncer=new Ee.Debouncer(500),this.apiProvider=r??(()=>ge.get())}setWithManualResources(e){this.withManualResources=e,this.updateIfNeeded()}addListeners(){this.store.addEventListener(z.eventName,this.reloadConfiguration)}removeListeners(){this.store.removeEventListener(z.eventName,this.reloadConfiguration)}async updateIfNeeded(){this.apiProvider()&&(this.withManualResources||(this.store.getState().session==null&&this.updateSession(),this.store.getState().metadataConfiguration==null&&this.updateMetadataConfiguration()),this.store.getState().localesConfiguration==null&&this.updateLocalesConfiguration(),(this.store.getState().availableContentLocales==null||this.store.getState().availableContentLocales.length==0)&&this.updateAvailableContentLocales())}async updateSession(){let e=await this.cache.get("session",async()=>{let r=await this.apiProvider().getCurrentSession();return r.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run(()=>{this.cache.clear("session"),this.setSession(void 0)},r.idleTimeoutInMillis),r});this.setSession(e)}async updateMetadataConfiguration(){this.setMetadataConfiguration(await this.cache.get("metadataConfiguration",()=>this.apiProvider().getMetadataConfiguration()))}async updateLocalesConfiguration(){this.setLocalesConfiguration(await this.cache.get("localesConfiguration",()=>this.apiProvider().getLocalesConfiguration()))}async updateAvailableContentLocales(){var e;let r=await this.cache.get("availableContentLocales",()=>Bs(()=>this.apiProvider().getAvailableSearchLocales(),{contentLocales:[]}));this.setAvailableContentLocales((e=r.contentLocales)!==null&&e!==void 0?e:[])}setStickyFilters(e){this.store.actions.stickyFilters(e)}setBaseUrl(e){this.store.actions.baseUrl(e),window.fluidTopicsBaseUrl=e}setTenantId(e){this.store.actions.tenantId(e)}setApiIntegrationIdentifier(e){this.store.actions.apiIntegrationIdentifier(e)}setApiIntegrationAppVersion(e){this.store.actions.apiIntegrationAppVersion(e)}setUiLocale(e){this.store.actions.uiLocale(e)}setLocalesConfiguration(e){this.store.actions.localesConfiguration(e),setTimeout(()=>this.updateIfNeeded())}setAvailableContentLocales(e){this.store.actions.availableContentLocales(e),setTimeout(()=>this.updateIfNeeded())}stopReloadDebouncer(){this.reloadDebouncer.cancel()}requestUiLocaleUpdate(e,r){this.userLocaleService.updateUiLocale({uiLocale:e,contentLocale:r}).then(n=>{n.uiLocaleChanged&&(this.reloadDebouncer.run(()=>window.location.reload()),this.store.dispatchEvent(new je(n)))}).catch(()=>{})}setMetadataConfiguration(e){this.store.actions.metadataConfiguration(e),setTimeout(()=>this.updateIfNeeded())}setNoCustom(e){this.store.actions.noCustom(e)}setEditorMode(e){this.store.actions.editorMode(e)}setNoCustomComponent(e){this.store.actions.noCustomComponent(e)}setNoCustomCode(e){this.store.actions.noCustomCode(e)}setSession(e){this.store.actions.session(e),setTimeout(()=>this.updateIfNeeded())}setOpenExternalDocumentInNewTab(e){this.store.actions.openExternalDocumentInNewTab(e)}setNavigatorOnline(e){this.store.actions.navigatorOnline(e)}setForcedOffline(e){this.store.actions.forcedOffline(e)}setAuthenticationRequired(e){this.store.actions.authenticationRequired(e)}userHasAnyRole(...e){return kn(d.getState().session,...e)}},$e=Vr.build();var Se=class extends Event{constructor(e,r,n,s){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=r,this.callback=n,this.subscribe=s??!1}};var Ke=class{constructor(){this.pendingContextRequests=new Map,this.onContextProvider=e=>{let r=this.pendingContextRequests.get(e.context);if(r===void 0)return;this.pendingContextRequests.delete(e.context);let{requests:n}=r;for(let{elementRef:s,callbackRef:i}of n){let a=s.deref(),o=i.deref();a===void 0||o===void 0||a.dispatchEvent(new Se(e.context,a,o,!0))}},this.onContextRequest=e=>{if(e.subscribe!==!0)return;let r=e.contextTarget??e.composedPath()[0],n=e.callback,s=this.pendingContextRequests.get(e.context);s===void 0&&this.pendingContextRequests.set(e.context,s={callbacks:new WeakMap,requests:[]});let i=s.callbacks.get(r);i===void 0&&s.callbacks.set(r,i=new WeakSet),i.has(n)||(i.add(n),s.requests.push({elementRef:new WeakRef(r),callbackRef:new WeakRef(n)}))}}attach(e){e.addEventListener("context-request",this.onContextRequest),e.addEventListener("context-provider",this.onContextProvider)}detach(e){e.removeEventListener("context-request",this.onContextRequest),e.removeEventListener("context-provider",this.onContextProvider)}};var k=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},b=class extends Ae.FtLitElementRedux{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.apiIntegrationAppVersion="ft-integration-app-version",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.noCustomCode=!1,this.withManualResources=!1,this.navigatorOnline=!1,this.forcedOffline=!1,this.authenticationRequired=!1,this.messageContexts=[],this.stateManager=$e,this.contextRoot=new Ke}render(){return Vs.html`
3
3
  <slot></slot>
4
- `}connectedCallback(){super.connectedCallback(),this.stateManager.addListeners(),this.contextRoot.attach(document.body)}disconnectedCallback(){super.disconnectedCallback(),this.stateManager.removeListeners(),this.contextRoot.detach(document.body)}update(e){var r;super.update(e),e.has("baseUrl")&&this.stateManager.setBaseUrl(this.baseUrl),e.has("tenantId")&&this.stateManager.setTenantId(this.tenantId),e.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),e.has("apiIntegrationAppVersion")&&this.stateManager.setApiIntegrationAppVersion(this.apiIntegrationAppVersion),e.has("uiLocale")&&this.stateManager.setUiLocale(this.uiLocale),e.has("metadataConfiguration")&&this.stateManager.setMetadataConfiguration(this.metadataConfiguration),e.has("noCustom")&&this.stateManager.setNoCustom(this.noCustom),e.has("editorMode")&&this.stateManager.setEditorMode(this.editorMode),e.has("noCustomComponent")&&this.stateManager.setNoCustomComponent(this.noCustomComponent),e.has("noCustomCode")&&this.stateManager.setNoCustomCode(this.noCustomCode),e.has("session")&&this.stateManager.setSession(this.session),e.has("messageContexts")&&this.messageContexts!=null&&this.messageContexts.forEach(n=>Ns.addContext(n)),e.has("openExternalDocumentInNewTab")&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("navigatorOnline")&&this.stateManager.setNavigatorOnline(this.navigatorOnline),e.has("forcedOffline")&&this.stateManager.setForcedOffline(this.forcedOffline),e.has("authenticationRequired")&&this.stateManager.setAuthenticationRequired(this.authenticationRequired),e.has("withManualResources")&&((r=this.stateManager)===null||r===void 0||r.setWithManualResources(this.withManualResources)),setTimeout(()=>this.stateManager.updateIfNeeded())}};_.elementDefinitions={};_.styles=Bs;D([(0,V.property)()],_.prototype,"baseUrl",void 0);D([(0,V.property)()],_.prototype,"tenantId",void 0);D([(0,V.property)()],_.prototype,"apiIntegrationIdentifier",void 0);D([(0,V.property)()],_.prototype,"apiIntegrationAppVersion",void 0);D([(0,V.property)()],_.prototype,"uiLocale",void 0);D([(0,Ae.jsonProperty)(null)],_.prototype,"availableUiLocales",void 0);D([(0,Ae.jsonProperty)(null)],_.prototype,"metadataConfiguration",void 0);D([(0,V.property)({type:Boolean})],_.prototype,"editorMode",void 0);D([(0,V.property)({type:Boolean})],_.prototype,"noCustom",void 0);D([(0,V.property)({type:Boolean})],_.prototype,"openExternalDocumentInNewTab",void 0);D([(0,V.property)({converter:{fromAttribute(t){return t==="false"?!1:t==="true"||(t??!1)}}})],_.prototype,"noCustomComponent",void 0);D([(0,V.property)({converter:{fromAttribute(t){return t==="false"?!1:t==="true"||(t??!1)}}})],_.prototype,"noCustomCode",void 0);D([(0,V.property)({type:Boolean})],_.prototype,"withManualResources",void 0);D([(0,V.property)({type:Boolean})],_.prototype,"navigatorOnline",void 0);D([(0,V.property)({type:Boolean})],_.prototype,"forcedOffline",void 0);D([(0,V.property)({type:Boolean})],_.prototype,"authenticationRequired",void 0);D([(0,Ae.jsonProperty)([])],_.prototype,"messageContexts",void 0);D([(0,Ae.jsonProperty)(void 0)],_.prototype,"session",void 0);var Hs=f(b());var js={"ft-app-context":_};(0,Hs.customElements)(js);var Vt=f(b()),Bt=class extends N{get metadataFilters(){return this._metadataFilters}set metadataFilters(e){this._metadataFilters=e}get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,r,n,s){super(!1,r),this.converter=e,this._mapId=n,this._metadataFilters=s,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(this.makeCacheKey("enrichedToc",void 0,this.metadataFilters),()=>this.withMapId(e=>this.fetchPages(e,this._metadataFilters).then(r=>this.converter.convertPaginatedToc(e,r)))),this.cache.register("ratingSummary",()=>{var e,r;return G((r=(e=d.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&r!==void 0?r:[],"RATING_USER")?this.withMapId(s=>this.fetchMapRating(s)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,r,n){return e+(r?"-destinationLanguage-"+r?.destinationLanguage:"")+(!n||n.length==0?"":"-metadataFilters-"+this.hash(n))}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.metadataFilters),()=>this.fetchPages(this.mapId,this.metadataFilters,e).then(r=>this.converter.convertPaginatedToc(this.mapId,r)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e,this.metadataFilters))}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 getFilteredTocNodes(e){var r;return(r=(await this.getEnrichedToc(e)).filteredTocNodes)!==null&&r!==void 0?r:{}}async getTocNode(e,r){return(await this.getEnrichedToc(r)).nodeByTocId[e]}getTocNodeNow(e,r){var n;return(n=this.getEnrichedTocNow(r))===null||n===void 0?void 0:n.nodeByTocId[e]}getTocNodeNowByUrl(e,r){var n,s;let i=this.getMapNow(r);return i?.prettyUrl==e||`${i?.id}/root`===e?(n=this.getEnrichedTocNow(r))===null||n===void 0?void 0:n.toc[0]:(s=this.getEnrichedTocNow(r))===null||s===void 0?void 0:s.nodeByUrl[e]}async getPage(e,r){let n=await this.getEnrichedToc(r);return n.pages[e-1]||n.pages[0]}async getPageByTocId(e,r){let n=await this.getEnrichedToc(r);return n.pageByTocId[e]||n.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))}async getTopicMetadataValue(e,r){let n=this.getTocNodeNow(e);if(!n)return;let s=await this.getTopicInfo(n);return s?.metadata.find(i=>i.key==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,n){return this.cache.get("topic-relatives-"+[e,r,...n].join("-"),()=>this.fetchRelativesForTopicInMap(e,r,n))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,r,n,s){let i=this.getNavigationData(e,r,n),a=this.getReaderLinkPrefix()+(i.prettyUrl?i.prettyUrl:`${i.mapId}/${i.tocId}`),o=new URL(a,this.api.tenantBaseUrl);if(i.page!=null&&o.searchParams.set("page",`${i.page}`),i.prettyUrlDuplicated&&o.searchParams.set("tocId",i.tocId),i.section!=null&&o.searchParams.set("section",i.section),s&&i.metadataFilters){let c=Vt.SearchPlaceConverter.serializeValueFilters(i.metadataFilters);c&&o.searchParams.set(Vt.SearchPlaceQueryParams.VALUE_FILTERS,c)}return o.href}getLinkWithFilter(e,r,n){return this.getLink(e,r,n,!0)}getNavigationData(e,r,n,s){var i,a;e=e||"root";let o=this.getEnrichedTocNow(s),c=o?.pageByTocId[e],l=o?.nodeByTocId[e],u=l?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(i=l?.title)!==null&&i!==void 0?i:"",untranslatedTopicTitle:l?.untranslatedTitle,page:r&&c&&c.number!==r?r:void 0,prettyUrl:u?.replace(/^r\//,""),prettyUrlDuplicated:(a=o?.duplicatedPrettyUrls.has(u??""))!==null&&a!==void 0?a:!1,section:n,metadataFilters:this.metadataFilters}}async getAccurateNavigationData(e,r,n,s){return await this.getEnrichedToc(s),this.getNavigationData(e,r,n,s)}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 n;return r?{type:r.topics.type,rating:(n=r.topics)===null||n===void 0?void 0:n.ratings.find(s=>s.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,n){return this.makeRateTopicRequest(e,r,n).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=d.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,r,n,s){return this.makeTopicFeedbackRequest(e,r,n,s)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,r){let n=this.getTocNodeNow(e,r);if(!n)return[];let s=[{tocId:n.tocId,title:n.title,untranslatedTitle:n.untranslatedTitle}],i=this.getTocNodeNow(n.parentTocId,r);for(;i;)s.unshift({tocId:i.tocId,title:i.title,untranslatedTitle:i.untranslatedTitle}),i=this.getTocNodeNow(i.parentTocId,r);return s}isFeatureAccessible(e,{session:r}){var n;if(!this.isFeatureAvailable(e))return!1;switch(e){case re.FEEDBACK:return G(r??[],S.FEEDBACK_USER);case re.RATING:return G(r??[],S.RATING_USER);case re.PRINT:return G(r??[],S.PRINT_USER);case re.BOOKMARK:return!!r?.sessionAuthenticated;case re.COLLECTIONS:return G(r??[],S.COLLECTION_USER);case re.PERSONAL_BOOKS:return G(r??[],S.PERSONAL_BOOK_USER)&&!(!((n=this.getMapNow())===null||n===void 0)&&n.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var qt=class t extends Bt{static async build(e){return new t(new Je,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,r){let n=await this.api.getMap(e,r);return this.fingerprint=n.fingerprint,n}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,r,n){return await this.getMap(n),r?.length?this.api.getFilteredPages(e,n,r):this.api.getPages(e,this.fingerprint,n)}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 n={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:r}}],sort:[],facets:[]};return this.api.search(n)}fetchRelativesForTopicInMap(e,r,n){let s={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:r,valueFilter:{negative:!1,values:n}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(s)}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,n){return this.api.rateTopic(this.mapId,e,r,n)}makeTopicFeedbackRequest(e,r,n,s){return this.api.sendTopicFeedback(this.mapId,e,r,n,s)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var Ea="topicPivot";function Ks(t,e){let r=new URL(t);return e?.values.forEach(n=>{r.searchParams.append(Ea,n)}),r.href}var jt=class t{static build(e,r){return new t(Yr(e.trim()||"context"),r??qt.build)}loaded(){return(0,L.waitUntil)(()=>this._loaded)}constructor(e,r,n,s){this.store=e,this.clusteringHelperProvider=n,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new L.Debouncer(10),this.analyticsEventsService=s??new Me,this.initService(r)}async initService(e){this.service=await e();let{mapId:r,metadataFilters:n}=this.store.getState();return this.service.mapId=r,this.service.metadataFilters=n,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 setFilters(e){(0,L.deepEqual)(e,this.store.getState().metadataFilters)||(this.store.actions.metadataFilters(e),this.service&&(this.service.metadataFilters=e))}async awaitService(){return(0,L.waitFor)(()=>this.service)}async navigateToTopic(e,r,n){await this.loaded();let s=await this.resolvePage(e,n);this.store.actions.currentPage(s);let i=this.resolveValidNonRootTocId(e,s);this.store.actions.scrollTarget({tocId:i,section:r}),this.store.getState().visibleTopics[0]!==i&&this.store.actions.visibleTopics([]),e&&!r&&(this.store.commands.clear(/^focus-topic-/),this.store.commands.add({type:`focus-topic-${e}`}))}async resolvePage(e,r){var n,s,i;let a=await this.awaitService();if(r)return a.getPage(r,this.getTranslationSettings());if(!e)return a.getPageByTocId("root",this.getTranslationSettings());let o=(n=this.store.getState().filteredTocNodes)===null||n===void 0?void 0:n[e],c=((s=this.service)===null||s===void 0?void 0:s.getTocNodeNow(e))!=null;return o&&o.reason!=="ACCESS_RIGHTS_FILTER"&&!c?a.getPageByTocId((i=o.closestParent)!==null&&i!==void 0?i:"root",this.getTranslationSettings()):a.getPageByTocId(e,this.getTranslationSettings())}resolveValidNonRootTocId(e,r){var n,s,i,a,o;let c=(s=e==="root"?void 0:e)!==null&&s!==void 0?s:r.rootTocId;if(!r.topics.includes(c)){if(e!="root"&&!r.hiddenTopics.includes(c)){let l=this.store.getState().filteredTocNodes[c];if(l){this.store.dispatchEvent(new Xe(l));let u=((n=this.service)===null||n===void 0?void 0:n.getTocNodeNow(l.tocId))!=null;return l.reason==="ACCESS_RIGHTS_FILTER"||u?l.tocId:(i=l.closestParent)!==null&&i!==void 0?i:"root"}this.store.dispatchEvent(new CustomEvent(de.requestedTopicNotFound))}return(o=(a=r.topics[0])!==null&&a!==void 0?a:r.hiddenTopics[0])!==null&&o!==void 0?o:"root"}return c}async navigateToPage(e){await this.loaded();let n=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(n)}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())}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()}clearFromFilter(){this._loaded=!1,this.store.actions.toc(void 0),this.store.actions.pagesToc(void 0)}async reloadFromFilter(e,r){var n,s,i;this.clearFromFilter();let{scrollTarget:a,visibleTopics:o,currentPage:c}=this.store.getState(),l=(i=(s=(n=a?.tocId)!==null&&n!==void 0?n:o?.[0])!==null&&s!==void 0?s:c?.rootTocId)!==null&&i!==void 0?i:"root";await this.fetchDataFromFilter(),this.navigateToTopic(l,e,r)}async fetchDataFromFilter(){var e,r,n,s;let i=this.getTranslationSettings();try{await Promise.all([(e=this.service)===null||e===void 0?void 0:e.getToc(i).then(a=>this.store.actions.toc(a)),(r=this.service)===null||r===void 0?void 0:r.getPagesToc(i).then(a=>this.store.actions.pagesToc(a)),(n=this.service)===null||n===void 0?void 0:n.getFilteredTocNodes(i).then(a=>this.store.actions.filteredTocNodes(a))]),this._loaded=!0}catch(a){if(!(a instanceof L.CanceledPromiseError))throw i&&this.setTranslationError(!0),(s=this.errorHandler)===null||s===void 0||s.call(this,a),a}}async fetchData(){var e,r,n,s,i,a,o;let c=this.getTranslationSettings();try{c&&this.setTranslationLoading(!0),await Promise.all([this.loadConfiguration(),(e=this.service)===null||e===void 0?void 0:e.getMap(c).then(l=>this.store.actions.map(l)),(r=this.service)===null||r===void 0?void 0:r.getToc(c).then(l=>this.store.actions.toc(l)),(n=this.service)===null||n===void 0?void 0:n.getPagesToc(c).then(l=>this.store.actions.pagesToc(l)),(s=this.service)===null||s===void 0?void 0:s.getPaginationConfiguration().then(l=>this.store.actions.paginationConfiguration(l)),(i=this.service)===null||i===void 0?void 0:i.getFilteredTocNodes(c).then(l=>this.store.actions.filteredTocNodes(l)),(a=this.service)===null||a===void 0?void 0:a.getTranslationError(c).then(l=>this.setTranslationError(l))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,c&&this.setTranslationLoading(!1)}catch(l){if(!(l instanceof L.CanceledPromiseError))throw c&&this.setTranslationError(!0),(o=this.errorHandler)===null||o===void 0||o.call(this,l),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()}async fetchRelatives(){var e,r;let n=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(s=>{var i;return s.key==((i=this.store.getState().configuration)===null||i===void 0?void 0:i.relativePivotMetadata)}).flatMap(s=>s.values);if(n!==void 0&&n.length>0){let s=await((r=this.service)===null||r===void 0?void 0:r.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,n)),i=s?.results.flatMap(a=>a.entries);this.store.actions.relatives(i)}this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(de.clusteringHelperCreated))}createClusteringHelper(){var e,r;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let n=this.store.getState().relatives;if(n){let s=n.find(a=>{var o;return((o=a.map)===null||o===void 0?void 0:o.mapId)==this.store.getState().mapId}),i=(r=(e=d.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&r!==void 0?r:[];return new L.ClusteringHelper(n,s,this.metadataForSwitchToRelatives,i)}}async navigateToRelativeTopicIfFound(e){var r,n,s;await this.loaded();let i=await(0,L.waitFor)(()=>{var l;return(l=this.store.getState().configuration)===null||l===void 0?void 0:l.relativeTopicPivotMetadata}),a=this.store.getState().mapId,c=await(await this.awaitService()).getRelativesForTopicInMap(a,i,[e]);if(!((s=(n=(r=c?.results)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.entries)===null||s===void 0)&&s[0]){let l=c.results[0].entries[0].topic.tocId;return await this.navigateToTopic(l),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),e&&this.sendDocumentOnDemandTranslateEvent(e),await this.loadDebouncer.run(()=>this.fetchData())}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData())}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.linkPreviewDialogId(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 n=await((r=this.service)===null||r===void 0?void 0:r.getTopicRating(e));n&&this.store.actions.setTopicsRating({[e]:n})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}async getAccurateNavigationData(e,r,n){return await this.awaitService(),this.service.getAccurateNavigationData(e,r?.number,n?.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,n;let s=this.getTranslationSettings();return s?(this.sendTopicAiTranslateEvent(s.destinationLanguage,e),(r=this.service)===null||r===void 0?void 0:r.getTranslatedTopicContent(e,s).then(i=>(i.isTranslationError&&this.setTranslationError(!0),i.content))):(n=this.service)===null||n===void 0?void 0:n.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(de.mapAttachmentsUpdate))}async getRelativeDocumentUrlForLocale(e){var r,n,s;this.store.getState().relatives==null&&await this.fetchRelatives();let i=L.ClusteringHelper.findResultWithMetadataValue((s=this.store.getState().relatives)!==null&&s!==void 0?s:[],"ft:locale",e),a=(0,L.accessResultUrl)(i);if(a){let o=this.store.getState().visibleTopics[0],c=(r=this.store.getState().configuration)===null||r===void 0?void 0:r.relativeTopicPivotMetadata;if(c&&o){let l=await((n=this.service)===null||n===void 0?void 0:n.getTopicMetadataValue(o,c));a=Ks(a,l)}}return a}sendDocumentOnDemandTranslateEvent(e){var r;let{editorMode:n,apiIntegrationIdentifier:s,apiIntegrationAppVersion:i}=d.getState(),a=this.store.getState(),o=a.map,c=a.translation.profileId;if(!(n||!o||!s||!i||!c))try{let u={...this.analyticsEventsService.convertMapToAnalyticsDocument(o),title:(r=o.untranslatedTitle)!==null&&r!==void 0?r:o.title};this.analyticsEventsService.sendDocumentOnDemandTranslateEvent({name:"DOCUMENT__ON_DEMAND_TRANSLATE",offline:!1,appName:s,appVersion:i,sourceLanguage:this.parseLanguageToAnalyticsFormat(o.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e.code),profileId:c,document:u,translationOrigin:Ze.AI})}catch(l){console.warn("Failed to send on-demand document translate event:",l)}}sendTopicAiTranslateEvent(e,r){var n;let{editorMode:s,apiIntegrationIdentifier:i,apiIntegrationAppVersion:a}=d.getState(),o=this.store.getState(),c=o.map,l=o.translation.profileId;if(!(s||!c||!i||!a||!l))try{let u=this.buildBreadcrumb(r.tocId);if(!u){console.warn("Failed to build breadcrumb for topic ai translate event");return}let p={...this.analyticsEventsService.convertMapToAnalyticsDocument(c),title:(n=c.untranslatedTitle)!==null&&n!==void 0?n:c.title};this.analyticsEventsService.sendTopicAiTranslateEvent({name:"TOPIC__AI_TRANSLATE",offline:!1,appName:i,appVersion:a,sourceLanguage:this.parseLanguageToAnalyticsFormat(c.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e),breadcrumb:u.map(y=>{var E;return{tocId:y.tocId,title:(E=y.untranslatedTitle)!==null&&E!==void 0?E:y.title}}),document:p,profileId:l})}catch(u){console.warn("Failed to send topic ai translate event:",u)}}parseLanguageToAnalyticsFormat(e){if(!e)return;let r=e.split("-");return r.length===2?{languageCode:r[0],countryCode:r[1]}:{languageCode:r[0],countryCode:""}}};var $s=f(oe());var zs=$s.css`
5
- `;var Ht=class extends CustomEvent{constructor(e,r){super("ft-reader-map-loaded",{detail:{map:e,toc:r}})}},Kt=class extends CustomEvent{constructor(e,r){super("ft-reader-visible-topics-change",{detail:{visibleTopics:r}})}},$t=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},zt=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},Gt=class extends Event{constructor(){super("ft-reader-map-not-found")}},Wt=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},Qt=class extends Event{constructor(){super("ft-reader-map-forbidden")}},Yt=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var Gs=f(oe());var Ws=Gs.css`
6
- `;var Zs=f(oe()),Q=f(te()),q=f(b());var ke=f(b()),Qe=f(te());var ze;(function(t){t.CLUSTERED_SEARCH="CLUSTERED_SEARCH"})(ze||(ze={}));var x=f(b());var Qs=f(b()),Sa={setRequest:(t,e)=>{t.request=e.payload}},Ys=t=>Qs.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",clusterSortCriterions:[],metadataFilters:[],facets:[],sort:[],sortId:void 0,paging:{page:1,perPage:20},keywordMatch:void 0},liveQuery:"",recentQueries:[],paging:void 0,facets:void 0,spellcheck:void 0,locales:[],results:void 0,announcements:void 0,suggestResults:void 0,configuration:void 0,propagatedFacets:[]},reducers:Sa});var Xt=class extends N{constructor(e){super(!0,e),this.cache.registerFinal("search-configuration",async()=>(await this.awaitApi).getSearchConfiguration())}async launchSearch(e){let r={...e,metadataFilters:this.sortFilters(e.metadataFilters),facets:[...e.facets].sort((n,s)=>n.id.localeCompare(s.id))};return this.cache.get("search-"+this.hash(r),async()=>(await this.awaitApi).search(e),120*1e3)}async launchSuggest(e){let r={...e,metadataFilters:this.sortFilters(e.metadataFilters)};return this.cache.get("suggest-"+this.hash(r),async()=>(await this.awaitApi).getSuggestions(e),120*1e3)}async getAvailableSearchLocales(){return this.cache.get("available-locales",async()=>(await this.awaitApi).getAvailableSearchLocales())}async getConfiguration(){return this.cache.get("search-configuration")}sortFilters(e){return e.map(r=>r.valueFilter==null?r:{...r,valueFilter:{...r.valueFilter,values:[...r.valueFilter.values].sort((n,s)=>n.localeCompare(s))}}).sort((r,n)=>r.key.localeCompare(n.key))}};var Jt=class extends CustomEvent{constructor(e){super("ft-search-load-error",{detail:e,composed:!0,bubbles:!0})}},Zt=class extends CustomEvent{constructor(e){super("ft-search-request-change",{detail:e,composed:!0,bubbles:!0})}},er=class extends CustomEvent{constructor(e,r,n){super("ft-search-results-change",{detail:{request:e,paging:r,spellcheck:n},composed:!0,bubbles:!0})}},Ge=class t extends Event{constructor(){super(t.eventName)}};Ge.eventName="search-context-clear-all-filters";var Aa=t=>t.request.virtualField===Te.TITLE_ONLY&&t.request.scope===be.DOCUMENTS,Ta=t=>t.request.keywordMatch==et.MANDATORY,We=class t extends x.FtStateManager{static build(e,r){return new t(Ys(e.trim()||"context"),r)}constructor(e,r){super(),this.store=e,this.ignoreEmptyQuery=!1,this.canUpdateUiLocale=!1,this.openExternalDocumentInNewTab=!1,this.applyStickyFilters=!1,this.history=new x.QueryHistoryStorage(this.store.actions.recentQueries),this.onNewNeededRequest=n=>{n==ze.CLUSTERED_SEARCH&&this.launchSearch()},this.onStorageEvent=n=>{n.key===this.taruqaConfigStorageKey&&this.loadTaruqaTemplate()},this.loadTaruqaTemplate=()=>{var n;let s;if(G(d.getState().session,S.DEBUG_USER)){let i=JSON.parse((n=window.localStorage.getItem(this.taruqaConfigStorageKey))!==null&&n!==void 0?n:"{}");s=i.overrideEnabled?i.template:void 0}this.updateSearchRequest({taruqaTemplateOverride:s,changedByConfiguration:!0})},this.localesDebouncer=new x.Debouncer(10),this.searchDebouncer=new x.Debouncer(100),this.launchSearch=n=>this.searchDebouncer.run(()=>this.fetchSearchData(n??this.buildSearchRequest())),this.buildSearchRequest=(n=this.store.getState())=>{var s;return{...n.request,facets:this.facetIds.map(i=>({id:i})),stickyFiltersId:this.applyStickyFilters?(s=d.getState().stickyFilters)===null||s===void 0?void 0:s.id:void 0}},this.suggestDebouncer=new x.Debouncer(1e3),this.launchSuggest=n=>this.suggestDebouncer.run(()=>this.fetchSuggestData(n??this.buildSuggestRequest())),this.buildSuggestRequest=(n=this.store.getState())=>{var s,i;return{input:n.liveQuery,metadataFilters:n.request.metadataFilters,sort:(i=n.request.sort)!==null&&i!==void 0?i:[],sortId:n.request.sortId,contentLocale:n.request.contentLocale,scope:n.request.scope,keywordMatch:n.request.keywordMatch,stickyFiltersId:this.applyStickyFilters?(s=d.getState().stickyFilters)===null||s===void 0?void 0:s.id:void 0}},this.service=r??new Xt,this.service.cache.addEventListener("clear-cache",n=>{n.detail.clearedKeys.includes("available-locales")&&this.updateLocales()}),this.searchWatcher=new x.ReduxWatcher(e,this.buildSearchRequest,this.launchSearch),this.suggestWatcher=new x.ReduxWatcher(e,this.buildSuggestRequest,this.launchSuggest),this.stickyFiltersIdWatcher=new x.ReduxWatcher(d,n=>{var s;return(s=n.stickyFilters)===null||s===void 0?void 0:s.id},()=>{this.applyStickyFilters&&(this.launchSearch(),this.launchSuggest())})}async initService(){return this.updateLocales(),this.service.getConfiguration().then(e=>{this.store.actions.configuration(e),this.setSortId(this.store.getState().request.sortId)}),this.loadTaruqaTemplate(),this.launchSearch()}addListeners(){window.addEventListener("storage",this.onStorageEvent),d.addEventListener($.eventName,this.loadTaruqaTemplate),this.searchWatcher.watch(),this.suggestWatcher.watch(),this.stickyFiltersIdWatcher.watch(),this.history.enable(d.getState().tenantId+"-ft-recent-queries")}removeListeners(){window.removeEventListener("storage",this.onStorageEvent),d.removeEventListener($.eventName,this.loadTaruqaTemplate),this.searchWatcher.stop(),this.suggestWatcher.stop(),this.stickyFiltersIdWatcher.stop(),this.history.disable()}get taruqaConfigStorageKey(){return d.getState().tenantId+"-taruqa-experiment-conf"}updateSearchRequest(e,r=!1){let n=(0,x.deepCopy)(this.store.getState().request);delete n.changedByConfiguration,this.store.actions.setRequest({...n,paging:{perPage:n.paging.perPage,page:r?1:n.paging.page},...e})}setQuery(e){this.updateSearchRequest({query:e},!0),this.setLiveQuery(e)}setContentLocale(e){var r,n;let s=(n=this.store.getState().locales)!==null&&n!==void 0?n:[],i=this.store.getState().request.contentLocale;if(e!=i){if(s.length>0){let a=o=>s.some(c=>c.lang==o);a(e)||(e=a(i)?i:s[0].lang)}this.updateSearchRequest({contentLocale:e,metadataFilters:[]},!0),this.canUpdateUiLocale&&(!((r=Ke.store.getState().localesConfiguration)===null||r===void 0)&&r.searchLanguageSetsUiLanguage)&&e&&Ke.requestUiLocaleUpdate(e,e)}return e}forceContentLocale(e){this.updateSearchRequest({contentLocale:e})}setPageSize(e){let r=this.store.getState().request;this.updateSearchRequest({paging:{...r.paging,perPage:isNaN(e)?20:(0,x.minmax)(1,e,1e3)}})}setPageNumber(e){let r=this.store.getState().request;this.updateSearchRequest({paging:{...r.paging,page:isNaN(e)?1:Math.max(1,e)}})}get sortOptions(){var e,r;return(r=(e=this.store.getState().configuration)===null||e===void 0?void 0:e.sortOptions)!==null&&r!==void 0?r:[]}setSort(e){this.updateSearchRequest({sort:e},!0)}setSortId(e,r=!1){var n;let s=r?{changedByConfiguration:!0}:{};if(e==null||this.sortOptions.length==0)return this.updateSearchRequest({sortId:e,...s},!0),e;let i=(n=this.sortOptions.find(a=>a.id==e))!==null&&n!==void 0?n:this.sortOptions[0];return this.updateSearchRequest({sortId:i.id,...s},!0),i.id}setFilters(e){let r=e.filter(n=>!n.valueFilter||n.valueFilter.values.length>0);this.updateSearchRequest({metadataFilters:r},!0)}setClusterSortCriterion(e){this.updateSearchRequest({clusterSortCriterions:e})}setSearchInDocumentTitlesOnly(e){e?this.updateSearchRequest({virtualField:Te.TITLE_ONLY,scope:be.DOCUMENTS},!0):this.updateSearchRequest({virtualField:Te.EVERYWHERE,scope:be.DEFAULT},!0)}setKeywordMatch(e){this.updateSearchRequest({keywordMatch:e},!0)}setVirtualField(e){this.updateSearchRequest({virtualField:e},!0)}get searchInDocumentTitlesOnly(){return Aa(this.store.getState())}get keywordMatch(){return Ta(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.dispatchEvent(new Ge)}addFacet(e){this.facetIds=[...this.facetIds,e]}replaceFacet(e,r){let n=this.facetIds.filter(s=>s!=e);r&&n.push(r),this.facetIds=n}get facetIds(){var e;let r=this.store.getState().request;return[...new Set([...r.facets.map(n=>n.id),...((e=r.metadataFilters)!==null&&e!==void 0?e:[]).map(n=>n.key)])]}set facetIds(e){let n=[...new Set(e)].map(s=>({id:s}));this.updateSearchRequest({facets:n})}addPropagatedFacet(e){let r=new Set(this.store.getState().propagatedFacets);r.add(e),this.store.actions.propagatedFacets([...r])}setFilter(e,r){this.setValueFilter(e,r)}setValueFilter(e,r){let n=this.store.getState().request.metadataFilters,s={key:e,valueFilter:{values:r,negative:!1}},i=[...n.filter(a=>!a.valueFilter),...n.filter(a=>a.valueFilter&&a.key!==s.key),s];this.setFilters(i)}setDateFilter(e,r){let n=this.store.getState().request.metadataFilters,s={key:e,dateFilter:{type:r}},i=[...n.filter(a=>!a.dateFilter),...n.filter(a=>a.dateFilter&&a.key!==s.key),s];this.setFilters(i)}removeDateFilter(e){let r=this.store.getState().request.metadataFilters,n=[...r.filter(s=>!s.dateFilter),...r.filter(s=>s.dateFilter&&s.key!==e)];this.setFilters(n)}setRangeFilter(e,r,n){let s=this.store.getState().request.metadataFilters,i={key:e,rangeFilter:{from:r,to:n}},a=[...s.filter(o=>!o.rangeFilter),...s.filter(o=>o.rangeFilter&&o.key!==i.key),i];this.setFilters(a)}removeRangeFilter(e){let r=this.store.getState().request.metadataFilters,n=[...r.filter(s=>!s.rangeFilter),...r.filter(s=>s.rangeFilter&&s.key!==e)];this.setFilters(n)}setLiveQuery(e){this.store.actions.liveQuery(e)}setRequest(e){this.updateSearchRequest({...e,facets:this.store.getState().request.facets},!0),this.setLiveQuery(e.query)}setScope(e){this.updateSearchRequest({scope:e})}setOtherQueryParams(e){this.updateSearchRequest({otherQueryParams:e})}setIgnoreEmptyQuery(e){this.ignoreEmptyQuery=e}setOpenExternalDocumentInNewTab(e){this.openExternalDocumentInNewTab=e}setCanUpdateUiLocale(e){this.canUpdateUiLocale=e}setApplyStickyFilters(e){this.applyStickyFilters=e,this.launchSearch(),this.launchSuggest()}addRecentQuery(e){this.history.addRecentQuery(e)}removeRecentQuery(e){this.history.removeRecentQuery(e)}updateLocales(){return this.localesDebouncer.run(async()=>this.store.actions.locales((await this.service.getAvailableSearchLocales()).contentLocales))}async fetchSearchData(e){var r,n,s,i,a;if((r=this.cancelableSearch)===null||r===void 0||r.cancel(),!!this.isRequestNeeded(ze.CLUSTERED_SEARCH))try{if(this.store.actions.paging(void 0),this.ignoreEmptyQuery&&e.query.length==0)this.store.actions.results(void 0),this.store.actions.announcements(void 0),this.store.actions.facets(void 0),this.store.actions.spellcheck(void 0);else{!((n=this.store.getState().results)===null||n===void 0)&&n.length||this.store.actions.results(void 0),this.cancelableSearch=(0,x.cancelable)(this.service.launchSearch(e));let o=await this.cancelableSearch;if(this.store.actions.announcements(o.announcements),o.paging.currentPage<=1)this.store.actions.results(o.results),this.store.actions.facets(o.facets),this.store.actions.spellcheck(o.spellcheck);else{let c=((i=this.store.getState().results)!==null&&i!==void 0?i:[]).concat(o.results);this.store.actions.results(c),this.store.commands.clear(/^focus-result-/),this.store.commands.add({type:`focus-result-${(o.paging.currentPage-1)*((a=e.paging.perPage)!==null&&a!==void 0?a:20)+1}`})}this.store.actions.paging(o.paging)}}catch(o){o instanceof x.CanceledPromiseError||(console.error(o),(s=this.errorHandler)===null||s===void 0||s.call(this,o))}}async fetchSuggestData(e){var r;try{if((r=this.cancelableSuggest)===null||r===void 0||r.cancel(),e.input.length<3){this.store.actions.suggestResults([]);return}this.cancelableSuggest=(0,x.cancelable)(this.service.launchSuggest(e));let n=await this.cancelableSuggest;this.store.actions.suggestResults(n.suggestions)}catch(n){!(n instanceof x.CanceledPromiseError)&&this.errorHandler&&this.errorHandler(n)}}clear(){this.store.clear()}clearResults(){this.store.actions.paging(void 0),this.store.actions.results(void 0),this.store.actions.announcements(void 0),this.store.actions.facets(void 0),this.store.actions.spellcheck(void 0)}};var Vr=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},jr=class extends CustomEvent{constructor(e){super("register-ft-search-component",{bubbles:!0,composed:!0,detail:{registrationId:e}})}},Xs=Symbol("registerInterval"),qr=Symbol("registerAttempts"),ba=40,_a=(0,ke.applyMixinOnce)(Symbol("toFtSearchComponent"),function(t){class e extends t{constructor(){super(...arguments),this.neededSearchRequests=[]}willUpdate(n){var s,i,a;super.willUpdate(n),n.has("neededSearchRequests")&&((s=this.stateManager)===null||s===void 0||s.unregisterComponent(this,(a=n.get("neededSearchRequests"))!==null&&a!==void 0?a:[]),(i=this.stateManager)===null||i===void 0||i.registerComponent(this,this.neededSearchRequests))}setSearchStateManager(n){this.clearStateManager(),this.stateManager=n,this.stateManager.registerComponent(this,this.neededSearchRequests),this.addStore(n.store,"search")}clearStateManager(){this.stateManager&&(this.stateManager.unregisterComponent(this,this.neededSearchRequests),this.removeStore(this.stateManager.store),this.stateManager=void 0)}connectedCallback(){super.connectedCallback(),this[qr]=0,this.tryToRegisterToContext(),this[Xs]=window.setInterval(()=>this.tryToRegisterToContext(),50)}tryToRegisterToContext(){this.stateManager!=null||this[qr]>ba?window.clearInterval(this[Xs]):(this[qr]++,this.dispatchEvent(new jr(this.searchRegistrationId)))}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return Vr([(0,Qe.state)()],e.prototype,"stateManager",void 0),Vr([(0,Qe.state)({hasChanged:ke.hasChanged})],e.prototype,"neededSearchRequests",void 0),Vr([(0,Qe.property)()],e.prototype,"searchRegistrationId",void 0),e}),Js=class extends _a(ke.FtLitElementRedux){};var sr=f(b());function tr(t){return t.filter(e=>e.key==="ft:lastEdition").filter(e=>!e.valueFilter).map(e=>e.dateFilter?e.dateFilter.type:"CUSTOM").shift()}function rr(t){var e,r;return t.dateFilter?{key:t.key,type:"DATE",dateValue:t.dateFilter.type}:t.rangeFilter?{key:t.key,type:"RANGE",from:t.rangeFilter.from,to:t.rangeFilter.to}:{key:t.key,values:(e=t.valueFilter)===null||e===void 0?void 0:e.values,negative:(r=t.valueFilter)===null||r===void 0?void 0:r.negative}}var nr=class{constructor(e,r){this.store=e,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.enableAnalyticsEvents=!0,this.appName=void 0,this.appVersion=void 0,this.document=void 0,this.sendEvent=([n,s])=>{if(!this.canSendEvent()||!n||!s)return;let i=this.store.getState().request;this.document==null?this.sendKhubSearchEvent(i,n,s):this.sendDocumentSearchEvent(i,n,s)},this.eventsService=r??new Me,this.resultsWatcher=(0,sr.watch)(e,n=>[n.results,n.paging],this.sendEvent)}setEnableAnalyticsEvents(e){this.enableAnalyticsEvents=e}setAppName(e){this.appName=e}setAppVersion(e){this.appVersion=e}setDocumentSearch(e){this.document=e}setDocumentSearchFromMap(e){this.setDocumentSearch(this.eventsService.convertMapToAnalyticsDocument(e))}initAppInfo(){let{apiIntegrationIdentifier:e,apiIntegrationAppVersion:r}=d.getState();this.setAppName(e??"unknown"),this.setAppVersion(r??"unknown")}canSendEvent(){if(this.appName==null||this.appVersion==null)return console.debug("ft-search-context.eventManager is not initialized. No events will be sent!"),!1;let{editorMode:e}=d.getState();return this.enableAnalyticsEvents&&!e}sendKhubSearchEvent(e,r,n){let s={offline:!1,appVersion:this.appVersion,appName:this.appName,name:he.KHUB__SEARCH,searchResponse:{autocorrect:this.store.getState().spellcheck!=null,nbResults:n.totalClustersCount},searchQuery:{terms:e.query,searchType:e.virtualField,lastUpdate:tr(e.metadataFilters),facets:e.metadataFilters.map(i=>rr(i))}};this.eventsService.sendKhubSearchEvent(s)}sendDocumentSearchEvent(e,r,n){if(e.metadataFilters.find(i=>{var a;return i.key==="ft:publicationId"&&((a=i.valueFilter)===null||a===void 0?void 0:a.values[0])===this.document.id})!==void 0){let i={offline:!1,appVersion:this.appVersion,appName:this.appName,name:he.DOCUMENT__SEARCH,searchResponse:{autocorrect:this.store.getState().spellcheck!=null,nbResults:n.totalClustersCount},searchQuery:{terms:e.query},document:this.document};this.eventsService.sendDocumentSearchEvent(i)}}sendResultClickedEvent(e,r){if(!this.canSendEvent())return;let n=this.store.getState().request,s;e.type==J.TOPIC&&(s={tocId:e.topic.tocId,title:e.topic.title});let i={offline:!1,appVersion:this.appVersion,appName:this.appName,name:he.SEARCH_PAGE__SELECT,searchQuery:{terms:n.query,searchType:n.virtualField,lastUpdate:tr(n.metadataFilters),facets:n.metadataFilters.map(a=>rr(a))},searchResult:{rank:r,type:e.type,document:this.convertDocument(e),topic:s},externalLink:this.convertExternalLink(e)};this.eventsService.sendSearchPageSelectEvent(i)}sendResultContextMenuOpenedEvent(e,r){if(!this.canSendEvent())return;let n=this.store.getState().request,s;e.type==J.TOPIC&&(s={tocId:e.topic.tocId,title:e.topic.title});let i={offline:!1,appVersion:this.appVersion,appName:this.appName,name:he.SEARCH_RESULT__OPEN_BROWSER_CONTEXT_MENU,searchQuery:{terms:n.query,searchType:n.virtualField,lastUpdate:tr(n.metadataFilters),facets:n.metadataFilters.map(a=>rr(a))},searchResult:{rank:r,type:e.type,document:this.convertDocument(e),topic:s},externalLink:this.convertExternalLink(e)};this.eventsService.sendSearchResultOpenContextMenuEvent(i)}convertDocument(e){switch(e.type){case J.MAP:return{id:e.map.mapId,title:e.map.title,type:ce.STRUCTURED_DOCUMENT,metadata:e.map.metadata};case J.TOPIC:return{id:e.topic.mapId,title:e.topic.mapTitle,type:ce.STRUCTURED_DOCUMENT,metadata:e.topic.metadata};case J.DOCUMENT:return{id:e.document.documentId,title:e.document.title,type:ce.UNSTRUCTURED_DOCUMENT,metadata:e.document.metadata,mimeType:e.document.mimeType};case J.HTML_PACKAGE:return{id:e.htmlPackage.packageId,title:e.htmlPackage.title,type:ce.HTML_PACKAGE,metadata:e.htmlPackage.metadata};case J.HTML_PACKAGE_PAGE:return{id:e.htmlPackagePage.packageId,title:e.htmlPackagePage.title,type:ce.HTML_PACKAGE,metadata:e.htmlPackagePage.metadata};default:throw new TypeError("Unknown type "+e.type)}}convertExternalLink(e){var r;return(r=(0,sr.accessResult)(e))===null||r===void 0?void 0:r.originUrl}};var O=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},v=class extends q.FtLitElementRedux{get stateManager(){if(this._stateManager==null){let e=this.searchServiceProvider?this.searchServiceProvider():void 0;this._stateManager=We.build(this.id||(""+Math.round(Math.random()*999e3)).padStart(6,"0"),e),this._stateManager.errorHandler=r=>this.handleLoadError(r),this.addStore(this.stateManager.store,"search")}return this._stateManager}get eventManager(){return this._eventManager==null&&(this._eventManager=new nr(this.stateManager.store)),this._eventManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.applyStickyFilters=!1,this.openExternalDocumentInNewTab=!1,this.filters=[],this.sort=[],this.otherQueryParams={},this._appIntegrationInfoReady=!1,this.addStore(d)}render(){return Zs.html`
4
+ `}connectedCallback(){super.connectedCallback(),this.stateManager.addListeners(),this.contextRoot.attach(document.body)}disconnectedCallback(){super.disconnectedCallback(),this.stateManager.removeListeners(),this.contextRoot.detach(document.body)}update(e){var r;super.update(e),e.has("baseUrl")&&this.stateManager.setBaseUrl(this.baseUrl),e.has("tenantId")&&this.stateManager.setTenantId(this.tenantId),e.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),e.has("apiIntegrationAppVersion")&&this.stateManager.setApiIntegrationAppVersion(this.apiIntegrationAppVersion),e.has("uiLocale")&&this.stateManager.setUiLocale(this.uiLocale),e.has("metadataConfiguration")&&this.stateManager.setMetadataConfiguration(this.metadataConfiguration),e.has("noCustom")&&this.stateManager.setNoCustom(this.noCustom),e.has("editorMode")&&this.stateManager.setEditorMode(this.editorMode),e.has("noCustomComponent")&&this.stateManager.setNoCustomComponent(this.noCustomComponent),e.has("noCustomCode")&&this.stateManager.setNoCustomCode(this.noCustomCode),e.has("session")&&this.stateManager.setSession(this.session),e.has("messageContexts")&&this.messageContexts!=null&&this.messageContexts.forEach(n=>ks.addContext(n)),e.has("openExternalDocumentInNewTab")&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("navigatorOnline")&&this.stateManager.setNavigatorOnline(this.navigatorOnline),e.has("forcedOffline")&&this.stateManager.setForcedOffline(this.forcedOffline),e.has("authenticationRequired")&&this.stateManager.setAuthenticationRequired(this.authenticationRequired),e.has("withManualResources")&&((r=this.stateManager)===null||r===void 0||r.setWithManualResources(this.withManualResources)),setTimeout(()=>this.stateManager.updateIfNeeded())}};b.elementDefinitions={};b.styles=Us;k([(0,q.property)()],b.prototype,"baseUrl",void 0);k([(0,q.property)()],b.prototype,"tenantId",void 0);k([(0,q.property)()],b.prototype,"apiIntegrationIdentifier",void 0);k([(0,q.property)()],b.prototype,"apiIntegrationAppVersion",void 0);k([(0,q.property)()],b.prototype,"uiLocale",void 0);k([(0,Ae.jsonProperty)(null)],b.prototype,"availableUiLocales",void 0);k([(0,Ae.jsonProperty)(null)],b.prototype,"metadataConfiguration",void 0);k([(0,q.property)({type:Boolean})],b.prototype,"editorMode",void 0);k([(0,q.property)({type:Boolean})],b.prototype,"noCustom",void 0);k([(0,q.property)({type:Boolean})],b.prototype,"openExternalDocumentInNewTab",void 0);k([(0,q.property)({converter:{fromAttribute(t){return t==="false"?!1:t==="true"||(t??!1)}}})],b.prototype,"noCustomComponent",void 0);k([(0,q.property)({converter:{fromAttribute(t){return t==="false"?!1:t==="true"||(t??!1)}}})],b.prototype,"noCustomCode",void 0);k([(0,q.property)({type:Boolean})],b.prototype,"withManualResources",void 0);k([(0,q.property)({type:Boolean})],b.prototype,"navigatorOnline",void 0);k([(0,q.property)({type:Boolean})],b.prototype,"forcedOffline",void 0);k([(0,q.property)({type:Boolean})],b.prototype,"authenticationRequired",void 0);k([(0,Ae.jsonProperty)([])],b.prototype,"messageContexts",void 0);k([(0,Ae.jsonProperty)(void 0)],b.prototype,"session",void 0);var js=f(T());var qs={"ft-app-context":b};(0,js.customElements)(qs);var qt=f(T()),Vt=class extends M{get metadataFilters(){return this._metadataFilters}set metadataFilters(e){this._metadataFilters=e}get mapId(){return this._mapId}set mapId(e){e!==this._mapId&&this.clear(),this._mapId=e}constructor(e,r,n,s){super(!1,r),this.converter=e,this._mapId=n,this._metadataFilters=s,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(this.makeCacheKey("enrichedToc",void 0,this.metadataFilters),()=>this.withMapId(e=>this.fetchPages(e,this._metadataFilters).then(r=>this.converter.convertPaginatedToc(e,r)))),this.cache.register("ratingSummary",()=>{var e,r;return W((r=(e=d.getState().session)===null||e===void 0?void 0:e.profile.roles)!==null&&r!==void 0?r:[],"RATING_USER")?this.withMapId(s=>this.fetchMapRating(s)):Promise.resolve()})}clear(){this.cache.clearMatching(e=>e!=="configuration")}makeCacheKey(e,r,n){return e+(r?"-destinationLanguage-"+r?.destinationLanguage:"")+(!n||n.length==0?"":"-metadataFilters-"+this.hash(n))}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.metadataFilters),()=>this.fetchPages(this.mapId,this.metadataFilters,e).then(r=>this.converter.convertPaginatedToc(this.mapId,r)))}getEnrichedTocNow(e){return this.cache.getNow(this.makeCacheKey("enrichedToc",e,this.metadataFilters))}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 getFilteredTocNodes(e){var r;return(r=(await this.getEnrichedToc(e)).filteredTocNodes)!==null&&r!==void 0?r:{}}async getTocNode(e,r){return(await this.getEnrichedToc(r)).nodeByTocId[e]}getTocNodeNow(e,r){var n;return(n=this.getEnrichedTocNow(r))===null||n===void 0?void 0:n.nodeByTocId[e]}getTocNodeNowByUrl(e,r){var n,s;let i=this.getMapNow(r);return i?.prettyUrl==e||`${i?.id}/root`===e?(n=this.getEnrichedTocNow(r))===null||n===void 0?void 0:n.toc[0]:(s=this.getEnrichedTocNow(r))===null||s===void 0?void 0:s.nodeByUrl[e]}async getPage(e,r){let n=await this.getEnrichedToc(r);return n.pages[e-1]||n.pages[0]}async getPageByTocId(e,r){let n=await this.getEnrichedToc(r);return n.pageByTocId[e]||n.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))}async getTopicMetadataValue(e,r){let n=this.getTocNodeNow(e);if(!n)return;let s=await this.getTopicInfo(n);return s?.metadata.find(i=>i.key==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,n){return this.cache.get("topic-relatives-"+[e,r,...n].join("-"),()=>this.fetchRelativesForTopicInMap(e,r,n))}getAttachmentDownloadLink(e){return this.makeAbsolute(`${this.api.endpoints.khub.maps.mapId(this.mapId).attachments.attachmentId(e).content}?download=true&locationValue=reader`)}getLink(e,r,n,s){let i=this.getNavigationData(e,r,n),a=this.getReaderLinkPrefix()+(i.prettyUrl?i.prettyUrl:`${i.mapId}/${i.tocId}`),o=new URL(a,this.api.tenantBaseUrl);if(i.page!=null&&o.searchParams.set("page",`${i.page}`),i.prettyUrlDuplicated&&o.searchParams.set("tocId",i.tocId),i.section!=null&&o.searchParams.set("section",i.section),s&&i.metadataFilters){let c=qt.SearchPlaceConverter.serializeValueFilters(i.metadataFilters);c&&o.searchParams.set(qt.SearchPlaceQueryParams.VALUE_FILTERS,c)}return o.href}getLinkWithFilter(e,r,n){return this.getLink(e,r,n,!0)}getNavigationData(e,r,n,s){var i,a;e=e||"root";let o=this.getEnrichedTocNow(s),c=o?.pageByTocId[e],l=o?.nodeByTocId[e],u=l?.prettyUrl;return{mapId:this.mapId,tocId:e,topicTitle:(i=l?.title)!==null&&i!==void 0?i:"",untranslatedTopicTitle:l?.untranslatedTitle,page:r&&c&&c.number!==r?r:void 0,prettyUrl:u?.replace(/^r\//,""),prettyUrlDuplicated:(a=o?.duplicatedPrettyUrls.has(u??""))!==null&&a!==void 0?a:!1,section:n,metadataFilters:this.metadataFilters}}async getAccurateNavigationData(e,r,n,s){return await this.getEnrichedToc(s),this.getNavigationData(e,r,n,s)}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 n;return r?{type:r.topics.type,rating:(n=r.topics)===null||n===void 0?void 0:n.ratings.find(s=>s.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,n){return this.makeRateTopicRequest(e,r,n).then(()=>this.clearRatingIfNecessary())}unrateTopic(e){return this.makeUnrateTopicRequest(e).then(()=>this.clearRatingIfNecessary())}async clearRatingIfNecessary(){let e=d.getState().session;e?.sessionAuthenticated&&this.cache.clear("ratingSummary")}sendTopicFeedback(e,r,n,s){return this.makeTopicFeedbackRequest(e,r,n,s)}fontsStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.fonts)}themeStylesheet(){return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme)}buildBreadcrumb(e,r){let n=this.getTocNodeNow(e,r);if(!n)return[];let s=[{tocId:n.tocId,title:n.title,untranslatedTitle:n.untranslatedTitle}],i=this.getTocNodeNow(n.parentTocId,r);for(;i;)s.unshift({tocId:i.tocId,title:i.title,untranslatedTitle:i.untranslatedTitle}),i=this.getTocNodeNow(i.parentTocId,r);return s}isFeatureAccessible(e,{session:r}){var n;if(!this.isFeatureAvailable(e))return!1;switch(e){case ne.FEEDBACK:return W(r??[],A.FEEDBACK_USER);case ne.RATING:return W(r??[],A.RATING_USER);case ne.PRINT:return W(r??[],A.PRINT_USER);case ne.BOOKMARK:return!!r?.sessionAuthenticated;case ne.COLLECTIONS:return W(r??[],A.COLLECTION_USER);case ne.PERSONAL_BOOKS:return W(r??[],A.PERSONAL_BOOK_USER)&&!(!((n=this.getMapNow())===null||n===void 0)&&n.pbkConfidential);default:return!1}}makeAbsolute(e){return this.api.makeAbsolute(e)}};var jt=class t extends Vt{static async build(e){return new t(new Je,void 0,e)}clear(){super.clear(),this.fingerprint=void 0}async fetchMap(e,r){let n=await this.api.getMap(e,r);return this.fingerprint=n.fingerprint,n}fetchMapRating(e){return this.api.getMapRating(e)}async fetchPages(e,r,n){return await this.getMap(n),r?.length?this.api.getFilteredPages(e,n,r):this.api.getPages(e,this.fingerprint,n)}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 n={query:"",paging:{page:1,perPage:-1},scope:"DOCUMENTS",metadataFilters:[{key:e,valueFilter:{negative:!1,values:r}}],sort:[],facets:[]};return this.api.search(n)}fetchRelativesForTopicInMap(e,r,n){let s={query:"",paging:{page:1,perPage:1},scope:"ALL_TOPICS",metadataFilters:[{key:r,valueFilter:{negative:!1,values:n}},{key:"ft:publicationId",valueFilter:{negative:!1,values:[e]}}],sort:[],facets:[]};return this.api.search(s)}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,n){return this.api.rateTopic(this.mapId,e,r,n)}makeTopicFeedbackRequest(e,r,n,s){return this.api.sendTopicFeedback(this.mapId,e,r,n,s)}makeUnrateMapRequest(){return this.api.unrateMap(this.mapId)}makeUnrateTopicRequest(e){return this.api.unrateTopic(this.mapId,e)}getReaderLinkPrefix(){return"r/"}isFeatureAvailable(e){return!0}};var va="topicPivot";function Hs(t,e){let r=new URL(t);return e?.values.forEach(n=>{r.searchParams.append(va,n)}),r.href}var Ht=class t{static build(e,r){return new t(Yr(e.trim()||"context"),r??jt.build)}loaded(){return(0,P.waitUntil)(()=>this._loaded)}constructor(e,r,n,s){this.store=e,this.clusteringHelperProvider=n,this.metadataForSwitchToRelatives=new Set,this._loaded=!1,this.loadDebouncer=new P.Debouncer(10),this.analyticsEventsService=s??new Me,this.initService(r)}async initService(e){this.service=await e();let{mapId:r,metadataFilters:n}=this.store.getState();return this.service.mapId=r,this.service.metadataFilters=n,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 setFilters(e){(0,P.deepEqual)(e,this.store.getState().metadataFilters)||(this.store.actions.metadataFilters(e),this.service&&(this.service.metadataFilters=e))}async awaitService(){return(0,P.waitFor)(()=>this.service)}async navigateToTopic(e,r,n){await this.loaded();let s=await this.resolvePage(e,n);this.store.actions.currentPage(s);let i=this.resolveValidNonRootTocId(e,s);this.store.actions.scrollTarget({tocId:i,section:r}),this.store.getState().visibleTopics[0]!==i&&this.store.actions.visibleTopics([]),e&&!r&&(this.store.commands.clear(/^focus-topic-/),this.store.commands.add({type:`focus-topic-${e}`}))}async resolvePage(e,r){var n,s,i;let a=await this.awaitService();if(r)return a.getPage(r,this.getTranslationSettings());if(!e)return a.getPageByTocId("root",this.getTranslationSettings());let o=(n=this.store.getState().filteredTocNodes)===null||n===void 0?void 0:n[e],c=((s=this.service)===null||s===void 0?void 0:s.getTocNodeNow(e))!=null;return o&&o.reason!=="ACCESS_RIGHTS_FILTER"&&!c?a.getPageByTocId((i=o.closestParent)!==null&&i!==void 0?i:"root",this.getTranslationSettings()):a.getPageByTocId(e,this.getTranslationSettings())}resolveValidNonRootTocId(e,r){var n,s,i,a,o;let c=(s=e==="root"?void 0:e)!==null&&s!==void 0?s:r.rootTocId;if(!r.topics.includes(c)){if(e!="root"&&!r.hiddenTopics.includes(c)){let l=this.store.getState().filteredTocNodes[c];if(l){this.store.dispatchEvent(new Xe(l));let u=((n=this.service)===null||n===void 0?void 0:n.getTocNodeNow(l.tocId))!=null;return l.reason==="ACCESS_RIGHTS_FILTER"||u?l.tocId:(i=l.closestParent)!==null&&i!==void 0?i:"root"}this.store.dispatchEvent(new CustomEvent(de.requestedTopicNotFound))}return(o=(a=r.topics[0])!==null&&a!==void 0?a:r.hiddenTopics[0])!==null&&o!==void 0?o:"root"}return c}async navigateToPage(e){await this.loaded();let n=await(await this.awaitService()).getPage(e,this.getTranslationSettings());this.store.actions.currentPage(n)}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())}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()}clearFromFilter(){this._loaded=!1,this.store.actions.toc(void 0),this.store.actions.pagesToc(void 0)}async reloadFromFilter(e,r){var n,s,i;this.clearFromFilter();let{scrollTarget:a,visibleTopics:o,currentPage:c}=this.store.getState(),l=(i=(s=(n=a?.tocId)!==null&&n!==void 0?n:o?.[0])!==null&&s!==void 0?s:c?.rootTocId)!==null&&i!==void 0?i:"root";await this.fetchDataFromFilter(),this.navigateToTopic(l,e,r)}async fetchDataFromFilter(){var e,r,n,s;let i=this.getTranslationSettings();try{await Promise.all([(e=this.service)===null||e===void 0?void 0:e.getToc(i).then(a=>this.store.actions.toc(a)),(r=this.service)===null||r===void 0?void 0:r.getPagesToc(i).then(a=>this.store.actions.pagesToc(a)),(n=this.service)===null||n===void 0?void 0:n.getFilteredTocNodes(i).then(a=>this.store.actions.filteredTocNodes(a))]),this._loaded=!0}catch(a){if(!(a instanceof P.CanceledPromiseError))throw i&&this.setTranslationError(!0),(s=this.errorHandler)===null||s===void 0||s.call(this,a),a}}async fetchData(){var e,r,n,s,i,a,o;let c=this.getTranslationSettings();try{c&&this.setTranslationLoading(!0),await Promise.all([this.loadConfiguration(),(e=this.service)===null||e===void 0?void 0:e.getMap(c).then(l=>this.store.actions.map(l)),(r=this.service)===null||r===void 0?void 0:r.getToc(c).then(l=>this.store.actions.toc(l)),(n=this.service)===null||n===void 0?void 0:n.getPagesToc(c).then(l=>this.store.actions.pagesToc(l)),(s=this.service)===null||s===void 0?void 0:s.getPaginationConfiguration().then(l=>this.store.actions.paginationConfiguration(l)),(i=this.service)===null||i===void 0?void 0:i.getFilteredTocNodes(c).then(l=>this.store.actions.filteredTocNodes(l)),(a=this.service)===null||a===void 0?void 0:a.getTranslationError(c).then(l=>this.setTranslationError(l))]),this.metadataForSwitchToRelatives.size>0&&this.fetchRelatives(),this._loaded=!0,c&&this.setTranslationLoading(!1)}catch(l){if(!(l instanceof P.CanceledPromiseError))throw c&&this.setTranslationError(!0),(o=this.errorHandler)===null||o===void 0||o.call(this,l),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()}async fetchRelatives(){var e,r;let n=(e=this.store.getState().map)===null||e===void 0?void 0:e.metadata.filter(s=>{var i;return s.key==((i=this.store.getState().configuration)===null||i===void 0?void 0:i.relativePivotMetadata)}).flatMap(s=>s.values);if(n!==void 0&&n.length>0){let s=await((r=this.service)===null||r===void 0?void 0:r.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata,n)),i=s?.results.flatMap(a=>a.entries);this.store.actions.relatives(i)}this.updateClusteringHelper()}updateClusteringHelper(){this.clusteringHelper=this.createClusteringHelper(),this.clusteringHelper&&this.store.dispatchEvent(new Event(de.clusteringHelperCreated))}createClusteringHelper(){var e,r;if(this.clusteringHelperProvider)return this.clusteringHelperProvider();let n=this.store.getState().relatives;if(n){let s=n.find(a=>{var o;return((o=a.map)===null||o===void 0?void 0:o.mapId)==this.store.getState().mapId}),i=(r=(e=d.getState().metadataConfiguration)===null||e===void 0?void 0:e.descriptors)!==null&&r!==void 0?r:[];return new P.ClusteringHelper(n,s,this.metadataForSwitchToRelatives,i)}}async navigateToRelativeTopicIfFound(e){var r,n,s;await this.loaded();let i=await(0,P.waitFor)(()=>{var l;return(l=this.store.getState().configuration)===null||l===void 0?void 0:l.relativeTopicPivotMetadata}),a=this.store.getState().mapId,c=await(await this.awaitService()).getRelativesForTopicInMap(a,i,[e]);if(!((s=(n=(r=c?.results)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.entries)===null||s===void 0)&&s[0]){let l=c.results[0].entries[0].topic.tocId;return await this.navigateToTopic(l),!0}else return await this.navigateToTopic("root"),!1}setSearchInDocumentQuery(e){this.store.actions.searchInDocumentQuery(e)}async setTranslationDestinationLanguage(e){this.store.actions.setTranslationDestinationLanguage(e),e&&this.sendDocumentOnDemandTranslateEvent(e),await this.loadDebouncer.run(()=>this.fetchData())}async setTranslationSourceLanguage(e){this.store.actions.setTranslationSourceLanguage(e),await this.loadDebouncer.run(()=>this.fetchData())}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.linkPreviewDialogId(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 n=await((r=this.service)===null||r===void 0?void 0:r.getTopicRating(e));n&&this.store.actions.setTopicsRating({[e]:n})}registerMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.add(e),this.store.getState().relatives==null?this.fetchRelatives():this.updateClusteringHelper()}unregisterMetadataForSwitchToRelatives(e){this.metadataForSwitchToRelatives.delete(e),this.updateClusteringHelper()}async getAccurateNavigationData(e,r,n){return await this.awaitService(),this.service.getAccurateNavigationData(e,r?.number,n?.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,n;let s=this.getTranslationSettings();return s?(this.sendTopicAiTranslateEvent(s.destinationLanguage,e),(r=this.service)===null||r===void 0?void 0:r.getTranslatedTopicContent(e,s).then(i=>(i.isTranslationError&&this.setTranslationError(!0),i.content))):(n=this.service)===null||n===void 0?void 0:n.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(de.mapAttachmentsUpdate))}async getRelativeDocumentUrlForLocale(e){var r,n,s;this.store.getState().relatives==null&&await this.fetchRelatives();let i=P.ClusteringHelper.findResultWithMetadataValue((s=this.store.getState().relatives)!==null&&s!==void 0?s:[],"ft:locale",e),a=(0,P.accessResultUrl)(i);if(a){let o=this.store.getState().visibleTopics[0],c=(r=this.store.getState().configuration)===null||r===void 0?void 0:r.relativeTopicPivotMetadata;if(c&&o){let l=await((n=this.service)===null||n===void 0?void 0:n.getTopicMetadataValue(o,c));a=Hs(a,l)}}return a}sendDocumentOnDemandTranslateEvent(e){var r;let{editorMode:n,apiIntegrationIdentifier:s,apiIntegrationAppVersion:i}=d.getState(),a=this.store.getState(),o=a.map,c=a.translation.profileId;if(!(n||!o||!s||!i||!c))try{let u={...this.analyticsEventsService.convertMapToAnalyticsDocument(o),title:(r=o.untranslatedTitle)!==null&&r!==void 0?r:o.title};this.analyticsEventsService.sendDocumentOnDemandTranslateEvent({name:"DOCUMENT__ON_DEMAND_TRANSLATE",offline:!1,appName:s,appVersion:i,sourceLanguage:this.parseLanguageToAnalyticsFormat(o.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e.code),profileId:c,document:u,translationOrigin:Ze.AI})}catch(l){console.warn("Failed to send on-demand document translate event:",l)}}sendTopicAiTranslateEvent(e,r){var n;let{editorMode:s,apiIntegrationIdentifier:i,apiIntegrationAppVersion:a}=d.getState(),o=this.store.getState(),c=o.map,l=o.translation.profileId;if(!(s||!c||!i||!a||!l))try{let u=this.buildBreadcrumb(r.tocId);if(!u){console.warn("Failed to build breadcrumb for topic ai translate event");return}let p={...this.analyticsEventsService.convertMapToAnalyticsDocument(c),title:(n=c.untranslatedTitle)!==null&&n!==void 0?n:c.title};this.analyticsEventsService.sendTopicAiTranslateEvent({name:"TOPIC__AI_TRANSLATE",offline:!1,appName:i,appVersion:a,sourceLanguage:this.parseLanguageToAnalyticsFormat(c.lang),destinationLanguage:this.parseLanguageToAnalyticsFormat(e),breadcrumb:u.map(E=>{var S;return{tocId:E.tocId,title:(S=E.untranslatedTitle)!==null&&S!==void 0?S:E.title}}),document:p,profileId:l})}catch(u){console.warn("Failed to send topic ai translate event:",u)}}parseLanguageToAnalyticsFormat(e){if(!e)return;let r=e.split("-");return r.length===2?{languageCode:r[0],countryCode:r[1]}:{languageCode:r[0],countryCode:""}}};var $s=f(oe());var Ks=$s.css`
5
+ `;var $t=class extends CustomEvent{constructor(e,r){super("ft-reader-map-loaded",{detail:{map:e,toc:r}})}},Kt=class extends CustomEvent{constructor(e,r){super("ft-reader-visible-topics-change",{detail:{visibleTopics:r}})}},zt=class extends CustomEvent{constructor(e){super("ft-reader-navigation-done",{detail:e})}},Gt=class extends CustomEvent{constructor(e){super("ft-reader-load-error",{detail:e})}},Wt=class extends Event{constructor(){super("ft-reader-map-not-found")}},Qt=class extends Event{constructor(){super("ft-reader-map-unauthorized")}},Yt=class extends Event{constructor(){super("ft-reader-map-forbidden")}},Xt=class extends Event{constructor(){super("ft-reader-topic-relative-not-found",{bubbles:!0,composed:!0})}};var zs=f(oe());var Gs=zs.css`
6
+ `;var Js=f(oe()),Y=f(re()),j=f(T());var ke=f(T()),Qe=f(re());var ze;(function(t){t.CLUSTERED_SEARCH="CLUSTERED_SEARCH"})(ze||(ze={}));var C=f(T());var Ws=f(T()),Ea={setRequest:(t,e)=>{t.request=e.payload}},Qs=t=>Ws.FtReduxStore.get({name:"ft-search-"+t,initialState:{request:{query:"",clusterSortCriterions:[],metadataFilters:[],facets:[],sort:[],sortId:void 0,paging:{page:1,perPage:20},keywordMatch:void 0},liveQuery:"",recentQueries:[],paging:void 0,facets:void 0,spellcheck:void 0,locales:[],results:void 0,announcements:void 0,suggestResults:void 0,configuration:void 0,propagatedFacets:[]},reducers:Ea});var Jt=class extends M{constructor(e){super(!0,e),this.cache.registerFinal("search-configuration",async()=>(await this.awaitApi).getSearchConfiguration())}async launchSearch(e){let r={...e,metadataFilters:this.sortFilters(e.metadataFilters),facets:[...e.facets].sort((n,s)=>n.id.localeCompare(s.id))};return this.cache.get("search-"+this.hash(r),async()=>(await this.awaitApi).search(e),120*1e3)}async launchSuggest(e){let r={...e,metadataFilters:this.sortFilters(e.metadataFilters)};return this.cache.get("suggest-"+this.hash(r),async()=>(await this.awaitApi).getSuggestions(e),120*1e3)}async getAvailableSearchLocales(){return this.cache.get("available-locales",async()=>(await this.awaitApi).getAvailableSearchLocales())}async getConfiguration(){return this.cache.get("search-configuration")}sortFilters(e){return e.map(r=>r.valueFilter==null?r:{...r,valueFilter:{...r.valueFilter,values:[...r.valueFilter.values].sort((n,s)=>n.localeCompare(s))}}).sort((r,n)=>r.key.localeCompare(n.key))}};var Zt=class extends CustomEvent{constructor(e){super("ft-search-load-error",{detail:e,composed:!0,bubbles:!0})}},er=class extends CustomEvent{constructor(e){super("ft-search-request-change",{detail:e,composed:!0,bubbles:!0})}},tr=class extends CustomEvent{constructor(e,r,n){super("ft-search-results-change",{detail:{request:e,paging:r,spellcheck:n},composed:!0,bubbles:!0})}},Ge=class t extends Event{constructor(){super(t.eventName)}};Ge.eventName="search-context-clear-all-filters";var Sa=t=>t.request.virtualField===Te.TITLE_ONLY&&t.request.scope===be.DOCUMENTS,Aa=t=>t.request.keywordMatch==et.MANDATORY,We=class t extends C.FtStateManager{static build(e,r){return new t(Qs(e.trim()||"context"),r)}constructor(e,r){super(),this.store=e,this.ignoreEmptyQuery=!1,this.canUpdateUiLocale=!1,this.openExternalDocumentInNewTab=!1,this.applyStickyFilters=!1,this.history=new C.QueryHistoryStorage(this.store.actions.recentQueries),this.onNewNeededRequest=n=>{n==ze.CLUSTERED_SEARCH&&this.launchSearch()},this.onStorageEvent=n=>{n.key===this.taruqaConfigStorageKey&&this.loadTaruqaTemplate()},this.loadTaruqaTemplate=()=>{var n;let s;if(W(d.getState().session,A.DEBUG_USER)){let i=JSON.parse((n=window.localStorage.getItem(this.taruqaConfigStorageKey))!==null&&n!==void 0?n:"{}");s=i.overrideEnabled?i.template:void 0}this.updateSearchRequest({taruqaTemplateOverride:s,changedByConfiguration:!0})},this.localesDebouncer=new C.Debouncer(10),this.searchDebouncer=new C.Debouncer(100),this.launchSearch=n=>this.searchDebouncer.run(()=>this.fetchSearchData(n??this.buildSearchRequest())),this.buildSearchRequest=(n=this.store.getState())=>{var s;return{...n.request,facets:this.facetIds.map(i=>({id:i})),stickyFiltersId:this.applyStickyFilters?(s=d.getState().stickyFilters)===null||s===void 0?void 0:s.id:void 0}},this.suggestDebouncer=new C.Debouncer(1e3),this.launchSuggest=n=>this.suggestDebouncer.run(()=>this.fetchSuggestData(n??this.buildSuggestRequest())),this.buildSuggestRequest=(n=this.store.getState())=>{var s,i;return{input:n.liveQuery,metadataFilters:n.request.metadataFilters,sort:(i=n.request.sort)!==null&&i!==void 0?i:[],sortId:n.request.sortId,contentLocale:n.request.contentLocale,scope:n.request.scope,keywordMatch:n.request.keywordMatch,stickyFiltersId:this.applyStickyFilters?(s=d.getState().stickyFilters)===null||s===void 0?void 0:s.id:void 0}},this.service=r??new Jt,this.service.cache.addEventListener("clear-cache",n=>{n.detail.clearedKeys.includes("available-locales")&&this.updateLocales()}),this.searchWatcher=new C.ReduxWatcher(e,this.buildSearchRequest,this.launchSearch),this.suggestWatcher=new C.ReduxWatcher(e,this.buildSuggestRequest,this.launchSuggest),this.stickyFiltersIdWatcher=new C.ReduxWatcher(d,n=>{var s;return(s=n.stickyFilters)===null||s===void 0?void 0:s.id},()=>{this.applyStickyFilters&&(this.launchSearch(),this.launchSuggest())})}async initService(){return this.updateLocales(),this.service.getConfiguration().then(e=>{this.store.actions.configuration(e),this.setSortId(this.store.getState().request.sortId)}),this.loadTaruqaTemplate(),this.launchSearch()}addListeners(){window.addEventListener("storage",this.onStorageEvent),d.addEventListener(z.eventName,this.loadTaruqaTemplate),this.searchWatcher.watch(),this.suggestWatcher.watch(),this.stickyFiltersIdWatcher.watch(),this.history.enable(d.getState().tenantId+"-ft-recent-queries")}removeListeners(){window.removeEventListener("storage",this.onStorageEvent),d.removeEventListener(z.eventName,this.loadTaruqaTemplate),this.searchWatcher.stop(),this.suggestWatcher.stop(),this.stickyFiltersIdWatcher.stop(),this.history.disable()}get taruqaConfigStorageKey(){return d.getState().tenantId+"-taruqa-experiment-conf"}updateSearchRequest(e,r=!1){let n=(0,C.deepCopy)(this.store.getState().request);delete n.changedByConfiguration,this.store.actions.setRequest({...n,paging:{perPage:n.paging.perPage,page:r?1:n.paging.page},...e})}setQuery(e){this.updateSearchRequest({query:e},!0),this.setLiveQuery(e)}setContentLocale(e){var r,n;let s=(n=this.store.getState().locales)!==null&&n!==void 0?n:[],i=this.store.getState().request.contentLocale;if(e!=i){if(s.length>0){let a=o=>s.some(c=>c.lang==o);a(e)||(e=a(i)?i:s[0].lang)}this.updateSearchRequest({contentLocale:e,metadataFilters:[]},!0),this.canUpdateUiLocale&&(!((r=$e.store.getState().localesConfiguration)===null||r===void 0)&&r.searchLanguageSetsUiLanguage)&&e&&$e.requestUiLocaleUpdate(e,e)}return e}forceContentLocale(e){this.updateSearchRequest({contentLocale:e})}setPageSize(e){let r=this.store.getState().request;this.updateSearchRequest({paging:{...r.paging,perPage:isNaN(e)?20:(0,C.minmax)(1,e,1e3)}})}setPageNumber(e){let r=this.store.getState().request;this.updateSearchRequest({paging:{...r.paging,page:isNaN(e)?1:Math.max(1,e)}})}get sortOptions(){var e,r;return(r=(e=this.store.getState().configuration)===null||e===void 0?void 0:e.sortOptions)!==null&&r!==void 0?r:[]}setSort(e){this.updateSearchRequest({sort:e},!0)}setSortId(e,r=!1){var n;let s=r?{changedByConfiguration:!0}:{};if(e==null||this.sortOptions.length==0)return this.updateSearchRequest({sortId:e,...s},!0),e;let i=(n=this.sortOptions.find(a=>a.id==e))!==null&&n!==void 0?n:this.sortOptions[0];return this.updateSearchRequest({sortId:i.id,...s},!0),i.id}setFilters(e){let r=e.filter(n=>!n.valueFilter||n.valueFilter.values.length>0);this.updateSearchRequest({metadataFilters:r},!0)}setClusterSortCriterion(e){this.updateSearchRequest({clusterSortCriterions:e})}setSearchInDocumentTitlesOnly(e){e?this.updateSearchRequest({virtualField:Te.TITLE_ONLY,scope:be.DOCUMENTS},!0):this.updateSearchRequest({virtualField:Te.EVERYWHERE,scope:be.DEFAULT},!0)}setKeywordMatch(e){this.updateSearchRequest({keywordMatch:e},!0)}setVirtualField(e){this.updateSearchRequest({virtualField:e},!0)}get searchInDocumentTitlesOnly(){return Sa(this.store.getState())}get keywordMatch(){return Aa(this.store.getState())}clearAllFilters(){this.setFilters([]),this.store.dispatchEvent(new Ge)}addFacet(e){this.facetIds=[...this.facetIds,e]}replaceFacet(e,r){let n=this.facetIds.filter(s=>s!=e);r&&n.push(r),this.facetIds=n}get facetIds(){var e;let r=this.store.getState().request;return[...new Set([...r.facets.map(n=>n.id),...((e=r.metadataFilters)!==null&&e!==void 0?e:[]).map(n=>n.key)])]}set facetIds(e){let n=[...new Set(e)].map(s=>({id:s}));this.updateSearchRequest({facets:n})}addPropagatedFacet(e){let r=new Set(this.store.getState().propagatedFacets);r.add(e),this.store.actions.propagatedFacets([...r])}setFilter(e,r){this.setValueFilter(e,r)}setValueFilter(e,r){let n=this.store.getState().request.metadataFilters,s={key:e,valueFilter:{values:r,negative:!1}},i=[...n.filter(a=>!a.valueFilter),...n.filter(a=>a.valueFilter&&a.key!==s.key),s];this.setFilters(i)}setDateFilter(e,r){let n=this.store.getState().request.metadataFilters,s={key:e,dateFilter:{type:r}},i=[...n.filter(a=>!a.dateFilter),...n.filter(a=>a.dateFilter&&a.key!==s.key),s];this.setFilters(i)}removeDateFilter(e){let r=this.store.getState().request.metadataFilters,n=[...r.filter(s=>!s.dateFilter),...r.filter(s=>s.dateFilter&&s.key!==e)];this.setFilters(n)}setRangeFilter(e,r,n){let s=this.store.getState().request.metadataFilters,i={key:e,rangeFilter:{from:r,to:n}},a=[...s.filter(o=>!o.rangeFilter),...s.filter(o=>o.rangeFilter&&o.key!==i.key),i];this.setFilters(a)}removeRangeFilter(e){let r=this.store.getState().request.metadataFilters,n=[...r.filter(s=>!s.rangeFilter),...r.filter(s=>s.rangeFilter&&s.key!==e)];this.setFilters(n)}setLiveQuery(e){this.store.actions.liveQuery(e)}setRequest(e){this.updateSearchRequest({...e,facets:this.store.getState().request.facets},!0),this.setLiveQuery(e.query)}setScope(e){this.updateSearchRequest({scope:e})}setOtherQueryParams(e){this.updateSearchRequest({otherQueryParams:e})}setIgnoreEmptyQuery(e){this.ignoreEmptyQuery=e}setOpenExternalDocumentInNewTab(e){this.openExternalDocumentInNewTab=e}setCanUpdateUiLocale(e){this.canUpdateUiLocale=e}setApplyStickyFilters(e){this.applyStickyFilters=e,this.launchSearch(),this.launchSuggest()}addRecentQuery(e){this.history.addRecentQuery(e)}removeRecentQuery(e){this.history.removeRecentQuery(e)}updateLocales(){return this.localesDebouncer.run(async()=>this.store.actions.locales((await this.service.getAvailableSearchLocales()).contentLocales))}async fetchSearchData(e){var r,n,s,i,a;if((r=this.cancelableSearch)===null||r===void 0||r.cancel(),!!this.isRequestNeeded(ze.CLUSTERED_SEARCH))try{if(this.store.actions.paging(void 0),this.ignoreEmptyQuery&&e.query.length==0)this.store.actions.results(void 0),this.store.actions.announcements(void 0),this.store.actions.facets(void 0),this.store.actions.spellcheck(void 0);else{!((n=this.store.getState().results)===null||n===void 0)&&n.length||this.store.actions.results(void 0),this.cancelableSearch=(0,C.cancelable)(this.service.launchSearch(e));let o=await this.cancelableSearch;if(this.store.actions.announcements(o.announcements),o.paging.currentPage<=1)this.store.actions.results(o.results),this.store.actions.facets(o.facets),this.store.actions.spellcheck(o.spellcheck);else{let c=((i=this.store.getState().results)!==null&&i!==void 0?i:[]).concat(o.results);this.store.actions.results(c),this.store.commands.clear(/^focus-result-/),this.store.commands.add({type:`focus-result-${(o.paging.currentPage-1)*((a=e.paging.perPage)!==null&&a!==void 0?a:20)+1}`})}this.store.actions.paging(o.paging)}}catch(o){o instanceof C.CanceledPromiseError||(console.error(o),(s=this.errorHandler)===null||s===void 0||s.call(this,o))}}async fetchSuggestData(e){var r;try{if((r=this.cancelableSuggest)===null||r===void 0||r.cancel(),e.input.length<3){this.store.actions.suggestResults([]);return}this.cancelableSuggest=(0,C.cancelable)(this.service.launchSuggest(e));let n=await this.cancelableSuggest;this.store.actions.suggestResults(n.suggestions)}catch(n){!(n instanceof C.CanceledPromiseError)&&this.errorHandler&&this.errorHandler(n)}}clear(){this.store.clear()}clearResults(){this.store.actions.paging(void 0),this.store.actions.results(void 0),this.store.actions.announcements(void 0),this.store.actions.facets(void 0),this.store.actions.spellcheck(void 0)}};var qr=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},Hr=class extends CustomEvent{constructor(e){super("register-ft-search-component",{bubbles:!0,composed:!0,detail:{registrationId:e}})}},Ys=Symbol("registerInterval"),jr=Symbol("registerAttempts"),Ta=40,ba=(0,ke.applyMixinOnce)(Symbol("toFtSearchComponent"),function(t){class e extends t{constructor(){super(...arguments),this.neededSearchRequests=[]}willUpdate(n){var s,i,a;super.willUpdate(n),n.has("neededSearchRequests")&&((s=this.stateManager)===null||s===void 0||s.unregisterComponent(this,(a=n.get("neededSearchRequests"))!==null&&a!==void 0?a:[]),(i=this.stateManager)===null||i===void 0||i.registerComponent(this,this.neededSearchRequests))}setSearchStateManager(n){this.clearStateManager(),this.stateManager=n,this.stateManager.registerComponent(this,this.neededSearchRequests),this.addStore(n.store,"search")}clearStateManager(){this.stateManager&&(this.stateManager.unregisterComponent(this,this.neededSearchRequests),this.removeStore(this.stateManager.store),this.stateManager=void 0)}connectedCallback(){super.connectedCallback(),this[jr]=0,this.tryToRegisterToContext(),this[Ys]=window.setInterval(()=>this.tryToRegisterToContext(),50)}tryToRegisterToContext(){this.stateManager!=null||this[jr]>Ta?window.clearInterval(this[Ys]):(this[jr]++,this.dispatchEvent(new Hr(this.searchRegistrationId)))}disconnectedCallback(){super.disconnectedCallback(),this.clearStateManager()}}return qr([(0,Qe.state)()],e.prototype,"stateManager",void 0),qr([(0,Qe.state)({hasChanged:ke.hasChanged})],e.prototype,"neededSearchRequests",void 0),qr([(0,Qe.property)()],e.prototype,"searchRegistrationId",void 0),e}),Xs=class extends ba(ke.FtLitElementRedux){};var ir=f(T());function rr(t){return t.filter(e=>e.key==="ft:lastEdition").filter(e=>!e.valueFilter).map(e=>e.dateFilter?e.dateFilter.type:"CUSTOM").shift()}function nr(t){var e,r;return t.dateFilter?{key:t.key,type:"DATE",dateValue:t.dateFilter.type}:t.rangeFilter?{key:t.key,type:"RANGE",from:t.rangeFilter.from,to:t.rangeFilter.to}:{key:t.key,values:(e=t.valueFilter)===null||e===void 0?void 0:e.values,negative:(r=t.valueFilter)===null||r===void 0?void 0:r.negative}}var sr=class{constructor(e,r){this.store=e,this.ignoreEmptyQuery=!1,this.openExternalDocumentInNewTab=!1,this.enableAnalyticsEvents=!0,this.appName=void 0,this.appVersion=void 0,this.document=void 0,this.sendEvent=([n,s])=>{if(!this.canSendEvent()||!n||!s)return;let i=this.store.getState().request;this.document==null?this.sendKhubSearchEvent(i,n,s):this.sendDocumentSearchEvent(i,n,s)},this.eventsService=r??new Me,this.resultsWatcher=(0,ir.watch)(e,n=>[n.results,n.paging],this.sendEvent)}setEnableAnalyticsEvents(e){this.enableAnalyticsEvents=e}setAppName(e){this.appName=e}setAppVersion(e){this.appVersion=e}setDocumentSearch(e){this.document=e}setDocumentSearchFromMap(e){this.setDocumentSearch(this.eventsService.convertMapToAnalyticsDocument(e))}initAppInfo(){let{apiIntegrationIdentifier:e,apiIntegrationAppVersion:r}=d.getState();this.setAppName(e??"unknown"),this.setAppVersion(r??"unknown")}canSendEvent(){if(this.appName==null||this.appVersion==null)return console.debug("ft-search-context.eventManager is not initialized. No events will be sent!"),!1;let{editorMode:e}=d.getState();return this.enableAnalyticsEvents&&!e}sendKhubSearchEvent(e,r,n){let s={offline:!1,appVersion:this.appVersion,appName:this.appName,name:he.KHUB__SEARCH,searchResponse:{autocorrect:this.store.getState().spellcheck!=null,nbResults:n.totalClustersCount},searchQuery:{terms:e.query,searchType:e.virtualField,lastUpdate:rr(e.metadataFilters),facets:e.metadataFilters.map(i=>nr(i))}};this.eventsService.sendKhubSearchEvent(s)}sendDocumentSearchEvent(e,r,n){if(e.metadataFilters.find(i=>{var a;return i.key==="ft:publicationId"&&((a=i.valueFilter)===null||a===void 0?void 0:a.values[0])===this.document.id})!==void 0){let i={offline:!1,appVersion:this.appVersion,appName:this.appName,name:he.DOCUMENT__SEARCH,searchResponse:{autocorrect:this.store.getState().spellcheck!=null,nbResults:n.totalClustersCount},searchQuery:{terms:e.query},document:this.document};this.eventsService.sendDocumentSearchEvent(i)}}sendResultClickedEvent(e,r){if(!this.canSendEvent())return;let n=this.store.getState().request,s;e.type==J.TOPIC&&(s={tocId:e.topic.tocId,title:e.topic.title});let i={offline:!1,appVersion:this.appVersion,appName:this.appName,name:he.SEARCH_PAGE__SELECT,searchQuery:{terms:n.query,searchType:n.virtualField,lastUpdate:rr(n.metadataFilters),facets:n.metadataFilters.map(a=>nr(a))},searchResult:{rank:r,type:e.type,document:this.convertDocument(e),topic:s},externalLink:this.convertExternalLink(e)};this.eventsService.sendSearchPageSelectEvent(i)}sendResultContextMenuOpenedEvent(e,r){if(!this.canSendEvent())return;let n=this.store.getState().request,s;e.type==J.TOPIC&&(s={tocId:e.topic.tocId,title:e.topic.title});let i={offline:!1,appVersion:this.appVersion,appName:this.appName,name:he.SEARCH_RESULT__OPEN_BROWSER_CONTEXT_MENU,searchQuery:{terms:n.query,searchType:n.virtualField,lastUpdate:rr(n.metadataFilters),facets:n.metadataFilters.map(a=>nr(a))},searchResult:{rank:r,type:e.type,document:this.convertDocument(e),topic:s},externalLink:this.convertExternalLink(e)};this.eventsService.sendSearchResultOpenContextMenuEvent(i)}convertDocument(e){switch(e.type){case J.MAP:return{id:e.map.mapId,title:e.map.title,type:ce.STRUCTURED_DOCUMENT,metadata:e.map.metadata};case J.TOPIC:return{id:e.topic.mapId,title:e.topic.mapTitle,type:ce.STRUCTURED_DOCUMENT,metadata:e.topic.metadata};case J.DOCUMENT:return{id:e.document.documentId,title:e.document.title,type:ce.UNSTRUCTURED_DOCUMENT,metadata:e.document.metadata,mimeType:e.document.mimeType};case J.HTML_PACKAGE:return{id:e.htmlPackage.packageId,title:e.htmlPackage.title,type:ce.HTML_PACKAGE,metadata:e.htmlPackage.metadata};case J.HTML_PACKAGE_PAGE:return{id:e.htmlPackagePage.packageId,title:e.htmlPackagePage.title,type:ce.HTML_PACKAGE,metadata:e.htmlPackagePage.metadata};default:throw new TypeError("Unknown type "+e.type)}}convertExternalLink(e){var r;return(r=(0,ir.accessResult)(e))===null||r===void 0?void 0:r.originUrl}};var R=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},v=class extends j.FtLitElementRedux{get stateManager(){if(this._stateManager==null){let e=this.searchServiceProvider?this.searchServiceProvider():void 0;this._stateManager=We.build(this.id||(""+Math.round(Math.random()*999e3)).padStart(6,"0"),e),this._stateManager.errorHandler=r=>this.handleLoadError(r),this.addStore(this.stateManager.store,"search")}return this._stateManager}get eventManager(){return this._eventManager==null&&(this._eventManager=new sr(this.stateManager.store)),this._eventManager}constructor(){super(),this.query="",this.pageSize=20,this.searchInDocumentTitlesOnly=!1,this.ignoreEmptyQuery=!1,this.applyStickyFilters=!1,this.openExternalDocumentInNewTab=!1,this.filters=[],this.sort=[],this.otherQueryParams={},this._appIntegrationInfoReady=!1,this.addStore(d)}render(){return Js.html`
7
7
  <slot @register-ft-search-component=${this.registerComponent} @ft-search-result-click=${this.onResultClicked}
8
8
  @ft-search-result-open-context-menu=${this.onResultContextMenuOpened}></slot>
9
- `}willUpdate(e){super.willUpdate(e),e.has("_appIntegrationInfoReady")&&this._appIntegrationInfoReady&&this.eventManager.initAppInfo(),e.has("query")&&this.query!==void 0&&this.stateManager.setQuery(this.query),e.has("contentLocale")&&this.contentLocale!==void 0&&this.stateManager.forceContentLocale(this.contentLocale),e.has("filters")&&this.filters!==void 0&&this.stateManager.setFilters(this.filters),e.has("sortId")&&this.stateManager.setSortId(this.sortId),e.has("sort")&&this.sort!==void 0&&this.stateManager.setSort(this.sort),e.has("pageSize")&&this.pageSize!==void 0&&this.stateManager.setPageSize(this.pageSize),e.has("searchInDocumentTitlesOnly")&&this.searchInDocumentTitlesOnly!==void 0&&this.stateManager.setSearchInDocumentTitlesOnly(this.searchInDocumentTitlesOnly),e.has("keywordMatch")&&this.stateManager.setKeywordMatch(this.keywordMatch),e.has("scope")&&this.scope!==void 0&&this.stateManager.setScope(this.scope),e.has("virtualField")&&this.virtualField!==void 0&&this.stateManager.setVirtualField(this.virtualField),e.has("ignoreEmptyQuery")&&this.ignoreEmptyQuery!==void 0&&this.stateManager.setIgnoreEmptyQuery(this.ignoreEmptyQuery),e.has("applyStickyFilters")&&this.stateManager.setApplyStickyFilters(this.applyStickyFilters),e.has("openExternalDocumentInNewTab")&&this.openExternalDocumentInNewTab!==void 0&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("otherQueryParams")&&this.otherQueryParams!==void 0&&this.stateManager.setOtherQueryParams(this.otherQueryParams),e.has("session")&&this.session!==void 0&&e.get("session")!=null&&(this.stateManager.service.clearCache(),this.stateManager.initService())}connectedCallback(){super.connectedCallback(),this.stateManager.initService(),this.stateManager.clearResults(),this.stateManager.setQuery(this.query),this.stateManager.forceContentLocale(this.contentLocale),this.stateManager.setFilters(this.filters),this.stateManager.setPageSize(this.pageSize),this.stateManager.setSort(this.sort),this.stateManager.setOtherQueryParams(this.otherQueryParams),this.stateManager.addListeners()}disconnectedCallback(){super.disconnectedCallback(),this.stateManager.removeListeners(),this.stateManager.clearResults()}contentAvailableCallback(e){super.contentAvailableCallback(e),e.has("request")&&this.request&&this.dispatchEvent(new Zt(this.request)),e.has("paging")&&this.paging!==void 0&&this.dispatchEvent(new er(this.request,this.paging,this.spellcheckAutocorrect))}registerComponent(e){var r;if(e.stopPropagation(),((r=e.detail)===null||r===void 0?void 0:r.registrationId)==this.registrationId){let n=e.composedPath()[0];this.register(n)}}register(e){e.setSearchStateManager(this.stateManager)}handleLoadError(e){this.dispatchEvent(new Jt(e))}clear(){this.stateManager.clear()}onResultClicked(e){this.eventManager.sendResultClickedEvent(e.detail.result,e.detail.rank)}onResultContextMenuOpened(e){this.eventManager.sendResultContextMenuOpenedEvent(e.detail.result,e.detail.rank)}};v.elementDefinitions={};v.styles=Ws;O([(0,q.redux)({store:d.name})],v.prototype,"session",void 0);O([(0,Q.property)()],v.prototype,"query",void 0);O([(0,Q.property)()],v.prototype,"contentLocale",void 0);O([(0,q.numberProperty)()],v.prototype,"pageSize",void 0);O([(0,Q.property)({type:Boolean})],v.prototype,"searchInDocumentTitlesOnly",void 0);O([(0,Q.property)()],v.prototype,"keywordMatch",void 0);O([(0,Q.property)()],v.prototype,"scope",void 0);O([(0,Q.property)()],v.prototype,"virtualField",void 0);O([(0,Q.property)()],v.prototype,"registrationId",void 0);O([(0,Q.property)({type:Boolean})],v.prototype,"ignoreEmptyQuery",void 0);O([(0,Q.property)({type:Boolean})],v.prototype,"applyStickyFilters",void 0);O([(0,q.redux)({store:d.name})],v.prototype,"openExternalDocumentInNewTab",void 0);O([(0,q.jsonProperty)([])],v.prototype,"filters",void 0);O([(0,Q.property)()],v.prototype,"sortId",void 0);O([(0,q.jsonProperty)([])],v.prototype,"sort",void 0);O([(0,q.jsonProperty)({})],v.prototype,"otherQueryParams",void 0);O([(0,q.redux)({store:"search"})],v.prototype,"request",void 0);O([(0,q.redux)({store:"search"})],v.prototype,"paging",void 0);O([(0,q.redux)({store:"search",selector:t=>t.spellcheck})],v.prototype,"spellcheckAutocorrect",void 0);O([(0,q.redux)({store:d.name,selector:t=>t.apiIntegrationIdentifier!==void 0&&t.apiIntegrationAppVersion!==void 0})],v.prototype,"_appIntegrationInfoReady",void 0);O([(0,Q.property)({attribute:!1})],v.prototype,"searchServiceProvider",void 0);var ti=f(b());var ei={"ft-search-context":v};(0,ti.customElements)(ei);var U=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},Hr=class{constructor(e){this.stateManager=e}searchInDocument(e){this.stateManager.setSearchInDocumentQuery(e??"")}},R=class extends M.FtLitElementRedux{constructor(){super(),this.metadataFilters=[],this.visibleTopics=[],this.updateConfiguration=()=>{this.stateManager.reloadConfiguration()},this.scrollToTargetDebouncer=new M.Debouncer(5),this.navigationDebouncer=new M.Debouncer(10),this.mapLoadedEventDebouncer=new M.Debouncer(50),this.addStore(d)}render(){return Ye.html`
9
+ `}willUpdate(e){super.willUpdate(e),e.has("_appIntegrationInfoReady")&&this._appIntegrationInfoReady&&this.eventManager.initAppInfo(),e.has("query")&&this.query!==void 0&&this.stateManager.setQuery(this.query),e.has("contentLocale")&&this.contentLocale!==void 0&&this.stateManager.forceContentLocale(this.contentLocale),e.has("filters")&&this.filters!==void 0&&this.stateManager.setFilters(this.filters),e.has("sortId")&&this.stateManager.setSortId(this.sortId),e.has("sort")&&this.sort!==void 0&&this.stateManager.setSort(this.sort),e.has("pageSize")&&this.pageSize!==void 0&&this.stateManager.setPageSize(this.pageSize),e.has("searchInDocumentTitlesOnly")&&this.searchInDocumentTitlesOnly!==void 0&&this.stateManager.setSearchInDocumentTitlesOnly(this.searchInDocumentTitlesOnly),e.has("keywordMatch")&&this.stateManager.setKeywordMatch(this.keywordMatch),e.has("scope")&&this.scope!==void 0&&this.stateManager.setScope(this.scope),e.has("virtualField")&&this.virtualField!==void 0&&this.stateManager.setVirtualField(this.virtualField),e.has("ignoreEmptyQuery")&&this.ignoreEmptyQuery!==void 0&&this.stateManager.setIgnoreEmptyQuery(this.ignoreEmptyQuery),e.has("applyStickyFilters")&&this.stateManager.setApplyStickyFilters(this.applyStickyFilters),e.has("openExternalDocumentInNewTab")&&this.openExternalDocumentInNewTab!==void 0&&this.stateManager.setOpenExternalDocumentInNewTab(this.openExternalDocumentInNewTab),e.has("otherQueryParams")&&this.otherQueryParams!==void 0&&this.stateManager.setOtherQueryParams(this.otherQueryParams),e.has("session")&&this.session!==void 0&&e.get("session")!=null&&(this.stateManager.service.clearCache(),this.stateManager.initService())}connectedCallback(){super.connectedCallback(),this.stateManager.initService(),this.stateManager.clearResults(),this.stateManager.setQuery(this.query),this.stateManager.forceContentLocale(this.contentLocale),this.stateManager.setFilters(this.filters),this.stateManager.setPageSize(this.pageSize),this.stateManager.setSort(this.sort),this.stateManager.setOtherQueryParams(this.otherQueryParams),this.stateManager.addListeners()}disconnectedCallback(){super.disconnectedCallback(),this.stateManager.removeListeners(),this.stateManager.clearResults()}contentAvailableCallback(e){super.contentAvailableCallback(e),e.has("request")&&this.request&&this.dispatchEvent(new er(this.request)),e.has("paging")&&this.paging!==void 0&&this.dispatchEvent(new tr(this.request,this.paging,this.spellcheckAutocorrect))}registerComponent(e){var r;if(e.stopPropagation(),((r=e.detail)===null||r===void 0?void 0:r.registrationId)==this.registrationId){let n=e.composedPath()[0];this.register(n)}}register(e){e.setSearchStateManager(this.stateManager)}handleLoadError(e){this.dispatchEvent(new Zt(e))}clear(){this.stateManager.clear()}onResultClicked(e){this.eventManager.sendResultClickedEvent(e.detail.result,e.detail.rank)}onResultContextMenuOpened(e){this.eventManager.sendResultContextMenuOpenedEvent(e.detail.result,e.detail.rank)}};v.elementDefinitions={};v.styles=Gs;R([(0,j.redux)({store:d.name})],v.prototype,"session",void 0);R([(0,Y.property)()],v.prototype,"query",void 0);R([(0,Y.property)()],v.prototype,"contentLocale",void 0);R([(0,j.numberProperty)()],v.prototype,"pageSize",void 0);R([(0,Y.property)({type:Boolean})],v.prototype,"searchInDocumentTitlesOnly",void 0);R([(0,Y.property)()],v.prototype,"keywordMatch",void 0);R([(0,Y.property)()],v.prototype,"scope",void 0);R([(0,Y.property)()],v.prototype,"virtualField",void 0);R([(0,Y.property)()],v.prototype,"registrationId",void 0);R([(0,Y.property)({type:Boolean})],v.prototype,"ignoreEmptyQuery",void 0);R([(0,Y.property)({type:Boolean})],v.prototype,"applyStickyFilters",void 0);R([(0,j.redux)({store:d.name})],v.prototype,"openExternalDocumentInNewTab",void 0);R([(0,j.jsonProperty)([])],v.prototype,"filters",void 0);R([(0,Y.property)()],v.prototype,"sortId",void 0);R([(0,j.jsonProperty)([])],v.prototype,"sort",void 0);R([(0,j.jsonProperty)({})],v.prototype,"otherQueryParams",void 0);R([(0,j.redux)({store:"search"})],v.prototype,"request",void 0);R([(0,j.redux)({store:"search"})],v.prototype,"paging",void 0);R([(0,j.redux)({store:"search",selector:t=>t.spellcheck})],v.prototype,"spellcheckAutocorrect",void 0);R([(0,j.redux)({store:d.name,selector:t=>t.apiIntegrationIdentifier!==void 0&&t.apiIntegrationAppVersion!==void 0})],v.prototype,"_appIntegrationInfoReady",void 0);R([(0,Y.property)({attribute:!1})],v.prototype,"searchServiceProvider",void 0);var ei=f(T());var Zs={"ft-search-context":v};(0,ei.customElements)(Zs);var U=function(t,e,r,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(i=(s<3?a(i):s>3?a(e,r,i):a(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i},$r=class{constructor(e){this.stateManager=e}searchInDocument(e){this.stateManager.setSearchInDocumentQuery(e??"")}},w=class extends I.FtLitElementRedux{constructor(){super(),this.metadataFilters=[],this.visibleTopics=[],this.updateConfiguration=()=>{this.stateManager.reloadConfiguration()},this.scrollToTargetDebouncer=new I.Debouncer(5),this.navigationDebouncer=new I.Debouncer(10),this.mapLoadedEventDebouncer=new I.Debouncer(50),this.addStore(d)}render(){return Ye.html`
10
10
  ${this.importStyleIfNeeded()}
11
11
  <ft-toc-filtering-search-context
12
12
  registrationId="reader-toc-filtering"
@@ -21,7 +21,7 @@
21
21
  <style>
22
22
  @import "${n}"
23
23
  </style>
24
- `}get stateManager(){return this._stateManager==null&&(this._stateManager=jt.build(this.id||(0,M.randomId)(6),this.readerServiceProvider),this._stateManager.errorHandler=e=>this.handleLoadError(e),this.addStore(this.stateManager.store,"reader")),this._stateManager}get filters(){return[{key:"ft:publicationId",valueFilter:{negative:!1,values:[this.mapId]}},...this.metadataFilters]}connectedCallback(){super.connectedCallback(),this.stateManager.setMapId(this.mapId),this.stateManager.awaitService().then(e=>{let r=e.fontsStylesheet();if(r&&!window.location.href.startsWith(this.baseUrl)&&!document.querySelector(`head link[href="${r}"]`)){let n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",r),document.head.append(n)}window.FluidTopicsReaderService=new Hr(this.stateManager)}),d.addEventListener($.eventName,this.updateConfiguration)}disconnectedCallback(){super.disconnectedCallback(),d.addEventListener($.eventName,this.updateConfiguration)}update(e){var r;super.update(e),e.has("readerServiceProvider")&&this.readerServiceProvider&&this.stateManager.initService(this.readerServiceProvider);let n=e.has("metadataFilters")&&e.get("metadataFilters")!=null;n&&this.stateManager.setFilters((r=this.metadataFilters)!==null&&r!==void 0?r:[]),e.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.lastNotifiedNotFoundRelative=void 0),e.has("searchInDocumentQuery")&&this.searchInDocumentQuery!=null&&this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery),e.has("session")?this.reload():n?this.stateManager.reloadFromFilter(this.section,this.page):["tocId","section","page","mapId","topicPivot"].some(s=>e.has(s))&&this.mapId&&this.navigateToTarget()}contentAvailableCallback(e){var r,n;if(super.contentAvailableCallback(e),(e.has("map")||e.has("toc"))&&this.sendLoadedEventIfLoaded(),e.has("scrollTarget")&&((r=this.scrollTarget)===null||r===void 0?void 0:r.tocId)==null){let s=e.get("scrollTarget");s?.tocId!=null&&this.scrollToTargetDebouncer.run(()=>this.stateManager.getAccurateNavigationData(s.tocId,this.currentPage,s).then(i=>this.dispatchEvent(new $t(i))))}(e.has("visibleTopics")||e.has("scrollTarget"))&&((n=this.scrollTarget)===null||n===void 0?void 0:n.tocId)==null&&Promise.all(this.visibleTopics.map(s=>this.stateManager.getAccurateNavigationData(s,this.currentPage))).then(s=>{let i=s.filter(a=>a!=null&&a.topicTitle!=="").map(a=>({tocId:a.tocId,title:a.topicTitle,page:a.page,prettyUrl:a.prettyUrl,prettyUrlDuplicated:a.prettyUrlDuplicated,breadcrumb:this.stateManager.buildBreadcrumb(a.tocId)}));this.dispatchEvent(new Kt(this.map,i))})}clear(){this.stateManager.clear()}async reload(){await this.stateManager.reload(),await this.navigateToTarget()}async navigateToTarget(){await this.stateManager.loaded(),await this.navigationDebouncer.run(async()=>{this.topicPivot!=null?!await this.stateManager.navigateToRelativeTopicIfFound(this.topicPivot)&&this.lastNotifiedNotFoundRelative!==this.mapId+this.topicPivot?(this.dispatchEvent(new Yt),this.lastNotifiedNotFoundRelative=this.mapId+this.topicPivot):this.lastNotifiedNotFoundRelative=void 0:this.tocId!=null?await this.stateManager.navigateToTopic(this.tocId,this.section,this.page):this.page!=null&&await this.stateManager.navigateToPage(this.page)})}registerComponent(e){e.stopPropagation();let r=e.composedPath()[0];this.register(r)}register(e){e.setReaderStateManager(this.stateManager)}handleLoadError(e){let r=e;r.status===401?this.dispatchEvent(new Wt):r.status===403?this.dispatchEvent(new Qt):r.status===404?this.dispatchEvent(new Gt):this.dispatchEvent(new zt(e))}reloadBookmarks(){Nr.reloadBookmarks()}async reloadRating(){var e,r;await((e=this.stateManager.service)===null||e===void 0?void 0:e.reloadRating()),(r=this.stateManager.store)===null||r===void 0||r.dispatchEvent(new CustomEvent("rating-changed"))}sendLoadedEventIfLoaded(){this.mapLoadedEventDebouncer.run(()=>{this.map&&this.toc&&this.dispatchEvent(new Ht(this.map,this.toc))})}};R.elementDefinitions={"ft-toc-filtering-search-context":v};R.styles=zs;U([(0,M.redux)({store:d.name})],R.prototype,"baseUrl",void 0);U([(0,M.redux)({store:d.name})],R.prototype,"session",void 0);U([(0,ae.property)()],R.prototype,"mapId",void 0);U([(0,ae.property)()],R.prototype,"tocId",void 0);U([(0,ae.property)()],R.prototype,"section",void 0);U([(0,ae.property)()],R.prototype,"topicPivot",void 0);U([(0,ae.property)()],R.prototype,"searchInDocumentQuery",void 0);U([(0,M.redux)({store:"reader",converter:(0,M.jsonPropertyConverter)([]),attribute:!0})],R.prototype,"metadataFilters",void 0);U([(0,M.numberProperty)({min:1})],R.prototype,"page",void 0);U([(0,M.redux)({store:"reader"})],R.prototype,"map",void 0);U([(0,M.redux)({store:"reader"})],R.prototype,"toc",void 0);U([(0,M.redux)({store:"reader"})],R.prototype,"visibleTopics",void 0);U([(0,M.redux)({store:"reader"})],R.prototype,"currentPage",void 0);U([(0,M.redux)({store:"reader"})],R.prototype,"scrollTarget",void 0);U([(0,ae.property)({attribute:!1})],R.prototype,"readerServiceProvider",void 0);U([(0,ae.query)("ft-toc-filtering-search-context")],R.prototype,"tocFilteringContext",void 0);var ri={"ft-reader-context":R};(0,ni.customElements)(ri);})();
24
+ `}get stateManager(){return this._stateManager==null&&(this._stateManager=Ht.build(this.id||(0,I.randomId)(6),this.readerServiceProvider),this._stateManager.errorHandler=e=>this.handleLoadError(e),this.addStore(this.stateManager.store,"reader")),this._stateManager}get filters(){return[{key:"ft:publicationId",valueFilter:{negative:!1,values:[this.mapId]}},...this.metadataFilters]}connectedCallback(){super.connectedCallback(),this.stateManager.setMapId(this.mapId),this.stateManager.awaitService().then(e=>{let r=e.fontsStylesheet();if(r&&!window.location.href.startsWith(this.baseUrl)&&!document.querySelector(`head link[href="${r}"]`)){let n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",r),document.head.append(n)}window.FluidTopicsReaderService=new $r(this.stateManager)}),d.addEventListener(z.eventName,this.updateConfiguration)}disconnectedCallback(){super.disconnectedCallback(),d.addEventListener(z.eventName,this.updateConfiguration)}update(e){var r;super.update(e),e.has("readerServiceProvider")&&this.readerServiceProvider&&this.stateManager.initService(this.readerServiceProvider);let n=e.has("metadataFilters")&&e.get("metadataFilters")!=null;n&&this.stateManager.setFilters((r=this.metadataFilters)!==null&&r!==void 0?r:[]),e.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.lastNotifiedNotFoundRelative=void 0),e.has("searchInDocumentQuery")&&this.searchInDocumentQuery!=null&&this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery),e.has("session")?this.reload():n?this.stateManager.reloadFromFilter(this.section,this.page):["tocId","section","page","mapId","topicPivot"].some(s=>e.has(s))&&this.mapId&&this.navigateToTarget()}contentAvailableCallback(e){var r,n;if(super.contentAvailableCallback(e),(e.has("map")||e.has("toc"))&&this.sendLoadedEventIfLoaded(),e.has("scrollTarget")&&((r=this.scrollTarget)===null||r===void 0?void 0:r.tocId)==null){let s=e.get("scrollTarget");s?.tocId!=null&&this.scrollToTargetDebouncer.run(()=>this.stateManager.getAccurateNavigationData(s.tocId,this.currentPage,s).then(i=>this.dispatchEvent(new zt(i))))}(e.has("visibleTopics")||e.has("scrollTarget"))&&((n=this.scrollTarget)===null||n===void 0?void 0:n.tocId)==null&&Promise.all(this.visibleTopics.map(s=>this.stateManager.getAccurateNavigationData(s,this.currentPage))).then(s=>{let i=s.filter(a=>a!=null&&a.topicTitle!=="").map(a=>({tocId:a.tocId,title:a.topicTitle,page:a.page,prettyUrl:a.prettyUrl,prettyUrlDuplicated:a.prettyUrlDuplicated,breadcrumb:this.stateManager.buildBreadcrumb(a.tocId)}));this.dispatchEvent(new Kt(this.map,i))})}clear(){this.stateManager.clear()}async reload(){await this.stateManager.reload(),await this.navigateToTarget()}async navigateToTarget(){await this.stateManager.loaded(),await this.navigationDebouncer.run(async()=>{this.topicPivot!=null?!await this.stateManager.navigateToRelativeTopicIfFound(this.topicPivot)&&this.lastNotifiedNotFoundRelative!==this.mapId+this.topicPivot?(this.dispatchEvent(new Xt),this.lastNotifiedNotFoundRelative=this.mapId+this.topicPivot):this.lastNotifiedNotFoundRelative=void 0:this.tocId!=null?await this.stateManager.navigateToTopic(this.tocId,this.section,this.page):this.page!=null&&await this.stateManager.navigateToPage(this.page)})}registerComponent(e){e.stopPropagation();let r=e.composedPath()[0];this.register(r)}register(e){e.setReaderStateManager(this.stateManager)}handleLoadError(e){let r=e;r.status===401?this.dispatchEvent(new Qt):r.status===403?this.dispatchEvent(new Yt):r.status===404?this.dispatchEvent(new Wt):this.dispatchEvent(new Gt(e))}reloadBookmarks(){Dr.reloadBookmarks()}async reloadRating(){var e,r;await((e=this.stateManager.service)===null||e===void 0?void 0:e.reloadRating()),(r=this.stateManager.store)===null||r===void 0||r.dispatchEvent(new CustomEvent("rating-changed"))}sendLoadedEventIfLoaded(){this.mapLoadedEventDebouncer.run(()=>{this.map&&this.toc&&this.dispatchEvent(new $t(this.map,this.toc))})}};w.elementDefinitions={"ft-toc-filtering-search-context":v};w.styles=Ks;U([(0,I.redux)({store:d.name})],w.prototype,"baseUrl",void 0);U([(0,I.redux)({store:d.name})],w.prototype,"session",void 0);U([(0,ae.property)()],w.prototype,"mapId",void 0);U([(0,ae.property)()],w.prototype,"tocId",void 0);U([(0,ae.property)()],w.prototype,"section",void 0);U([(0,ae.property)()],w.prototype,"topicPivot",void 0);U([(0,ae.property)()],w.prototype,"searchInDocumentQuery",void 0);U([(0,I.redux)({store:"reader",converter:(0,I.jsonPropertyConverter)([]),attribute:!0})],w.prototype,"metadataFilters",void 0);U([(0,I.numberProperty)({min:1})],w.prototype,"page",void 0);U([(0,I.redux)({store:"reader"})],w.prototype,"map",void 0);U([(0,I.redux)({store:"reader"})],w.prototype,"toc",void 0);U([(0,I.redux)({store:"reader"})],w.prototype,"visibleTopics",void 0);U([(0,I.redux)({store:"reader"})],w.prototype,"currentPage",void 0);U([(0,I.redux)({store:"reader"})],w.prototype,"scrollTarget",void 0);U([(0,ae.property)({attribute:!1})],w.prototype,"readerServiceProvider",void 0);U([(0,ae.query)("ft-toc-filtering-search-context")],w.prototype,"tocFilteringContext",void 0);var ti={"ft-reader-context":w};(0,ri.customElements)(ti);})();
25
25
  /*! Bundled license information:
26
26
 
27
27
  .store/@lit-context-npm-1.1.6-2c155157c6/package/lib/context-request-event.js: