"use strict";(globalThis.webpackChunk_flippingbook_publication=globalThis.webpackChunk_flippingbook_publication||[]).push([[24],{6233:(t,e,r)=>{r.r(e),r.d(e,{SearchHighlight:()=>n});var o=r(1071);const s="search/";function n(t){this.store=t}n.prototype.clear=function(){this.store.commit(s+o.Sb)},n.prototype.findHighlights=function(t,e){const r=this;if(!this.store.getters["search/isSearchTextInfoLoaded"](e))return;const n=[],i=this.store.state.search.results;for(let o=0,s=i.length;o<s;o++)Array.isArray(i[o])?(i[o][0].pageId.toString()===e.toString()&&n.push(i[o][0]),i[o][1].pageId.toString()===e.toString()&&n.push(i[o][1])):i[o].pageId.toString()===e.toString()&&n.push(i[o]);if(!n.length)return void this.store.commit(s+o._m,{key:e,query:t,value:[]});const c=r._highlightFoundItems(n,e);r._filterCrossedItems(c),r.store.commit(s+o._m,{key:e,query:t,value:c});const a=r.store.getters["pager/state"];if("search"===a.target&&null===n[0].widePageSecondHalf&&a.singleMode&&a.currentPage===e&&!r.store.getters["pages/isFirstPage"](e)&&!r.store.getters["pages/isLastPage"](e)){const t=r.store.getters["search/getRightWideHalfSelection"](e);t!==a.widePageSecondHalf&&r.store.dispatch("pager/goToPageById",{id:e.toString(),widePageSecondHalf:t})}},n.prototype._highlightFoundItems=function(t,e){let r=[];const o=this.store.getters["search/getSearchTextInfo"](e),s=o.finalTree,n=o.searchTextMap,i=Object.keys(n).map((t=>parseInt(t,10)));i.sort(((t,e)=>e-t));const c=[].concat.apply([],t.map((t=>t.positions)));for(let a=0,g=c.length;a<g;a++){const t=this._highlightFoundItem(c[a].startPos,c[a].stopPos,i,n,s);r=r.concat(t)}return r},n.prototype._highlightFoundItem=function(t,e,r,o,s){try{const n=[];let i=r.findIndex((e=>e<=t));for(;i>=0&&o[r[i]].endSrc<t;)i--;if(i<0)return[];let c=r[i],a=Math.max(t-c,0),g=i;for(;c<=e&&g>=0;){const t=o[c],i=s[t.block],h=i.lines[t.line],l=Math.max(t.endSrc-e,0),p=t.reversed?l:a,u=t.endSrc-t.startSrc-l-a;n.push(this._getHighlightItem(h.symbols,i.onlyForSearch,t.startSym,p,u)),g--,c=r[g],a=0}return n}catch(n){return setTimeout((()=>{throw n}),0),[]}},n.prototype._getHighlightItem=function(t,e,r,o,s){const n=r+o;let i=t[n].left,c=t[n].top;const a=t[n].height,g=n+s;e&&t[n].rtl&&(i=t[g].left,c=t[g].top);return{rect:[[...Array(g-n+1).keys()].reduce(((e,r)=>e+t[n+r].width),0),a,i,c],angle:t[n].angle}},n.prototype._filterCrossedItems=function(t){for(let e=0;e<t.length;e++){const r=t[e];let o=t[e].rect;for(let s=e+1;s<t.length;s++){const n=t[s];if(0!==r.angle||0!==n.angle||r.rect[1]!==n.rect[1]||r.rect[3]!==n.rect[3])continue;const i=n.rect;if(o[2]<=i[2]&&i[2]<=o[2]+o[0]||i[2]<=o[2]&&o[2]<=i[2]+i[0]){const n=Math.min(o[2],i[2]),c=[Math.max(o[2]+o[0],i[2]+i[0])-n,o[1],n,o[3]];o=r.rect=c,t.splice(s,1),s=e}}}}}}]);