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

4 lines
42 KiB
JavaScript

/*! StateRestore 1.4.1
* © SpryMedia Ltd - datatables.net/license
*/
!function(s){var o,i;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return s(e,window,document)}):"object"==typeof exports?(o=require("jquery"),i=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||o(e),i(e,t),s(t,0,e.document)}:(i(window,o),module.exports=s(o,window,window.document))):s(jQuery,window,document)}(function(y,e,g){"use strict";var u,m,p,a,k,s,t,c=y.fn.dataTable;function n(e,t,s,o,i,a){if(void 0===o&&(o=void 0),void 0===i&&(i=!1),void 0===a&&(a=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:i,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,a)}function r(e,t){var o=this;if(!a||!a.versionCheck||!a.versionCheck("1.10.0"))throw new Error("StateRestore requires DataTables 1.10 or newer");if(!a.Buttons)throw new Error("StateRestore requires Buttons");var s,i,e=new a.Api(e);if(this.classes=p.extend(!0,{},r.classes),void 0===e.settings()[0]._stateRestore)return this.c=p.extend(!0,{},r.defaults,t),this.s={dt:e,hasColReorder:void 0!==a.ColReorder,hasScroller:void 0!==a.Scroller,hasSearchBuilder:void 0!==a.SearchBuilder,hasSearchPanes:void 0!==a.SearchPanes,hasSelect:void 0!==a.select,states:[]},this.s.dt.on("xhr",function(e,t,s){s&&s.stateRestore&&o._addPreDefined(s.stateRestore)}),this.dom={background:p('<div class="'+this.classes.background+'"/>'),checkboxInputRow:p('<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:p('<div class="'+this.classes.closeButton+'">x</div>'),colReorderToggle:p('<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:p('<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:p('<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:p('<div class="'+this.classes.confirmation+'"/>'),confirmationTitleRow:p('<div class="'+this.classes.confirmationTitleRow+'"></div>'),createButtonRow:p('<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:p('<div class="'+this.classes.creation+'"/>'),creationForm:p('<div class="'+this.classes.creationForm+'"/>'),creationTitle:p('<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:p(this.s.dt.table().container()),duplicateError:p('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError)+"</span>"),emptyError:p('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError)+"</span>"),lengthToggle:p('<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:p('<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:p('<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:p('<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:p('<div class="'+this.classes.confirmationText+'"><span></span></div>'),removeTitle:p('<div class="'+this.classes.creationText+'"><h2 class="'+this.classes.creationTitle+'">'+this.s.dt.i18n("stateRestore.removeTitle",this.c.i18n.removeTitle)+"</h2></div>"),scrollerToggle:p('<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:p('<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:p('<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:p('<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:p('<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),i={action:"load"},"function"==typeof this.c.ajax?s=function(){"function"==typeof o.c.ajax&&o.c.ajax.call(o.s.dt,i,function(e){return o._addPreDefined(e)})}:"string"==typeof this.c.ajax&&(s=function(){p.ajax({data:i,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}function o(e,t){l(e,new c.StateRestoreCollection(e,t.config))}function l(e,t){var s=e.stateRestore.states(),o=e.button("SaveStateRestore:name"),i=[];if(o[0])for(var a=o.index().split("-"),i=o[0].inst.c.buttons,n=0;n<a.length;n++){if(!i[a[n]].buttons){i=[];break}i=i[a[n]].buttons}var r=e.settings()[0]._stateRestore.c;for(n=0;n<i.length;n++)"stateRestore"===i[n].extend&&(i.splice(n,1),n--);if(r._createInSaved&&i.push("createState"),void 0===s||0===s.length)i.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),i.push({_stateRestore:d,attr:{title:d.s.identifier},config:{split:h},extend:"stateRestore",text:k.entityEncode(d.s.identifier),popoverTitle:k.entityEncode(d.s.identifier)})}e.button("SaveStateRestore:name").collectionRebuild(i);for(var u=0,m=e.buttons();u<m.length;u++){var v=m[u];y(v.node).hasClass("dtsr-removeAllStates")&&(0===s.length?e.button(v.node).disable():e.button(v.node).enable())}}return n.prototype.remove=function(e){var t,s,o,i,a=this;return void 0===e&&(e=!1),!!this.c.remove&&(o={action:"remove",stateRestore:((t={})[this.s.identifier]=this.s.savedState,t)},i=function(){a.dom.confirmation.trigger("dtsr-remove"),u(a.s.dt.table().node()).trigger("stateRestore-change"),a.dom.background.click(),a.dom.confirmation.remove(),u(g).unbind("keyup",function(e){return a._keyupFunction(e)}),a.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:i,type:"POST",url:a.c.ajax}),!0}:"function"==typeof this.c.ajax&&(s=function(){return"function"==typeof a.c.ajax&&a.c.ajax.call(a.s.dt,o,i),!0}):s=function(){try{localStorage.removeItem("DataTables_stateRestore_"+a.s.identifier+"_"+location.pathname+(a.s.tableId?"_"+a.s.tableId:"")),i()}catch(e){return a.dom.confirmation.children("."+a.classes.modalError).remove(),a.dom.confirmation.append(a.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=i.start/i.length;0<=e&&0<=t&&e!=t&&o.s.dt.page(t).draw(!1)},50)}),o.s.dt.draw(!1)}var o=this,i=this.s.savedState,t=this.s.dt.settings()[0];i.time=+new Date,t.oLoadedState=u.extend(!0,{},i),u("div.dt-button-background").click();return c.versionCheck("2")?(this.s.dt.state(i),e()):c.ext.oApi._fnImplementState(t,i,e),i},n.prototype.rename=function(s,o){var i=this;if(void 0===s&&(s=null),this.c.rename){var e=function(){if(null===s){var e=u("input."+i.classes.input.replace(/ /g,".")).val();if(0===e.length)return i.dom.confirmation.children("."+i.classes.modalError).remove(),i.dom.confirmation.append(i.dom.emptyError),"empty";if(o.includes(e))return i.dom.confirmation.children("."+i.classes.modalError).remove(),i.dom.confirmation.append(i.dom.duplicateError),"duplicate";s=e}function t(){i.s.identifier=s,i.save(i.s.savedState,function(){return null},!1),i.dom.removeContents=u('<div class="'+i.classes.confirmationText+'"><span>'+i.s.dt.i18n("stateRestore.removeConfirm",i.c.i18n.removeConfirm).replace(/%s/g,i.s.identifier)+"</span></div>"),i.dom.confirmation.trigger("dtsr-rename"),i.dom.background.click(),i.dom.confirmation.remove(),u(g).unbind("keyup",function(e){return i._keyupFunction(e)}),i.dom.confirmationButton.off("click")}e={action:"rename",stateRestore:((e={})[i.s.identifier]=s,e)};if(i.c.ajax)"string"==typeof i.c.ajax&&i.s.dt.settings()[0]._bInitComplete?u.ajax({data:e,success:t,type:"POST",url:i.c.ajax}):"function"==typeof i.c.ajax&&i.c.ajax.call(i.s.dt,e,t);else try{localStorage.removeItem("DataTables_stateRestore_"+i.s.identifier+"_"+location.pathname+(i.s.tableId?"_"+i.s.tableId:"")),t()}catch(e){return i.dom.confirmation.children("."+i.classes.modalError).remove(),i.dom.confirmation.append(i.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,i,a,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):(i={action:"save",stateRestore:((e={})[this.s.identifier]=this.s.savedState,e)},a=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:i,success:a,type:"POST",url:this.c.ajax}):this.s.dt.one("init",function(){u.ajax({data:i,success:a,type:"POST",url:n.c.ajax})}):"function"==typeof this.c.ajax&&s&&this.c.ajax.call(this.s.dt,i,a):(localStorage.setItem("DataTables_stateRestore_"+this.s.identifier+"_"+location.pathname+(this.s.tableId?"_"+this.s.tableId:""),JSON.stringify(this.s.savedState)),a()))}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,i=[e,t],a=[Object.keys(e).sort(),Object.keys(t).sort()];for(a[0].includes("scroller")&&(s=a[0].indexOf("start"))&&a[0].splice(s,1),a[1].includes("scroller")&&(s=a[1].indexOf("start"))&&a[1].splice(s,1),o=0;o<a[0].length;o++)0!==a[0][o].indexOf("_")&&"baseRowTop"!==a[0][o]&&"baseScrollTop"!==a[0][o]&&"scrollTop"!==a[0][o]&&(this.c.saveState.paging||"page"!==a[0][o])||(a[0].splice(o,1),o--);for(o=0;o<a[1].length;o++)0!==a[1][o].indexOf("_")&&"baseRowTop"!==a[1][o]&&"baseScrollTop"!==a[1][o]&&"scrollTop"!==a[1][o]&&(this.c.saveState.paging||"page"!==a[0][o])||(a[1].splice(o,1),o--);if(0===a[0].length&&0<a[1].length||0===a[1].length&&0<a[0].length)return!1;for(o=0;o<a[0].length;o++)a[1].includes(a[0][o])||(a[0].splice(o,1),o--);for(o=0;o<a[1].length;o++)a[0].includes(a[1][o])||(a[1].splice(o,1),o--);for(o=0;o<a[0].length;o++){if(a[0][o]!==a[1][o]||typeof i[0][a[0][o]]!=typeof i[1][a[1][o]])return!1;if("object"==typeof i[0][a[0][o]]){if(!this._deepCompare(i[0][a[0][o]],i[1][a[1][o]]))return!1}else if("number"==typeof i[0][a[0][o]]&&"number"==typeof i[1][a[1][o]]){if(Math.round(i[0][a[0][o]])!==Math.round(i[1][a[1][o]]))return!1}else if(i[0][a[0][o]]!==i[1][a[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 i=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")),a=((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 a.click()})),this.dom.confirmationButton.on("click",function(){return s()}),this.dom.confirmation.on("click",function(e){e.stopPropagation()}),a.one("click",function(){i.dom.background.remove(),i.dom.confirmation.remove(),u(g).unbind("keyup",function(e){return i._keyupFunction(e)})}),u(g).on("keyup",function(e){return i._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}},k=n,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 i=v.c.saveState,a=0,n=Object.keys(t.saveState);a<n.length;a++){var r=n[a];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]||(i[r][d]=!1)}else t.saveState[r]||(i[r]=!1)}v.c.saveState=i}var h=new k(v.s.dt.settings()[0],p.extend(!0,{},v.c,m),e,o,!1,function(){s.s.states.push(this),s._collectionRebuild()});return p(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)),p(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();p.each(this.dom,function(e,t){t.off().remove()}),this.s.states=[],this.s.dt.off(".dtsr"),p(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],(p(d).hasClass("dtsr-state")||p(d).children().hasClass("dtsr-state"))&&this.s.dt.button(d).active(!1);for(var i=[],a=0,n=this.s.states;a<n.length;a++){var r=n[a];if(r.compare(e)){i.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 i},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 i=o[s],a=!1,n=0,r=this.s.states;n<r.length;n++){var c=r[n];if(i===c.s.identifier){t.push(c),a=!0;break}}a||t.push(void 0)}return t},r.prototype._addPreDefined=function(a){for(var n=this,e=Object.keys(a).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=a[e],i=new k(r.s.dt,p.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()});i.s.savedState=o,p(r.s.dt.table().node()).on("dtsr-modal-inserted",function(){i.dom.confirmation.one("dtsr-remove",function(){return n._removeCallback(i.s.identifier)}),i.dom.confirmation.one("dtsr-rename",function(){return n._collectionRebuild()}),i.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 i='<span class="'+this.classes.emptyStates+'">'+this.s.dt.i18n("stateRestore.emptyStates",this.c.i18n.emptyStates)+"</span>";if(0===this.s.states.length)t.includes(i)||t.push(i);else{for(;t.includes(i);)t.splice(t.indexOf(i),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 a=0,n=this.s.states;a<n.length;a++){var r=n[a],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:k.entityEncode(r.s.identifier),popoverTitle:k.entityEncode(r.s.identifier)})}}e.collectionRebuild(t);for(var l=0,d=this.s.dt.buttons();l<d.length;l++){var h=d[l];p(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,i=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),a=[],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)&&a.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)&&a.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)&&a.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)&&a.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&&a.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&&a.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&&a.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&&a.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&&a.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?(a.push(this.dom.columnsSearchToggle),a.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&&a.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&&a.push(this.dom.columnsVisibleToggle)):this.c.saveState.columns&&(a.push(this.dom.columnsSearchToggle),a.push(this.dom.columnsVisibleToggle))),a.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=a;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),p(this.s.dt.table().node()).trigger("dtsr-modal-inserted");for(var d=0,h=a;d<h.length;d++)p((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=p("button."+this.classes.creationButton.replace(/ /g,".")),e=this.dom.creationForm.find("input"),v=((0<e.length?p(e[0]):m).focus(),p("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:i.dom.colReorderToggle.find("input").is(":checked"),columns:{search:i.dom.columnsSearchToggle.find("input").is(":checked"),visible:i.dom.columnsVisibleToggle.find("input").is(":checked")},length:i.dom.lengthToggle.find("input").is(":checked"),order:i.dom.orderToggle.find("input").is(":checked"),paging:i.dom.pagingToggle.find("input").is(":checked"),scroller:i.dom.scrollerToggle.find("input").is(":checked"),search:i.dom.searchToggle.find("input").is(":checked"),searchBuilder:i.dom.searchBuilderToggle.find("input").is(":checked"),searchPanes:i.dom.searchPanesToggle.find("input").is(":checked"),select:i.dom.selectToggle.find("input").is(":checked")},e=t(p("input."+i.classes.nameInput.replace(/ /g,".")).val(),{saveState:e});!0===e?(i.dom.background.remove(),i.dom.creation.remove(),p(g).unbind("keyup",u)):(i.dom.creation.children("."+i.classes.modalError).remove(),i.dom.creation.append(i.dom[e+"Error"]))}),v.one("click",function(){i.dom.background.remove(),i.dom.creation.remove(),p(g).unbind("keyup",u),i._collectionRebuild()}),p(g).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 i(e){"Enter"===e.key?n.click():"Escape"===e.key&&r.click()}var a=this,n=(this.dom.background.appendTo(this.dom.dtContainer),this.dom.confirmationTitleRow.empty().append(e),p('<button class="'+this.classes.confirmationButton+" "+this.classes.dtButton+'">'+t+"</button>")),e=(this.dom.confirmation.empty().append(this.dom.confirmationTitleRow).append(o).append(p('<div class="'+this.classes.confirmationButtons+'"></div>').append(n)).appendTo(this.dom.dtContainer),p(this.s.dt.table().node()).trigger("dtsr-modal-inserted"),o.children("input")),r=((0<e.length?p(e[0]):n).focus(),p("div."+this.classes.background.replace(/ /g,".")));n.on("click",function(){var e=s(!0);!0===e?(a.dom.background.remove(),a.dom.confirmation.remove(),p(g).unbind("keyup",i),n.off("click")):(a.dom.confirmation.children("."+a.classes.modalError).remove(),a.dom.confirmation.append(a.dom[e+"Error"]))}),this.dom.confirmation.on("click",function(e){e.stopPropagation()}),r.one("click",function(){a.dom.background.remove(),a.dom.confirmation.remove(),p(g).unbind("keyup",i)}),p(g).on("keyup",i)},r.prototype._searchForStates=function(){for(var i=this,e=Object.keys(localStorage),a=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+"_"+a.s.dt.table().node().id+"$"))){var t=JSON.parse(localStorage.getItem(e));if(t.stateRestore.isPreDefined||t.stateRestore.tableId&&t.stateRestore.tableId!==a.s.dt.table().node().id)return;var s=a,o=new k(a.s.dt,p.extend(!0,{},a.c,{saveState:t.c.saveState}),t.stateRestore.state,t,!1,function(){this.s.savedState=t,s.s.states.push(this),s._collectionRebuild()});p(a.s.dt.table().node()).on("dtsr-modal-inserted",function(){o.dom.confirmation.one("dtsr-remove",function(){return i._removeCallback(o.s.identifier)}),o.dom.confirmation.one("dtsr-rename",function(){return i._collectionRebuild()}),o.dom.confirmation.one("dtsr-save",function(){return i._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}},s=r,m=(u=y).fn.dataTable,a=(p=y).fn.dataTable,y.fn.dataTable.StateRestore=k,y.fn.DataTable.StateRestore=k,y.fn.dataTable.StateRestoreCollection=s,y.fn.DataTable.StateRestoreCollection=s,(t=c.Api.register)("stateRestore()",function(){return this}),t("stateRestore.state()",function(e){var t,s=this.context[0];return s._stateRestore||l(t=c.Api(s),new c.StateRestoreCollection(t,{})),this[0]=s._stateRestore.getState(e),this}),t("stateRestore.state.add()",function(e,t){var s,o=this.context[0];if(o._stateRestore||l(s=c.Api(o),new c.StateRestoreCollection(s,{})),!o._stateRestore.c.create)return this;if(o._stateRestore.addState){for(var i=[],a=0,n=o._stateRestore.s.states;a<n.length;a++){var r=n[a];i.push(r.s.identifier)}return o._stateRestore.addState(e,i,t),this}}),t("stateRestore.states()",function(e){var t,s=this.context[0];return s._stateRestore||l(t=c.Api(s),new c.StateRestoreCollection(t,{})),this.length=0,this.push.apply(this,s._stateRestore.getStates(e)),this}),t("stateRestore.state().save()",function(){var e=this[0];return e.c.save&&e.save(),this}),t("stateRestore.state().rename()",function(e){var t=this.context[0],s=this[0];if(s.c.save){for(var o=[],i=0,a=t._stateRestore.s.states;i<a.length;i++){var n=a[i];o.push(n.s.identifier)}s.rename(e,o)}return this}),t("stateRestore.state().load()",function(){return this[0].load(),this}),t("stateRestore.state().remove()",function(e){var t=this[0];return t.c.remove&&t.remove(e),this}),t("stateRestore.states().remove()",function(e){function t(e){for(var t=!0,s=i.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 i=this;return this.context[0]._stateRestore&&this.context[0]._stateRestore.c.remove&&(e?t(e):this.context[0]._stateRestore.removeAll(t)),this}),t("stateRestore.activeStates()",function(){var e,t=this.context[0];return this.length=0,t._stateRestore||l(e=c.Api(t),new c.StateRestoreCollection(e,{})),t._stateRestore&&this.push.apply(this,t._stateRestore.findActive()),this}),c.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)}},c.ext.buttons.updateState={action:function(e,t,s,o){y("div.dt-button-background").click(),o.parent._stateRestore.save()},text:function(e){return e.i18n("buttons.updateState","Update")}},c.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)}},c.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)}},c.ext.buttons.createState={action:function(e,t,s,o){e.stopPropagation();var i=t.settings()[0]._stateRestore.c,e=t.settings()[0].oLanguage;if(i.create&&i.save){var a=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)){i=e;for(var t=0,s=n;t<s.length;t++)var o=s[t],i=i.replace(o,"")}else i=e.replace(n,"");return isNaN(+i)||i.length===e?0:+i},e=a.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})),a=t.button("SaveStateRestore:name"),u=void 0!==a[0]&&void 0!==a[0].inst.c.buttons[0].buttons?a[0].inst.c.buttons[0].buttons:[],m=0;m<u.length;m++)"stateRestore"===u[m].extend&&(u.splice(m,1),m--);i._createInSaved&&u.push("createState");for(var v=0,g=h;v<g.length;v++){var p=g[v],f=i.splitSecondaries.slice();f.includes("updateState")&&!i.save&&f.splice(f.indexOf("updateState"),1),!f.includes("renameState")||i.save&&i.rename||f.splice(f.indexOf("renameState"),1),f.includes("removeState")&&!i.remove&&f.splice(f.indexOf("removeState"),1),u.push({_stateRestore:p,attr:{title:p.s.identifier},config:{split:f},extend:"stateRestore",text:k.entityEncode(p.s.identifier),popoverTitle:k.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];y(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")}},c.ext.buttons.removeState={action:function(e,t,s,o){o.parent._stateRestore.remove(),s.blur()},text:function(e){return e.i18n("buttons.removeState","Remove")}},c.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||y(t).addClass("disabled")},text:function(e){return e.i18n("buttons.removeAllStates","Remove All States")}},c.ext.buttons.renameState={action:function(e,t,s,o){for(var i=[],a=0,n=t.settings()[0]._stateRestore.s.states;a<n.length;a++){var r=n[a];i.push(r.s.identifier)}o.parent._stateRestore.rename(void 0,i),s.blur()},text:function(e){return e.i18n("buttons.renameState","Rename")}},y(g).on("preInit.dt.dtsr",function(e,t){"dt"!==e.namespace||!t.oInit.stateRestore&&!c.defaults.stateRestore||t._stateRestore||(e=t,void 0===(t=null)&&(t=null),e=new c.Api(e),t=t||e.init().stateRestore||c.defaults.stateRestore,t=new s(e,t),l(e,t))}),c});