smeserver-manager-jsquery/root/usr/share/javascript/StateRestore/js/dataTables.stateRestore.min.mjs

7 lines
42 KiB
JavaScript

/*! StateRestore 1.4.1
* © SpryMedia Ltd - datatables.net/license
*/
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;!function(){"use strict";var u,m;n.prototype.remove=function(e){var t,s,o,a,i=this;return void 0===e&&(e=!1),!!this.c.remove&&(o={action:"remove",stateRestore:((t={})[this.s.identifier]=this.s.savedState,t)},a=function(){i.dom.confirmation.trigger("dtsr-remove"),u(i.s.dt.table().node()).trigger("stateRestore-change"),i.dom.background.click(),i.dom.confirmation.remove(),u(document).unbind("keyup",function(e){return i._keyupFunction(e)}),i.dom.confirmationButton.off("click")},this.c.ajax?"string"==typeof this.c.ajax&&this.s.dt.settings()[0]._bInitComplete?s=function(){return u.ajax({data:o,success:a,type:"POST",url:i.c.ajax}),!0}:"function"==typeof this.c.ajax&&(s=function(){return"function"==typeof i.c.ajax&&i.c.ajax.call(i.s.dt,o,a),!0}):s=function(){try{localStorage.removeItem("DataTables_stateRestore_"+i.s.identifier+"_"+location.pathname+(i.s.tableId?"_"+i.s.tableId:"")),a()}catch(e){return i.dom.confirmation.children("."+i.classes.modalError).remove(),i.dom.confirmation.append(i.dom.removeError),"remove"}return!0},e?(this.dom.confirmation.appendTo(this.dom.dtContainer),u(this.s.dt.table().node()).trigger("dtsr-modal-inserted"),s(),this.dom.confirmation.remove()):this._newModal(this.dom.removeTitle,this.s.dt.i18n("stateRestore.removeSubmit",this.c.i18n.removeSubmit),s,this.dom.removeContents),!0)},n.prototype.compare=function(e){if(this.c.saveState.order||(e.order=void 0),this.c.saveState.search||(e.search=void 0),this.c.saveState.columns&&e.columns)for(var t=0,s=e.columns.length;t<s;t++)"boolean"==typeof this.c.saveState.columns||this.c.saveState.columns.visible||(e.columns[t].visible=void 0),"boolean"==typeof this.c.saveState.columns||this.c.saveState.columns.search||(e.columns[t].search=void 0);else this.c.saveState.columns||(e.columns=void 0);this.c.saveState.paging||(e.page=void 0),this.c.saveState.searchBuilder||(e.searchBuilder=void 0),this.c.saveState.searchPanes||(e.searchPanes=void 0),this.c.saveState.select||(e.select=void 0),this.c.saveState.colReorder||(e.ColReorder=void 0),this.c.saveState.scroller||(e.scroller=void 0)!==m.Scroller&&(e.start=0),this.c.saveState.paging||(e.start=0),this.c.saveState.length||(e.length=void 0),delete e.time;var o=this.s.savedState;return delete o.time,delete o.c,delete o.stateRestore,this._deepCompare(e,o)},n.prototype.destroy=function(){u.each(this.dom,function(e,t){t.off().remove()})},n.prototype.load=function(){function e(){o.s.dt.one("preDraw",function(e,s){setTimeout(function(){var e=s._iDisplayStart/s._iDisplayLength,t=a.start/a.length;0<=e&&0<=t&&e!=t&&o.s.dt.page(t).draw(!1)},50)}),o.s.dt.draw(!1)}var o=this,a=this.s.savedState,t=this.s.dt.settings()[0];a.time=+new Date,t.oLoadedState=u.extend(!0,{},a),u("div.dt-button-background").click();return DataTable.versionCheck("2")?(this.s.dt.state(a),e()):DataTable.ext.oApi._fnImplementState(t,a,e),a},n.prototype.rename=function(s,o){var a=this;if(void 0===s&&(s=null),this.c.rename){var e=function(){if(null===s){var e=u("input."+a.classes.input.replace(/ /g,".")).val();if(0===e.length)return a.dom.confirmation.children("."+a.classes.modalError).remove(),a.dom.confirmation.append(a.dom.emptyError),"empty";if(o.includes(e))return a.dom.confirmation.children("."+a.classes.modalError).remove(),a.dom.confirmation.append(a.dom.duplicateError),"duplicate";s=e}function t(){a.s.identifier=s,a.save(a.s.savedState,function(){return null},!1),a.dom.removeContents=u('<div class="'+a.classes.confirmationText+'"><span>'+a.s.dt.i18n("stateRestore.removeConfirm",a.c.i18n.removeConfirm).replace(/%s/g,a.s.identifier)+"</span></div>"),a.dom.confirmation.trigger("dtsr-rename"),a.dom.background.click(),a.dom.confirmation.remove(),u(document).unbind("keyup",function(e){return a._keyupFunction(e)}),a.dom.confirmationButton.off("click")}e={action:"rename",stateRestore:((e={})[a.s.identifier]=s,e)};if(a.c.ajax)"string"==typeof a.c.ajax&&a.s.dt.settings()[0]._bInitComplete?u.ajax({data:e,success:t,type:"POST",url:a.c.ajax}):"function"==typeof a.c.ajax&&a.c.ajax.call(a.s.dt,e,t);else try{localStorage.removeItem("DataTables_stateRestore_"+a.s.identifier+"_"+location.pathname+(a.s.tableId?"_"+a.s.tableId:"")),t()}catch(e){return a.dom.confirmation.children("."+a.classes.modalError).remove(),a.dom.confirmation.append(a.dom.removeError),!1}return!0};if(null!==s){if(o.includes(s))throw new Error(this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError));if(0===s.length)throw new Error(this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError));this.dom.confirmation.appendTo(this.dom.dtContainer),u(this.s.dt.table().node()).trigger("dtsr-modal-inserted"),e(),this.dom.confirmation.remove()}else this.dom.renameInput.val(this.s.identifier),this.dom.renameContents.append(this.dom.renameInput),this._newModal(this.dom.renameTitle,this.s.dt.i18n("stateRestore.renameButton",this.c.i18n.renameButton),e,this.dom.renameContents)}},n.prototype.save=function(e,t,s){var o,a,i,n=this;if(void 0===s&&(s=!0),this.c.save){if(this.s.dt.state.save(),void 0===e)o=this.s.dt.state();else{if("object"!=typeof e)return;o=e}if(o.stateRestore?(o.stateRestore.isPreDefined=this.s.isPreDefined,o.stateRestore.state=this.s.identifier,o.stateRestore.tableId=this.s.tableId):o.stateRestore={isPreDefined:this.s.isPreDefined,state:this.s.identifier,tableId:this.s.tableId},this.s.savedState=o,this.c.saveState.order||(this.s.savedState.order=void 0),this.c.saveState.search||(this.s.savedState.search=void 0),this.c.saveState.columns&&this.s.savedState.columns)for(var r=0,c=this.s.savedState.columns.length;r<c;r++)"boolean"==typeof this.c.saveState.columns||this.c.saveState.columns.visible||(this.s.savedState.columns[r].visible=void 0),"boolean"==typeof this.c.saveState.columns||this.c.saveState.columns.search||(this.s.savedState.columns[r].search=void 0);else this.c.saveState.columns||(this.s.savedState.columns=void 0);if(this.c.saveState.searchBuilder||(this.s.savedState.searchBuilder=void 0),this.c.saveState.searchPanes||(this.s.savedState.searchPanes=void 0),this.c.saveState.select||(this.s.savedState.select=void 0),this.c.saveState.colReorder||(this.s.savedState.ColReorder=void 0),this.c.saveState.scroller||(this.s.savedState.scroller=void 0)!==m.Scroller&&(this.s.savedState.start=0),this.c.saveState.paging||(this.s.savedState.start=0),this.c.saveState.length||(this.s.savedState.length=void 0),this.s.savedState.c=this.c,this.s.savedState.c.splitSecondaries.length)for(var l=0,d=this.s.savedState.c.splitSecondaries;l<d.length;l++){var h=d[l];h.parent&&(h.parent=void 0)}this.s.isPreDefined?t&&t.call(this):(a={action:"save",stateRestore:((e={})[this.s.identifier]=this.s.savedState,e)},i=function(){t&&t.call(n),n.dom.confirmation.trigger("dtsr-save"),u(n.s.dt.table().node()).trigger("stateRestore-change")},this.c.ajax?"string"==typeof this.c.ajax&&s?this.s.dt.settings()[0]._bInitComplete?u.ajax({data:a,success:i,type:"POST",url:this.c.ajax}):this.s.dt.one("init",function(){u.ajax({data:a,success:i,type:"POST",url:n.c.ajax})}):"function"==typeof this.c.ajax&&s&&this.c.ajax.call(this.s.dt,a,i):(localStorage.setItem("DataTables_stateRestore_"+this.s.identifier+"_"+location.pathname+(this.s.tableId?"_"+this.s.tableId:""),JSON.stringify(this.s.savedState)),i()))}else t&&t.call(this)},n.entityEncode=function(e){return"string"==typeof e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):e},n.prototype._deepCompare=function(e,t){var s,o,a=[e,t],i=[Object.keys(e).sort(),Object.keys(t).sort()];for(i[0].includes("scroller")&&(s=i[0].indexOf("start"))&&i[0].splice(s,1),i[1].includes("scroller")&&(s=i[1].indexOf("start"))&&i[1].splice(s,1),o=0;o<i[0].length;o++)0!==i[0][o].indexOf("_")&&"baseRowTop"!==i[0][o]&&"baseScrollTop"!==i[0][o]&&"scrollTop"!==i[0][o]&&(this.c.saveState.paging||"page"!==i[0][o])||(i[0].splice(o,1),o--);for(o=0;o<i[1].length;o++)0!==i[1][o].indexOf("_")&&"baseRowTop"!==i[1][o]&&"baseScrollTop"!==i[1][o]&&"scrollTop"!==i[1][o]&&(this.c.saveState.paging||"page"!==i[0][o])||(i[1].splice(o,1),o--);if(0===i[0].length&&0<i[1].length||0===i[1].length&&0<i[0].length)return!1;for(o=0;o<i[0].length;o++)i[1].includes(i[0][o])||(i[0].splice(o,1),o--);for(o=0;o<i[1].length;o++)i[0].includes(i[1][o])||(i[1].splice(o,1),o--);for(o=0;o<i[0].length;o++){if(i[0][o]!==i[1][o]||typeof a[0][i[0][o]]!=typeof a[1][i[1][o]])return!1;if("object"==typeof a[0][i[0][o]]){if(!this._deepCompare(a[0][i[0][o]],a[1][i[1][o]]))return!1}else if("number"==typeof a[0][i[0][o]]&&"number"==typeof a[1][i[1][o]]){if(Math.round(a[0][i[0][o]])!==Math.round(a[1][i[1][o]]))return!1}else if(a[0][i[0][o]]!==a[1][i[1][o]])return!1}return!0},n.prototype._keyupFunction=function(e){"Enter"===e.key?this.dom.confirmationButton.click():"Escape"===e.key&&u("div."+this.classes.background.replace(/ /g,".")).click()},n.prototype._newModal=function(e,t,s,o){var a=this,e=(this.dom.background.appendTo(this.dom.dtContainer),this.dom.confirmationTitleRow.empty().append(e),this.dom.confirmationButton.html(t),this.dom.confirmation.empty().append(this.dom.confirmationTitleRow).append(o).append(u('<div class="'+this.classes.confirmationButtons+'"></div>').append(this.dom.confirmationButton)).appendTo(this.dom.dtContainer),u(this.s.dt.table().node()).trigger("dtsr-modal-inserted"),o.children("input")),i=((0<e.length?u(e[0]):this.dom.confirmationButton).focus(),u("div."+this.classes.background.replace(/ /g,".")));this.c.modalCloseButton&&(this.dom.confirmation.append(this.dom.closeButton),this.dom.closeButton.on("click",function(){return i.click()})),this.dom.confirmationButton.on("click",function(){return s()}),this.dom.confirmation.on("click",function(e){e.stopPropagation()}),i.one("click",function(){a.dom.background.remove(),a.dom.confirmation.remove(),u(document).unbind("keyup",function(e){return a._keyupFunction(e)})}),u(document).on("keyup",function(e){return a._keyupFunction(e)})},n.version="1.4.1",n.classes={background:"dtsr-background",closeButton:"dtsr-popover-close",confirmation:"dtsr-confirmation",confirmationButton:"dtsr-confirmation-button",confirmationButtons:"dtsr-confirmation-buttons",confirmationMessage:"dtsr-confirmation-message dtsr-name-label",confirmationText:"dtsr-confirmation-text",confirmationTitle:"dtsr-confirmation-title",confirmationTitleRow:"dtsr-confirmation-title-row",dtButton:"dt-button",input:"dtsr-input",modalError:"dtsr-modal-error",renameModal:"dtsr-rename-modal"},n.defaults={_createInSaved:!1,ajax:!1,create:!0,creationModal:!1,i18n:{creationModal:{button:"Create",colReorder:"Column Order:",columns:{search:"Column Search:",visible:"Column Visibility:"},length:"Page Length:",name:"Name:",order:"Sorting:",paging:"Paging:",scroller:"Scroll Position:",search:"Search:",searchBuilder:"SearchBuilder:",searchPanes:"SearchPanes:",select:"Select:",title:"Create New State",toggleLabel:"Includes:"},duplicateError:"A state with this name already exists.",emptyError:"Name cannot be empty.",emptyStates:"No saved states",removeConfirm:"Are you sure you want to remove %s?",removeError:"Failed to remove state.",removeJoiner:" and ",removeSubmit:"Remove",removeTitle:"Remove State",renameButton:"Rename",renameLabel:"New Name for %s:",renameTitle:"Rename State"},modalCloseButton:!0,remove:!0,rename:!0,save:!0,saveState:{colReorder:!0,columns:{search:!0,visible:!0},length:!0,order:!0,paging:!0,scroller:!0,search:!0,searchBuilder:!0,searchPanes:!0,select:!0},splitSecondaries:["updateState","renameState","removeState"],toggle:{colReorder:!1,columns:{search:!1,visible:!1},length:!1,order:!1,paging:!1,scroller:!1,search:!1,searchBuilder:!1,searchPanes:!1,select:!1}};var g,i,y=n;function n(e,t,s,o,a,i){if(void 0===o&&(o=void 0),void 0===a&&(a=!1),void 0===i&&(i=function(){return null}),!m||!m.versionCheck||!m.versionCheck("1.10.0"))throw new Error("StateRestore requires DataTables 1.10 or newer");if(!m.Buttons)throw new Error("StateRestore requires Buttons");e=new m.Api(e);this.classes=u.extend(!0,{},n.classes),this.c=u.extend(!0,{},n.defaults,t),this.s={dt:e,identifier:s,isPreDefined:a,savedState:null,tableId:o&&o.stateRestore?o.stateRestore.tableId:void 0},this.dom={background:u('<div class="'+this.classes.background+'"/>'),closeButton:u('<div class="'+this.classes.closeButton+'">&times;</div>'),confirmation:u('<div class="'+this.classes.confirmation+'"/>'),confirmationButton:u('<button class="'+this.classes.confirmationButton+" "+this.classes.dtButton+'">'),confirmationTitleRow:u('<div class="'+this.classes.confirmationTitleRow+'"></div>'),dtContainer:u(this.s.dt.table().container()),duplicateError:u('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError)+"</span>"),emptyError:u('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError)+"</span>"),removeContents:u('<div class="'+this.classes.confirmationText+'"><span>'+this.s.dt.i18n("stateRestore.removeConfirm",this.c.i18n.removeConfirm).replace(/%s/g,n.entityEncode(this.s.identifier))+"</span></div>"),removeError:u('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.removeError",this.c.i18n.removeError)+"</span>"),removeTitle:u('<h2 class="'+this.classes.confirmationTitle+'">'+this.s.dt.i18n("stateRestore.removeTitle",this.c.i18n.removeTitle)+"</h2>"),renameContents:u('<div class="'+this.classes.confirmationText+" "+this.classes.renameModal+'"><label class="'+this.classes.confirmationMessage+'">'+this.s.dt.i18n("stateRestore.renameLabel",this.c.i18n.renameLabel).replace(/%s/g,n.entityEncode(this.s.identifier))+"</label></div>"),renameInput:u('<input class="'+this.classes.input+'" type="text"></input>'),renameTitle:u('<h2 class="'+this.classes.confirmationTitle+'">'+this.s.dt.i18n("stateRestore.renameTitle",this.c.i18n.renameTitle)+"</h2>")},this.save(o,i)}r.prototype.addState=function(e,u,m){var v=this;if(this.c.create&&this.c.save){var t=function(e,t){if(0===e.length)return"empty";if(u.includes(e))return"duplicate";v.s.dt.state.save();var s=v,o=v.s.dt.state();if(o.stateRestore={isPredefined:!1,state:e,tableId:v.s.dt.table().node().id},t.saveState){for(var a=v.c.saveState,i=0,n=Object.keys(t.saveState);i<n.length;i++){var r=n[i];if("object"==typeof t.saveState[r])for(var c=0,l=Object.keys(t.saveState[r]);c<l.length;c++){var d=l[c];t.saveState[r][d]||(a[r][d]=!1)}else t.saveState[r]||(a[r]=!1)}v.c.saveState=a}var h=new y(v.s.dt.settings()[0],g.extend(!0,{},v.c,m),e,o,!1,function(){s.s.states.push(this),s._collectionRebuild()});return g(v.s.dt.table().node()).on("dtsr-modal-inserted",function(){h.dom.confirmation.one("dtsr-remove",function(){return v._removeCallback(h.s.identifier)}),h.dom.confirmation.one("dtsr-rename",function(){return v._collectionRebuild()}),h.dom.confirmation.one("dtsr-save",function(){return v._collectionRebuild()})}),!0};if(null!==this.getState(e))throw new Error(this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError));if(this.c.creationModal||void 0!==m&&m.creationModal)this._creationModal(t,e,m);else{t=t(e,{});if("empty"===t)throw new Error(this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError));if("duplicate"===t)throw new Error(this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError))}}},r.prototype.removeAll=function(e){var t,s;0!==this.s.states.length&&(s=(t=this.s.states.map(function(e){return e.s.identifier}))[0],1<t.length&&(s=t.slice(0,-1).join(", ")+this.s.dt.i18n("stateRestore.removeJoiner",this.c.i18n.removeJoiner)+t.slice(-1)),g(this.dom.removeContents.children("span")).html(this.s.dt.i18n("stateRestore.removeConfirm",this.c.i18n.removeConfirm).replace(/%s/g,s)),this._newModal(this.dom.removeTitle,this.s.dt.i18n("stateRestore.removeSubmit",this.c.i18n.removeSubmit),e,this.dom.removeContents))},r.prototype.destroy=function(){for(var e=0,t=this.s.states;e<t.length;e++)t[e].destroy();g.each(this.dom,function(e,t){t.off().remove()}),this.s.states=[],this.s.dt.off(".dtsr"),g(this.s.dt.table().node()).off(".dtsr")},r.prototype.findActive=function(){this.s.dt.state.save();for(var e=this.s.dt.state(),t=this.s.dt.buttons().nodes(),s=0,o=t;s<o.length;s++)d=o[s],(g(d).hasClass("dtsr-state")||g(d).children().hasClass("dtsr-state"))&&this.s.dt.button(d).active(!1);for(var a=[],i=0,n=this.s.states;i<n.length;i++){var r=n[i];if(r.compare(e)){a.push({data:r.s.savedState,name:r.s.identifier});for(var c=0,l=t;c<l.length;c++){var d=l[c],h=this.s.dt.button(d);if(h.text()===r.s.identifier){h.active(!0);break}}}}return a},r.prototype.getState=function(e){for(var t=0,s=this.s.states;t<s.length;t++){var o=s[t];if(o.s.identifier===e)return o}return null},r.prototype.getStates=function(e){if(void 0===e)return this.s.states;for(var t=[],s=0,o=e;s<o.length;s++){for(var a=o[s],i=!1,n=0,r=this.s.states;n<r.length;n++){var c=r[n];if(a===c.s.identifier){t.push(c),i=!0;break}}i||t.push(void 0)}return t},r.prototype._addPreDefined=function(i){for(var n=this,e=Object.keys(i).sort(function(e,t){return t<e?1:e<t?-1:0}),r=this,t=0,s=e;t<s.length;t++)!function(e){for(var t=0;t<r.s.states.length;t++)r.s.states[t].s.identifier===e&&r.s.states.splice(t,1);var s=r,o=i[e],a=new y(r.s.dt,g.extend(!0,{},r.c,void 0!==o.c?{saveState:o.c.saveState}:void 0,!0),e,o,!0,function(){s.s.states.push(this),s._collectionRebuild()});a.s.savedState=o,g(r.s.dt.table().node()).on("dtsr-modal-inserted",function(){a.dom.confirmation.one("dtsr-remove",function(){return n._removeCallback(a.s.identifier)}),a.dom.confirmation.one("dtsr-rename",function(){return n._collectionRebuild()}),a.dom.confirmation.one("dtsr-save",function(){return n._collectionRebuild()})})}(s[t])},r.prototype._collectionRebuild=function(){var e=this.s.dt.button("SaveStateRestore:name"),t=[];if(e[0])for(var s=e.index().split("-"),t=e[0].inst.c.buttons,o=0;o<s.length;o++){if(!t[s[o]].buttons){t=[];break}t=t[s[o]].buttons}for(o=0;o<t.length;o++)"stateRestore"===t[o].extend&&(t.splice(o,1),o--);this.c._createInSaved&&t.push("createState");var a='<span class="'+this.classes.emptyStates+'">'+this.s.dt.i18n("stateRestore.emptyStates",this.c.i18n.emptyStates)+"</span>";if(0===this.s.states.length)t.includes(a)||t.push(a);else{for(;t.includes(a);)t.splice(t.indexOf(a),1);this.s.states=this.s.states.sort(function(e,t){e=e.s.identifier,t=t.s.identifier;return t<e?1:e<t?-1:0});for(var i=0,n=this.s.states;i<n.length;i++){var r=n[i],c=this.c.splitSecondaries.slice();!c.includes("updateState")||this.c.save&&r.c.save||c.splice(c.indexOf("updateState"),1),!c.includes("renameState")||this.c.save&&r.c.save&&this.c.rename&&r.c.rename||c.splice(c.indexOf("renameState"),1),!c.includes("removeState")||this.c.remove&&r.c.remove||c.splice(c.indexOf("removeState"),1),t.push({_stateRestore:r,attr:{title:r.s.identifier},config:{split:c},extend:"stateRestore",text:y.entityEncode(r.s.identifier),popoverTitle:y.entityEncode(r.s.identifier)})}}e.collectionRebuild(t);for(var l=0,d=this.s.dt.buttons();l<d.length;l++){var h=d[l];g(h.node).hasClass("dtsr-removeAllStates")&&(0===this.s.states.length?this.s.dt.button(h.node).disable():this.s.dt.button(h.node).enable())}},r.prototype._creationModal=function(t,e,s){for(var o,a=this,e=(this.dom.creation.empty(),this.dom.creationForm.empty(),this.dom.nameInputRow.find("input").val(e),this.dom.creationForm.append(this.dom.nameInputRow),this.s.dt.settings()[0].oInit),i=[],n=void 0!==s&&void 0!==s.toggle,r=(((!n||void 0===s.toggle.order)&&this.c.toggle.order||n&&s.toggle.order)&&this.c.saveState.order&&(void 0===e.ordering||e.ordering)&&i.push(this.dom.orderToggle),((!n||void 0===s.toggle.search)&&this.c.toggle.search||n&&s.toggle.search)&&this.c.saveState.search&&(void 0===e.searching||e.searching)&&i.push(this.dom.searchToggle),((!n||void 0===s.toggle.paging)&&this.c.toggle.paging||n&&s.toggle.paging)&&this.c.saveState.paging&&(void 0===e.paging||e.paging)&&i.push(this.dom.pagingToggle),((!n||void 0===s.toggle.length)&&this.c.toggle.length||n&&s.toggle.length)&&this.c.saveState.length&&(void 0===e.length||e.length)&&i.push(this.dom.lengthToggle),this.s.hasColReorder&&((!n||void 0===s.toggle.colReorder)&&this.c.toggle.colReorder||n&&s.toggle.colReorder)&&this.c.saveState.colReorder&&i.push(this.dom.colReorderToggle),this.s.hasScroller&&((!n||void 0===s.toggle.scroller)&&this.c.toggle.scroller||n&&s.toggle.scroller)&&this.c.saveState.scroller&&i.push(this.dom.scrollerToggle),this.s.hasSearchBuilder&&((!n||void 0===s.toggle.searchBuilder)&&this.c.toggle.searchBuilder||n&&s.toggle.searchBuilder)&&this.c.saveState.searchBuilder&&i.push(this.dom.searchBuilderToggle),this.s.hasSearchPanes&&((!n||void 0===s.toggle.searchPanes)&&this.c.toggle.searchPanes||n&&s.toggle.searchPanes)&&this.c.saveState.searchPanes&&i.push(this.dom.searchPanesToggle),this.s.hasSelect&&((!n||void 0===s.toggle.select)&&this.c.toggle.select||n&&s.toggle.select)&&this.c.saveState.select&&i.push(this.dom.selectToggle),"boolean"==typeof this.c.toggle.columns&&((!n||void 0===s.toggle.order)&&this.c.toggle.columns||n&&s.toggle.order)&&this.c.saveState.columns?(i.push(this.dom.columnsSearchToggle),i.push(this.dom.columnsVisibleToggle)):(n&&void 0!==s.toggle.columns||"boolean"==typeof this.c.toggle.columns)&&"boolean"==typeof s.toggle.order||("boolean"!=typeof this.c.saveState.columns&&this.c.saveState.columns?((n&&void 0!==s.toggle.columns&&"boolean"!=typeof s.toggle.columns&&s.toggle.columns.search||(!n||void 0===s.toggle.columns||"boolean"!=typeof s.toggle.columns&&void 0===s.toggle.columns.search)&&"boolean"!=typeof this.c.toggle.columns&&this.c.toggle.columns.search)&&this.c.saveState.columns.search&&i.push(this.dom.columnsSearchToggle),(n&&void 0!==s.toggle.columns&&"boolean"!=typeof s.toggle.columns&&s.toggle.columns.visible||(!n||void 0===s.toggle.columns||"boolean"!=typeof s.toggle.columns&&void 0===s.toggle.columns.visible)&&"boolean"!=typeof this.c.toggle.columns&&this.c.toggle.columns.visible)&&this.c.saveState.columns.visible&&i.push(this.dom.columnsVisibleToggle)):this.c.saveState.columns&&(i.push(this.dom.columnsSearchToggle),i.push(this.dom.columnsVisibleToggle))),i.sort(function(e,t){e=e.text(),t=t.text();return e<t?-1:t<e?1:0}),this.dom.checkboxInputRow.appendTo(this.dom.creationForm).find("div.dtsr-input").empty()),c=0,l=i;c<l.length;c++)o=l[c],r.append(o);this.dom.background.appendTo(this.dom.dtContainer),this.dom.creation.append(this.dom.creationTitle).append(this.dom.creationForm).append(this.dom.createButtonRow).appendTo(this.dom.dtContainer),g(this.s.dt.table().node()).trigger("dtsr-modal-inserted");for(var d=0,h=i;d<h.length;d++)g((o=h[d]).children("label:last-child")).on("click",function(){o.children("input").prop("checked",!o.children("input").prop("checked"))});function u(e){"Enter"===e.key?m.click():"Escape"===e.key&&v.click()}var m=g("button."+this.classes.creationButton.replace(/ /g,".")),e=this.dom.creationForm.find("input"),v=((0<e.length?g(e[0]):m).focus(),g("div."+this.classes.background.replace(/ /g,".")));this.c.modalCloseButton&&(this.dom.creation.append(this.dom.closeButton),this.dom.closeButton.on("click",function(){return v.click()})),m.on("click",function(){var e={colReorder:a.dom.colReorderToggle.find("input").is(":checked"),columns:{search:a.dom.columnsSearchToggle.find("input").is(":checked"),visible:a.dom.columnsVisibleToggle.find("input").is(":checked")},length:a.dom.lengthToggle.find("input").is(":checked"),order:a.dom.orderToggle.find("input").is(":checked"),paging:a.dom.pagingToggle.find("input").is(":checked"),scroller:a.dom.scrollerToggle.find("input").is(":checked"),search:a.dom.searchToggle.find("input").is(":checked"),searchBuilder:a.dom.searchBuilderToggle.find("input").is(":checked"),searchPanes:a.dom.searchPanesToggle.find("input").is(":checked"),select:a.dom.selectToggle.find("input").is(":checked")},e=t(g("input."+a.classes.nameInput.replace(/ /g,".")).val(),{saveState:e});!0===e?(a.dom.background.remove(),a.dom.creation.remove(),g(document).unbind("keyup",u)):(a.dom.creation.children("."+a.classes.modalError).remove(),a.dom.creation.append(a.dom[e+"Error"]))}),v.one("click",function(){a.dom.background.remove(),a.dom.creation.remove(),g(document).unbind("keyup",u),a._collectionRebuild()}),g(document).on("keyup",u),this.s.dt.state.save()},r.prototype._removeCallback=function(e){for(var t=0;t<this.s.states.length;t++)this.s.states[t].s.identifier===e&&(this.s.states.splice(t,1),t--);return this._collectionRebuild(),!0},r.prototype._newModal=function(e,t,s,o){function a(e){"Enter"===e.key?n.click():"Escape"===e.key&&r.click()}var i=this,n=(this.dom.background.appendTo(this.dom.dtContainer),this.dom.confirmationTitleRow.empty().append(e),g('<button class="'+this.classes.confirmationButton+" "+this.classes.dtButton+'">'+t+"</button>")),e=(this.dom.confirmation.empty().append(this.dom.confirmationTitleRow).append(o).append(g('<div class="'+this.classes.confirmationButtons+'"></div>').append(n)).appendTo(this.dom.dtContainer),g(this.s.dt.table().node()).trigger("dtsr-modal-inserted"),o.children("input")),r=((0<e.length?g(e[0]):n).focus(),g("div."+this.classes.background.replace(/ /g,".")));n.on("click",function(){var e=s(!0);!0===e?(i.dom.background.remove(),i.dom.confirmation.remove(),g(document).unbind("keyup",a),n.off("click")):(i.dom.confirmation.children("."+i.classes.modalError).remove(),i.dom.confirmation.append(i.dom[e+"Error"]))}),this.dom.confirmation.on("click",function(e){e.stopPropagation()}),r.one("click",function(){i.dom.background.remove(),i.dom.confirmation.remove(),g(document).unbind("keyup",a)}),g(document).on("keyup",a)},r.prototype._searchForStates=function(){for(var a=this,e=Object.keys(localStorage),i=this,t=0,s=e;t<s.length;t++)!function(e){if(e.match(new RegExp("^DataTables_stateRestore_.*_"+location.pathname+"$"))||e.match(new RegExp("^DataTables_stateRestore_.*_"+location.pathname+"_"+i.s.dt.table().node().id+"$"))){var t=JSON.parse(localStorage.getItem(e));if(t.stateRestore.isPreDefined||t.stateRestore.tableId&&t.stateRestore.tableId!==i.s.dt.table().node().id)return;var s=i,o=new y(i.s.dt,g.extend(!0,{},i.c,{saveState:t.c.saveState}),t.stateRestore.state,t,!1,function(){this.s.savedState=t,s.s.states.push(this),s._collectionRebuild()});g(i.s.dt.table().node()).on("dtsr-modal-inserted",function(){o.dom.confirmation.one("dtsr-remove",function(){return a._removeCallback(o.s.identifier)}),o.dom.confirmation.one("dtsr-rename",function(){return a._collectionRebuild()}),o.dom.confirmation.one("dtsr-save",function(){return a._collectionRebuild()})})}}(s[t])},r.version="1.0.0",r.classes={background:"dtsr-background",checkBox:"dtsr-check-box",checkLabel:"dtsr-check-label",checkRow:"dtsr-check-row",closeButton:"dtsr-popover-close",colReorderToggle:"dtsr-colReorder-toggle",columnsSearchToggle:"dtsr-columns-search-toggle",columnsVisibleToggle:"dtsr-columns-visible-toggle",confirmation:"dtsr-confirmation",confirmationButton:"dtsr-confirmation-button",confirmationButtons:"dtsr-confirmation-buttons",confirmationMessage:"dtsr-confirmation-message dtsr-name-label",confirmationText:"dtsr-confirmation-text",confirmationTitle:"dtsr-confirmation-title",confirmationTitleRow:"dtsr-confirmation-title-row",creation:"dtsr-creation",creationButton:"dtsr-creation-button",creationForm:"dtsr-creation-form",creationText:"dtsr-creation-text",creationTitle:"dtsr-creation-title",dtButton:"dt-button",emptyStates:"dtsr-emptyStates",formRow:"dtsr-form-row",leftSide:"dtsr-left",lengthToggle:"dtsr-length-toggle",modalError:"dtsr-modal-error",modalFoot:"dtsr-modal-foot",nameInput:"dtsr-name-input",nameLabel:"dtsr-name-label",orderToggle:"dtsr-order-toggle",pagingToggle:"dtsr-paging-toggle",rightSide:"dtsr-right",scrollerToggle:"dtsr-scroller-toggle",searchBuilderToggle:"dtsr-searchBuilder-toggle",searchPanesToggle:"dtsr-searchPanes-toggle",searchToggle:"dtsr-search-toggle",selectToggle:"dtsr-select-toggle",toggleLabel:"dtsr-toggle-title"},r.defaults={_createInSaved:!1,ajax:!1,create:!0,creationModal:!1,i18n:{creationModal:{button:"Create",colReorder:"Column Order",columns:{search:"Column Search",visible:"Column Visibility"},length:"Page Length",name:"Name:",order:"Sorting",paging:"Paging",scroller:"Scroll Position",search:"Search",searchBuilder:"SearchBuilder",searchPanes:"SearchPanes",select:"Select",title:"Create New State",toggleLabel:"Include:"},duplicateError:"A state with this name already exists.",emptyError:"Name cannot be empty.",emptyStates:"No saved states",removeConfirm:"Are you sure you want to remove %s?",removeError:"Failed to remove state.",removeJoiner:" and ",removeSubmit:"Remove",removeTitle:"Remove State",renameButton:"Rename",renameLabel:"New Name for %s:",renameTitle:"Rename State"},modalCloseButton:!0,preDefined:{},remove:!0,rename:!0,save:!0,saveState:{colReorder:!0,columns:{search:!0,visible:!0},length:!0,order:!0,paging:!0,scroller:!0,search:!0,searchBuilder:!0,searchPanes:!0,select:!0},splitSecondaries:["updateState","renameState","removeState"],toggle:{colReorder:!1,columns:{search:!1,visible:!1},length:!1,order:!1,paging:!1,scroller:!1,search:!1,searchBuilder:!1,searchPanes:!1,select:!1}};
/*! StateRestore 1.4.1
* © SpryMedia Ltd - datatables.net/license
*/var s=r;function r(e,t){var o=this;if(!i||!i.versionCheck||!i.versionCheck("1.10.0"))throw new Error("StateRestore requires DataTables 1.10 or newer");if(!i.Buttons)throw new Error("StateRestore requires Buttons");var s,a,e=new i.Api(e);if(this.classes=g.extend(!0,{},r.classes),void 0===e.settings()[0]._stateRestore)return this.c=g.extend(!0,{},r.defaults,t),this.s={dt:e,hasColReorder:void 0!==i.ColReorder,hasScroller:void 0!==i.Scroller,hasSearchBuilder:void 0!==i.SearchBuilder,hasSearchPanes:void 0!==i.SearchPanes,hasSelect:void 0!==i.select,states:[]},this.s.dt.on("xhr",function(e,t,s){s&&s.stateRestore&&o._addPreDefined(s.stateRestore)}),this.dom={background:g('<div class="'+this.classes.background+'"/>'),checkboxInputRow:g('<div class="'+this.classes.formRow+'"><label class="'+this.classes.nameLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.toggleLabel",this.c.i18n.creationModal.toggleLabel)+'</label><div class="dtsr-input"></div></div>'),closeButton:g('<div class="'+this.classes.closeButton+'">x</div>'),colReorderToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.colReorderToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.colReorder",this.c.i18n.creationModal.colReorder)+"</div>"),columnsSearchToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.columnsSearchToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.columns.search",this.c.i18n.creationModal.columns.search)+"</div>"),columnsVisibleToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.columnsVisibleToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.columns.visible",this.c.i18n.creationModal.columns.visible)+"</div>"),confirmation:g('<div class="'+this.classes.confirmation+'"/>'),confirmationTitleRow:g('<div class="'+this.classes.confirmationTitleRow+'"></div>'),createButtonRow:g('<div class="'+this.classes.formRow+" "+this.classes.modalFoot+'"><button class="'+this.classes.creationButton+" "+this.classes.dtButton+'">'+this.s.dt.i18n("stateRestore.creationModal.button",this.c.i18n.creationModal.button)+"</button></div>"),creation:g('<div class="'+this.classes.creation+'"/>'),creationForm:g('<div class="'+this.classes.creationForm+'"/>'),creationTitle:g('<div class="'+this.classes.creationText+'"><h2 class="'+this.classes.creationTitle+'">'+this.s.dt.i18n("stateRestore.creationModal.title",this.c.i18n.creationModal.title)+"</h2></div>"),dtContainer:g(this.s.dt.table().container()),duplicateError:g('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError)+"</span>"),emptyError:g('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError)+"</span>"),lengthToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.lengthToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.length",this.c.i18n.creationModal.length)+"</div>"),nameInputRow:g('<div class="'+this.classes.formRow+'"><label class="'+this.classes.nameLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.name",this.c.i18n.creationModal.name)+'</label><div class="dtsr-input"><input class="'+this.classes.nameInput+'" type="text"></div></div>'),orderToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.orderToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.order",this.c.i18n.creationModal.order)+"</div>"),pagingToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.pagingToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.paging",this.c.i18n.creationModal.paging)+"</div>"),removeContents:g('<div class="'+this.classes.confirmationText+'"><span></span></div>'),removeTitle:g('<div class="'+this.classes.creationText+'"><h2 class="'+this.classes.creationTitle+'">'+this.s.dt.i18n("stateRestore.removeTitle",this.c.i18n.removeTitle)+"</h2></div>"),scrollerToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.scrollerToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.scroller",this.c.i18n.creationModal.scroller)+"</div>"),searchBuilderToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.searchBuilderToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.searchBuilder",this.c.i18n.creationModal.searchBuilder)+"</div>"),searchPanesToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.searchPanesToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.searchPanes",this.c.i18n.creationModal.searchPanes)+"</div>"),searchToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.searchToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.search",this.c.i18n.creationModal.search)+"</div>"),selectToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.selectToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.select",this.c.i18n.creationModal.select)+"</div>")},(e.settings()[0]._stateRestore=this)._searchForStates(),this._addPreDefined(this.c.preDefined),a={action:"load"},"function"==typeof this.c.ajax?s=function(){"function"==typeof o.c.ajax&&o.c.ajax.call(o.s.dt,a,function(e){return o._addPreDefined(e)})}:"string"==typeof this.c.ajax&&(s=function(){g.ajax({data:a,success:function(e){o._addPreDefined(e)},type:"POST",url:o.c.ajax})}),"function"==typeof s&&(this.s.dt.settings()[0]._bInitComplete?s():this.s.dt.one("preInit.dtsr",function(){s()})),this.s.dt.on("destroy.dtsr",function(){o.destroy()}),this.s.dt.on("draw.dtsr buttons-action.dtsr",function(){return o.findActive()}),this}e=$,m=(u=e).fn.dataTable,e=$,i=(g=e).fn.dataTable,$.fn.dataTable.StateRestore=y,$.fn.DataTable.StateRestore=y,$.fn.dataTable.StateRestoreCollection=s,$.fn.DataTable.StateRestoreCollection=s;var e=DataTable.Api.register;function o(e,t){c(e,new DataTable.StateRestoreCollection(e,t.config))}function c(e,t){var s=e.stateRestore.states(),o=e.button("SaveStateRestore:name"),a=[];if(o[0])for(var i=o.index().split("-"),a=o[0].inst.c.buttons,n=0;n<i.length;n++){if(!a[i[n]].buttons){a=[];break}a=a[i[n]].buttons}var r=e.settings()[0]._stateRestore.c;for(n=0;n<a.length;n++)"stateRestore"===a[n].extend&&(a.splice(n,1),n--);if(r._createInSaved&&a.push("createState"),void 0===s||0===s.length)a.push('<span class="'+t.classes.emptyStates+'">'+e.i18n("stateRestore.emptyStates",t.c.i18n.emptyStates)+"</span>");else for(var c=0,l=s;c<l.length;c++){var d=l[c],h=r.splitSecondaries.slice();h.includes("updateState")&&!r.save&&h.splice(h.indexOf("updateState"),1),!h.includes("renameState")||r.save&&r.rename||h.splice(h.indexOf("renameState"),1),h.includes("removeState")&&!r.remove&&h.splice(h.indexOf("removeState"),1),a.push({_stateRestore:d,attr:{title:d.s.identifier},config:{split:h},extend:"stateRestore",text:y.entityEncode(d.s.identifier),popoverTitle:y.entityEncode(d.s.identifier)})}e.button("SaveStateRestore:name").collectionRebuild(a);for(var u=0,m=e.buttons();u<m.length;u++){var v=m[u];$(v.node).hasClass("dtsr-removeAllStates")&&(0===s.length?e.button(v.node).disable():e.button(v.node).enable())}}e("stateRestore()",function(){return this}),e("stateRestore.state()",function(e){var t,s=this.context[0];return s._stateRestore||c(t=DataTable.Api(s),new DataTable.StateRestoreCollection(t,{})),this[0]=s._stateRestore.getState(e),this}),e("stateRestore.state.add()",function(e,t){var s,o=this.context[0];if(o._stateRestore||c(s=DataTable.Api(o),new DataTable.StateRestoreCollection(s,{})),!o._stateRestore.c.create)return this;if(o._stateRestore.addState){for(var a=[],i=0,n=o._stateRestore.s.states;i<n.length;i++){var r=n[i];a.push(r.s.identifier)}return o._stateRestore.addState(e,a,t),this}}),e("stateRestore.states()",function(e){var t,s=this.context[0];return s._stateRestore||c(t=DataTable.Api(s),new DataTable.StateRestoreCollection(t,{})),this.length=0,this.push.apply(this,s._stateRestore.getStates(e)),this}),e("stateRestore.state().save()",function(){var e=this[0];return e.c.save&&e.save(),this}),e("stateRestore.state().rename()",function(e){var t=this.context[0],s=this[0];if(s.c.save){for(var o=[],a=0,i=t._stateRestore.s.states;a<i.length;a++){var n=i[a];o.push(n.s.identifier)}s.rename(e,o)}return this}),e("stateRestore.state().load()",function(){return this[0].load(),this}),e("stateRestore.state().remove()",function(e){var t=this[0];return t.c.remove&&t.remove(e),this}),e("stateRestore.states().remove()",function(e){function t(e){for(var t=!0,s=a.toArray();0<s.length;){var o=s[0];if(void 0===o||!o.c.remove)break;o=o.remove(e);!0!==o?t=o:s.splice(0,1)}return t}var a=this;return this.context[0]._stateRestore&&this.context[0]._stateRestore.c.remove&&(e?t(e):this.context[0]._stateRestore.removeAll(t)),this}),e("stateRestore.activeStates()",function(){var e,t=this.context[0];return this.length=0,t._stateRestore||c(e=DataTable.Api(t),new DataTable.StateRestoreCollection(e,{})),t._stateRestore&&this.push.apply(this,t._stateRestore.findActive()),this}),DataTable.ext.buttons.stateRestore={action:function(e,t,s,o){o._stateRestore.load(),s.blur()},className:"dtsr-state",config:{split:["updateState","renameState","removeState"]},text:function(e){return e.i18n("buttons.stateRestore","State %d",e.stateRestore.states()[0].length+1)}},DataTable.ext.buttons.updateState={action:function(e,t,s,o){$("div.dt-button-background").click(),o.parent._stateRestore.save()},text:function(e){return e.i18n("buttons.updateState","Update")}},DataTable.ext.buttons.savedStates={buttons:[],extend:"collection",init:function(e,t,s){e.on("stateRestore-change",function(){e.button(t).text(e.i18n("buttons.savedStates","Saved States",e.stateRestore.states().length))}),void 0===e.settings()[0]._stateRestore&&o(e,s)},name:"SaveStateRestore",text:function(e){return e.i18n("buttons.savedStates","Saved States",0)}},DataTable.ext.buttons.savedStatesCreate={buttons:[],extend:"collection",init:function(e,t,s){e.on("stateRestore-change",function(){e.button(t).text(e.i18n("buttons.savedStates","Saved States",e.stateRestore.states().length))}),void 0===e.settings()[0]._stateRestore&&(void 0===s.config&&(s.config={}),s.config._createInSaved=!0,o(e,s))},name:"SaveStateRestore",text:function(e){return e.i18n("buttons.savedStates","Saved States",0)}},DataTable.ext.buttons.createState={action:function(e,t,s,o){e.stopPropagation();var a=t.settings()[0]._stateRestore.c,e=t.settings()[0].oLanguage;if(a.create&&a.save){var i=t.stateRestore.states().toArray(),e=void 0!==e.buttons&&void 0!==e.buttons.stateRestore?e.buttons.stateRestore:"State ";if(e.indexOf("%d")===e.length-3)n=new RegExp(e.replace(/%d/g,""));else for(var e=e.split("%d"),n=[],r=0,c=e;r<c.length;r++){var l=c[r];n.push(new RegExp(l))}for(var d=function(e){if(Array.isArray(n)){a=e;for(var t=0,s=n;t<s.length;t++)var o=s[t],a=a.replace(o,"")}else a=e.replace(n,"");return isNaN(+a)||a.length===e?0:+a},e=i.map(function(e){return d(e.s.identifier)}).sort(function(e,t){return+e<+t?1:+t<+e?-1:0})[0],h=(t.stateRestore.state.add(t.i18n("buttons.stateRestore","State %d",void 0!==e?e+1:1),o.config),t.stateRestore.states().sort(function(e,t){e=+d(e.s.identifier),t=+d(t.s.identifier);return t<e?1:e<t?-1:0})),i=t.button("SaveStateRestore:name"),u=void 0!==i[0]&&void 0!==i[0].inst.c.buttons[0].buttons?i[0].inst.c.buttons[0].buttons:[],m=0;m<u.length;m++)"stateRestore"===u[m].extend&&(u.splice(m,1),m--);a._createInSaved&&u.push("createState");for(var v=0,g=h;v<g.length;v++){var p=g[v],f=a.splitSecondaries.slice();f.includes("updateState")&&!a.save&&f.splice(f.indexOf("updateState"),1),!f.includes("renameState")||a.save&&a.rename||f.splice(f.indexOf("renameState"),1),f.includes("removeState")&&!a.remove&&f.splice(f.indexOf("removeState"),1),u.push({_stateRestore:p,attr:{title:p.s.identifier},config:{split:f},extend:"stateRestore",text:y.entityEncode(p.s.identifier),popoverTitle:y.entityEncode(p.s.identifier)})}t.button("SaveStateRestore:name").collectionRebuild(u),s.blur();for(var b=0,S=t.buttons();b<S.length;b++){var R=S[b];$(R.node).hasClass("dtsr-removeAllStates")&&(0===h.length?t.button(R.node).disable():t.button(R.node).enable())}}},init:function(e,t,s){void 0===e.settings()[0]._stateRestore&&1<e.button("SaveStateRestore:name").length&&o(e,s)},text:function(e){return e.i18n("buttons.createState","Create State")}},DataTable.ext.buttons.removeState={action:function(e,t,s,o){o.parent._stateRestore.remove(),s.blur()},text:function(e){return e.i18n("buttons.removeState","Remove")}},DataTable.ext.buttons.removeAllStates={action:function(e,t,s){t.stateRestore.states().remove(!0),s.blur()},className:"dt-button dtsr-removeAllStates",init:function(e,t){e.settings()[0]._stateRestore&&0!==e.stateRestore.states().length||$(t).addClass("disabled")},text:function(e){return e.i18n("buttons.removeAllStates","Remove All States")}},DataTable.ext.buttons.renameState={action:function(e,t,s,o){for(var a=[],i=0,n=t.settings()[0]._stateRestore.s.states;i<n.length;i++){var r=n[i];a.push(r.s.identifier)}o.parent._stateRestore.rename(void 0,a),s.blur()},text:function(e){return e.i18n("buttons.renameState","Rename")}},$(document).on("preInit.dt.dtsr",function(e,t){"dt"!==e.namespace||!t.oInit.stateRestore&&!DataTable.defaults.stateRestore||t._stateRestore||(e=t,void 0===(t=null)&&(t=null),e=new DataTable.Api(e),t=t||e.init().stateRestore||DataTable.defaults.stateRestore,t=new s(e,t),c(e,t))})}();export default DataTable;