/*!*************************************************** * datatables.mark.js v3.0.0 * https://github.com/julmot/datatables.mark.js * Copyright (c) 2016–2020, Julian Kühnel, SpryMedia Ltd * Released under the MIT license https://git.io/voRZ7 *****************************************************/ import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;class MarkDataTables{instance;options;intervalThreshold;intervalMs;constructor(t,a){if(!$.fn.mark||!$.fn.unmark)throw new Error("jquery.mark.js is necessary for datatables.mark.js");this.instance=t,this.options="object"==typeof a?a:{},this.intervalThreshold=49,this.intervalMs=300,this.initMarkListener()}initMarkListener(){let t="draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth",a=(t+=" responsive-display.dt.dth",null);this.instance.on(t,()=>{this.instance.rows({filter:"applied",page:"current"}).nodes().length>this.intervalThreshold?(clearTimeout(a),a=setTimeout(()=>{this.mark()},this.intervalMs)):this.mark()}),this.instance.on("destroy",()=>{this.instance.off(t)}),this.mark()}mark(){const i=this.instance.search();var t=$(this.instance.table().body());t.unmark(this.options),this.instance.table().rows({search:"applied"}).data().length&&t.mark(i,this.options),this.instance.columns({search:"applied",page:"current"}).nodes().each((t,a)=>{const e=this.instance.column(a).search(),s=e||i;s&&t.forEach(t=>{$(t).unmark(this.options).mark(s,this.options)})})}}$(document).on("init.dt.dth",(a,e)=>{if("dt"===a.namespace){a=new DataTable.Api(e);let t=!1;a.init().mark?t=a.init().mark:DataTable.defaults.mark&&(t=DataTable.defaults.mark),t&&new MarkDataTables(a,t)}});export default DataTable;