let self;class ReducersClass{constructor(e){self=this,self.hooks=e}getViewableRecords(e,t){return this.getPaginatedRecords(e,t.pagination)}getSfsRecords(e,t){let r=e;return r=this.getFilteredRecords(r,t.filters),r=this.getSearchedRecords(r,t.search,t.columns,t.excludeColumnsFromSearch),r=this.getSortedRecords(r,t.sort),r}getPaginatedRecords(e,t){const r=t.currentPage*t.numOfRecordsPerPage,n=parseInt(r)+parseInt(t.numOfRecordsPerPage);return e.slice(r,n)}getFilteredRecords(e,t){let r=e;return t.forEach(((e,t)=>{e.column_id=e.filter_column_id,r=self.getFilteredRecordsFromSingleFilter(r,e)})),r}getSearchedRecords(e,t,r,n=""){if(null==t||0==t.length)return e;t=t.toLowerCase();const o=n?n.split(",").map((e=>e.trim())).filter((e=>""!==e)):[],l=new Set;return o.length>0&&r.forEach(((e,t)=>{if(e&&void 0!==e.id&&null!==e.id){const r=String(e.id);o.some((e=>String(e)===r))&&l.add(t)}})),e.filter((function(e){let n=!1;for(let o=0;o<e.content.length;o++){if(l.has(o))continue;const s=e.content[o];let i=s.value,c=!1;const a=r[o].format;let d={isContentMatch:c,searchQuery:t,cell:s,cellType:a,column:r[o]};d=self.hooks.applyFilters("getSearchRecords",d),c=d.isContentMatch,"file"==a?c=parseInt(t)==parseInt(i)||c:c||(i="string"==typeof i?i.toLowerCase():"",c=i.toLowerCase().indexOf(t)>=0||c),c&&(n=!0)}return n}))}getSortedRecords(e,t){const r=t.order;return null==r||e.sort(((e,n)=>{let o={};if(-1==t.index){let r,l,s;"created_at"==t.field||"updated_at"==t.field?(r=new Date(e[t.field]).getTime()/1e3,l=new Date(n[t.field]).getTime()/1e3,s="number"):(r=e[t.field],l=n[t.field],s="text"),o={valueA:r,valueB:l,rowA:e[t.field],rowB:n[t.field],cellType:"text",sortType:s}}else o={valueA:"",valueB:"",rowA:e.content[t.index],rowB:n.content[t.index],cellType:t.column.format,sortType:"text"},o=self.hooks.applyFilters("getSortRecords",o);let l=o.valueA,s=o.valueB;return l===s?0:0==l.length?1:0==s.length?-1:"desc"==r?"number"==o.sortType?s-l:l<s?1:-1:"number"==o.sortType?l-s:l<s?-1:1})),e}getFilteredRecordsFromSingleFilter(e,t){return e.filter((function(e){let r=e.content[t.column_index].value;t.value;"textarea"==t.format&&(r=e.content[t.column_index].html,r=r.replace(/<[^>]+>/g,""));const n=null===r||""==r;if("empty"===t.operator.value)return n;if("not_empty"===t.operator.value)return!n;let o=!1,l={isContentMatch:o,filter:t,cell:e.content[t.column_index]};return l=self.hooks.applyFilters("getFilterRecords",l),o=l.isContentMatch,o}))}filterText(e,t,r){return t=t.toLowerCase(),r=r.toLowerCase(),"is"==e?t==r:"is_not"==e?t!=r:"contains"==e?t.includes(r):"does_not_contain"==e?!t.includes(r):"starts_with"==e?t.startsWith(r):"ends_with"==e?t.endsWith(r):"empty"==e||"not_empty"==e?t<=r:void 0}filterNumber(e,t,r){return"="==e?t==r:"!="==e?t!=r:">"==e?t>r:"<"==e?t<r:">="==e?t>=r:"<="==e?t<=r:void 0}}export default ReducersClass;