!function(e){"function"==typeof define&&define.amd?define(["jquery","dataTables"],function(t){return e(t,window,document)}):"object"==typeof exports?module.exports=function(t,n){return t=t||window,n&&n.fn.dataTable||(n=require("dataTables")(t,n).$),e(n,t,t.document)}:e(jQuery,window,document)}(function(p,u,r,f){"use strict";function c(t,n){p.isArray(n=!0===(n=void 0===n?{}:n)?{}:n)&&(n={buttons:n}),this.c=p.extend(!0,{},c.defaults,n),n.buttons&&(this.c.buttons=n.buttons),this.s={dt:new e.Api(t),buttons:[],listenKeys:"",namespace:"dtb"+o++},this.dom={container:p("<"+this.c.dom.container.tag+"/>").addClass(this.c.dom.container.className)},this._constructor()}var i,e=p.fn.dataTable,o=0,l=0,d=e.ext.buttons,g=(p.extend(c.prototype,{action:function(t,n){t=this._nodeToButton(t);return n===f?t.conf.action:(t.conf.action=n,this)},active:function(t,n){var t=this._nodeToButton(t),e=this.c.dom.button.active,t=p(t.node);return n===f?t.hasClass(e):(t.toggleClass(e,n===f||n),this)},add:function(t,n){var e=this.s.buttons;if("string"==typeof n){for(var o=n.split("-"),i=this.s,s=0,r=o.length-1;s<r;s++)i=i.buttons[+o[s]];e=i.buttons,n=+o[o.length-1]}return this._expandButton(e,t,!1,n),this._draw(),this},container:function(){return this.dom.container},disable:function(t){t=this._nodeToButton(t);return p(t.node).addClass(this.c.dom.button.disabled),this},destroy:function(){p("body").off("keyup."+this.s.namespace);for(var t=this.s.buttons.slice(),n=0,e=t.length;n<e;n++)this.remove(t[n].node);this.dom.container.remove();var o=this.s.dt.settings()[0];for(n=0,e=o.length;n<e;n++)if(o.inst===this){o.splice(n,1);break}return this},enable:function(t,n){return!1===n?this.disable(t):(n=this._nodeToButton(t),p(n.node).removeClass(this.c.dom.button.disabled),this)},name:function(){return this.c.name},node:function(t){t=this._nodeToButton(t);return p(t.node)},processing:function(t,n){t=this._nodeToButton(t);return n===f?p(t.node).hasClass("processing"):(p(t.node).toggleClass("processing",n),this)},remove:function(t){var n=this._nodeToButton(t),e=this._nodeToHost(t),o=this.s.dt;if(n.buttons.length)for(var i=n.buttons.length-1;0<=i;i--)this.remove(n.buttons[i].node);n.conf.destroy&&n.conf.destroy.call(o.button(t),o,p(t),n.conf),this._removeKey(n.conf),p(n.node).remove();o=p.inArray(n,e);return e.splice(o,1),this},text:function(t,n){function e(t){return"function"==typeof t?t(i,s,o.conf):t}var o=this._nodeToButton(t),t=this.c.dom.collection.buttonLiner,t=(o.inCollection&&t&&t.tag?t:this.c.dom.buttonLiner).tag,i=this.s.dt,s=p(o.node);return n===f?e(o.conf.text):(o.conf.text=n,(t?s.children(t):s).html(e(n)),this)},_constructor:function(){var e=this,t=this.s.dt,n=t.settings()[0],o=this.c.buttons;n._buttons||(n._buttons=[]),n._buttons.push({inst:this,name:this.c.name});for(var i=0,s=o.length;i<s;i++)this.add(o[i]);t.on("destroy",function(){e.destroy()}),p("body").on("keyup."+this.s.namespace,function(t){var n;r.activeElement&&r.activeElement!==r.body||(n=String.fromCharCode(t.keyCode).toLowerCase(),-1!==e.s.listenKeys.toLowerCase().indexOf(n)&&e._keypress(n,t))})},_addKey:function(t){t.key&&(this.s.listenKeys+=(p.isPlainObject(t.key)?t.key:t).key)},_draw:function(t,n){t||(t=this.dom.container,n=this.s.buttons),t.children().detach();for(var e=0,o=n.length;e<o;e++)t.append(n[e].inserter),n[e].buttons&&n[e].buttons.length&&this._draw(n[e].collection,n[e].buttons)},_expandButton:function(t,n,e,o){for(var i=this.s.dt,s=p.isArray(n)?n:[n],r=0,a=s.length;r<a;r++){var u,c,l=this._resolveExtends(s[r]);l&&(p.isArray(l)?this._expandButton(t,l,e,o):(u=this._buildButton(l,e))&&(o!==f?(t.splice(o,0,u),o++):t.push(u),u.conf.buttons&&(c=this.c.dom.collection,u.collection=p("<"+c.tag+"/>").addClass(c.className).attr("role","menu"),u.conf._collection=u.collection,this._expandButton(u.buttons,u.conf.buttons,!0,o)),l.init&&l.init.call(i.button(u.node),i,p(u.node),l),0))}},_buildButton:function(n,t){function e(t){return"function"==typeof t?t(u,i,n):t}var o,i,s=this.c.dom.button,r=this.c.dom.buttonLiner,a=this.c.dom.collection,u=this.s.dt;return t&&a.button&&(s=a.button),t&&a.buttonLiner&&(r=a.buttonLiner),!(n.available&&!n.available(u,n))&&(o=function(t,n,e,o){o.action.call(n.button(e),t,n,e,o),p(n.table().node()).triggerHandler("buttons-action.dt",[n.button(e),n,e,o])},i=p("<"+s.tag+"/>").addClass(s.className).attr("tabindex",this.s.dt.settings()[0].iTabIndex).attr("aria-controls",this.s.dt.table().node().id).on("click.dtb",function(t){t.preventDefault(),!i.hasClass(s.disabled)&&n.action&&o(t,u,i,n),i.blur()}).on("keyup.dtb",function(t){13===t.keyCode&&!i.hasClass(s.disabled)&&n.action&&o(t,u,i,n)}),"a"===s.tag.toLowerCase()&&i.attr("href","#"),r.tag?(a=p("<"+r.tag+"/>").html(e(n.text)).addClass(r.className),"a"===r.tag.toLowerCase()&&a.attr("href","#"),i.append(a)):i.html(e(n.text)),!1===n.enabled&&i.addClass(s.disabled),n.className&&i.addClass(n.className),n.titleAttr&&i.attr("title",e(n.titleAttr)),n.namespace||(n.namespace=".dt-button-"+l++),a=(r=this.c.dom.buttonContainer)&&r.tag?p("<"+r.tag+"/>").addClass(r.className).append(i):i,this._addKey(n),{conf:n,node:i.get(0),inserter:a,buttons:[],inCollection:t,collection:null})},_nodeToButton:function(t,n){for(var e=0,o=(n=n||this.s.buttons).length;e<o;e++){if(n[e].node===t)return n[e];if(n[e].buttons.length){var i=this._nodeToButton(t,n[e].buttons);if(i)return i}}},_nodeToHost:function(t,n){for(var e=0,o=(n=n||this.s.buttons).length;e<o;e++){if(n[e].node===t)return n;if(n[e].buttons.length){var i=this._nodeToHost(t,n[e].buttons);if(i)return i}}},_keypress:function(s,r){function a(t){for(var n,e,o=0,i=t.length;o<i;o++)n=t[o].conf,e=t[o].node,!n.key||n.key!==s&&(!p.isPlainObject(n.key)||n.key.key!==s||n.key.shiftKey&&!r.shiftKey||n.key.altKey&&!r.altKey||n.key.ctrlKey&&!r.ctrlKey||n.key.metaKey&&!r.metaKey)||p(e).click(),t[o].buttons.length&&a(t[o].buttons)}a(this.s.buttons)},_removeKey:function(t){var n;t.key&&(t=(p.isPlainObject(t.key)?t.key:t).key,n=this.s.listenKeys.split(""),t=p.inArray(t,n),n.splice(t,1),this.s.listenKeys=n.join(""))},_resolveExtends:function(e){function t(t){for(var n=0;!p.isPlainObject(t)&&!p.isArray(t);){if(t===f)return;if("function"==typeof t){if(!(t=t(i,e)))return!1}else if("string"==typeof t){if(!d[t])throw"Unknown button type: "+t;t=d[t]}if(30<++n)throw"Buttons: Too many iterations"}return p.isArray(t)?t:p.extend({},t)}var n,o,i=this.s.dt;for(e=t(e);e&&e.extend;){if(!d[e.extend])throw"Cannot extend unknown button type: "+e.extend;var s=t(d[e.extend]);if(p.isArray(s))return s;if(!s)return!1;var r=s.className,a=(e=p.extend({},s,e),r&&e.className!==r&&(e.className=r+" "+e.className),e.postfixButtons);if(a){for(e.buttons||(e.buttons=[]),n=0,o=a.length;n<o;n++)e.buttons.push(a[n]);e.postfixButtons=null}var u=e.prefixButtons;if(u){for(e.buttons||(e.buttons=[]),n=0,o=u.length;n<o;n++)e.buttons.splice(n,0,u[n]);e.prefixButtons=null}e.extend=s.extend}return e}}),c.background=function(t,n,e){e===f&&(e=400),t?p("<div/>").addClass(n).css("display","none").appendTo("body").fadeIn(e):p("body > div."+n).fadeOut(e,function(){p(this).removeClass(n).remove()})},c.instanceSelector=function(t,i){var s,r,a;return t?(s=[],r=p.map(i,function(t){return t.name}),(a=function(t){var n;if(p.isArray(t))for(var e=0,o=t.length;e<o;e++)a(t[e]);else"string"==typeof t?-1!==t.indexOf(",")?a(t.split(",")):-1!==(n=p.inArray(p.trim(t),r))&&s.push(i[n].inst):"number"==typeof t&&s.push(i[t].inst)})(t),s):p.map(i,function(t){return t.inst})},c.buttonSelector=function(t,n){for(var c=[],l=function(t,n,e){for(var o,i,s=0,r=n.length;s<r;s++)(o=n[s])&&(t.push({node:o.node,name:o.conf.name,idx:i=e!==f?e+s:s+""}),o.buttons)&&l(t,o.buttons,i+"-")},d=function(t,n){var e=[],o=(l(e,n.s.buttons),p.map(e,function(t){return t.node}));if(p.isArray(t)||t instanceof p)for(s=0,r=t.length;s<r;s++)d(t[s],n);else if(null===t||t===f||"*"===t)for(s=0,r=e.length;s<r;s++)c.push({inst:n,node:e[s].node});else if("number"==typeof t)c.push({inst:n,node:n.s.buttons[t].node});else if("string"==typeof t)if(-1!==t.indexOf(","))for(var i=t.split(","),s=0,r=i.length;s<r;s++)d(p.trim(i[s]),n);else if(t.match(/^\d+(\-\d+)*$/)){var a=p.map(e,function(t){return t.idx});c.push({inst:n,node:e[p.inArray(t,a)].node})}else if(-1!==t.indexOf(":name")){var u=t.replace(":name","");for(s=0,r=e.length;s<r;s++)e[s].name===u&&c.push({inst:n,node:e[s].node})}else p(o).filter(t).each(function(){c.push({inst:n,node:this})});else"object"==typeof t&&t.nodeName&&-1!==(a=p.inArray(t,o))&&c.push({inst:n,node:o[a]})},e=0,o=t.length;e<o;e++){var i=t[e];d(n,i)}return c},c.defaults={buttons:["copy","excel","csv","pdf","print"],name:"main",tabIndex:0,dom:{container:{tag:"div",className:"dt-buttons"},collection:{tag:"div",className:"dt-button-collection"},button:{tag:"a",className:"dt-button",active:"active",disabled:"disabled"},buttonLiner:{tag:"span",className:""}}},p.extend(d,{collection:{text:function(t){return t.i18n("buttons.collection","Collection")},className:"buttons-collection",action:function(t,e,n,o){var i=n.offset(),s=p(e.table().container()),r=!1,a=(p("div.dt-button-background").length&&(r=p(".dt-button-collection").offset(),p("body").trigger("click.dtb-collection")),o._collection.addClass(o.collectionLayout).css("display","none").appendTo("body").fadeIn(o.fade),o._collection.css("position"));r&&"absolute"===a?o._collection.css({top:r.top,left:r.left}):"absolute"===a?(o._collection.css({top:i.top+n.outerHeight(),left:i.left}),r=i.left+o._collection.outerWidth(),(a=s.offset().left+s.width())<r&&o._collection.css("left",i.left-(r-a))):((n=o._collection.height()/2)>p(u).height()/2&&(n=p(u).height()/2),o._collection.css("marginTop",-1*n)),o.background&&c.background(!0,o.backgroundClassName,o.fade),setTimeout(function(){p("div.dt-button-background").on("click.dtb-collection",function(){}),p("body").on("click.dtb-collection",function(t){var n=p.fn.addBack?"addBack":"andSelf";p(t.target).parents()[n]().filter(o._collection).length||(o._collection.fadeOut(o.fade,function(){o._collection.detach()}),p("div.dt-button-background").off("click.dtb-collection"),c.background(!1,o.backgroundClassName,o.fade),p("body").off("click.dtb-collection"),e.off("buttons-action.b-internal"))})},10),o.autoClose&&e.on("buttons-action.b-internal",function(){p("div.dt-button-background").click()})},background:!0,collectionLayout:"",backgroundClassName:"dt-button-background",autoClose:!(c.version="1.3.1"),fade:400},copy:function(t,n){return d.copyHtml5?"copyHtml5":d.copyFlash&&d.copyFlash.available(t,n)?"copyFlash":void 0},csv:function(t,n){return d.csvHtml5&&d.csvHtml5.available(t,n)?"csvHtml5":d.csvFlash&&d.csvFlash.available(t,n)?"csvFlash":void 0},excel:function(t,n){return d.excelHtml5&&d.excelHtml5.available(t,n)?"excelHtml5":d.excelFlash&&d.excelFlash.available(t,n)?"excelFlash":void 0},pdf:function(t,n){return d.pdfHtml5&&d.pdfHtml5.available(t,n)?"pdfHtml5":d.pdfFlash&&d.pdfFlash.available(t,n)?"pdfFlash":void 0},pageLength:function(t){function i(t){return t.i18n("buttons.pageLength",{"-1":"Show all rows",_:"Show %d rows"},t.page.len())}var t=t.settings()[0].aLengthMenu,n=p.isArray(t[0])?t[0]:t,e=p.isArray(t[0])?t[1]:t;return{extend:"collection",text:i,className:"buttons-page-length",autoClose:!0,buttons:p.map(n,function(s,t){return{text:e[t],className:"button-page-length",action:function(t,n){n.page.len(s).draw()},init:function(t,n,e){function o(){i.active(t.page.len()===s)}var i=this;t.on("length.dt"+e.namespace,o),o()},destroy:function(t,n,e){t.off("length.dt"+e.namespace)}}}),init:function(t,n,e){var o=this;t.on("length.dt"+e.namespace,function(){o.text(i(t))})},destroy:function(t,n,e){t.off("length.dt"+e.namespace)}}}}),e.Api.register("buttons()",function(n,e){e===f&&(e=n,n=f),this.selector.buttonGroup=n;var t=this.iterator(!0,"table",function(t){if(t._buttons)return c.buttonSelector(c.instanceSelector(n,t._buttons),e)},!0);return t._groupSelector=n,t}),e.Api.register("button()",function(t,n){t=this.buttons(t,n);return 1<t.length&&t.splice(1,t.length),t}),e.Api.registerPlural("buttons().active()","button().active()",function(n){return n===f?this.map(function(t){return t.inst.active(t.node)}):this.each(function(t){t.inst.active(t.node,n)})}),e.Api.registerPlural("buttons().action()","button().action()",function(n){return n===f?this.map(function(t){return t.inst.action(t.node)}):this.each(function(t){t.inst.action(t.node,n)})}),e.Api.register(["buttons().enable()","button().enable()"],function(n){return this.each(function(t){t.inst.enable(t.node,n)})}),e.Api.register(["buttons().disable()","button().disable()"],function(){return this.each(function(t){t.inst.disable(t.node)})}),e.Api.registerPlural("buttons().nodes()","button().node()",function(){var n=p();return p(this.each(function(t){n=n.add(t.inst.node(t.node))})),n}),e.Api.registerPlural("buttons().processing()","button().processing()",function(n){return n===f?this.map(function(t){return t.inst.processing(t.node)}):this.each(function(t){t.inst.processing(t.node,n)})}),e.Api.registerPlural("buttons().text()","button().text()",function(n){return n===f?this.map(function(t){return t.inst.text(t.node)}):this.each(function(t){t.inst.text(t.node,n)})}),e.Api.registerPlural("buttons().trigger()","button().trigger()",function(){return this.each(function(t){t.inst.node(t.node).trigger("click")})}),e.Api.registerPlural("buttons().containers()","buttons().container()",function(){var i=p(),s=this._groupSelector;return this.iterator(!0,"table",function(t){if(t._buttons)for(var n=c.instanceSelector(s,t._buttons),e=0,o=n.length;e<o;e++)i=i.add(n[e].container())}),i}),e.Api.register("button().add()",function(t,n){var e=this.context;return e.length&&(e=c.instanceSelector(this._groupSelector,e[0]._buttons)).length&&e[0].add(n,t),this.button(this._groupSelector,t)}),e.Api.register("buttons().destroy()",function(){return this.pluck("inst").unique().each(function(t){t.destroy()}),this}),e.Api.registerPlural("buttons().remove()","buttons().remove()",function(){return this.each(function(t){t.inst.remove(t.node)}),this}),e.Api.register("buttons.info()",function(t,n,e){var o=this;return!1===t?(p("#datatables_buttons_info").fadeOut(function(){p(this).remove()}),clearTimeout(i),i=null):(i&&clearTimeout(i),p("#datatables_buttons_info").length&&p("#datatables_buttons_info").remove(),t=t?"<h2>"+t+"</h2>":"",p('<div id="datatables_buttons_info" class="dt-button-info"/>').html(t).append(p("<div/>")["string"==typeof n?"html":"append"](n)).css("display","none").appendTo("body").fadeIn(),e!==f&&0!==e&&(i=setTimeout(function(){o.buttons.info(!1)},e))),this}),e.Api.register("buttons.exportData()",function(t){if(this.context.length)return n(new e.Api(this.context[0]),t)}),p("<textarea/>")[0]),n=function(e,t){for(var o=p.extend(!0,{},{rows:null,columns:"",modifier:{search:"applied",order:"applied"},orthogonal:"display",stripHtml:!0,stripNewlines:!0,decodeEntities:!0,trim:!0,format:{header:function(t){return n(t)},footer:function(t){return n(t)},body:function(t){return n(t)}}},t),n=function(t){return"string"==typeof t&&(t=t.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,""),o.stripHtml&&(t=t.replace(/<[^>]*>/g,"")),o.trim&&(t=t.replace(/^\s+|\s+$/g,"")),o.stripNewlines&&(t=t.replace(/\n/g," ")),o.decodeEntities)&&(g.innerHTML=t,t=g.value),t},t=e.columns(o.columns).indexes().map(function(t){var n=e.column(t).header();return o.format.header(n.innerHTML,t,n)}).toArray(),i=e.table().footer()?e.columns(o.columns).indexes().map(function(t){var n=e.column(t).footer();return o.format.footer(n?n.innerHTML:"",t,n)}).toArray():null,s=e.rows(o.rows,o.modifier).indexes().toArray(),s=e.cells(s,o.columns),r=s.render(o.orthogonal).toArray(),a=s.nodes().toArray(),u=t.length,s=0<u?r.length/u:0,c=new Array(s),l=0,d=0,f=s;d<f;d++){for(var h=new Array(u),b=0;b<u;b++)h[b]=o.format.body(r[l],d,b,a[l]),l++;c[d]=h}return{header:t,footer:i,body:c}};return p.fn.dataTable.Buttons=c,p.fn.DataTable.Buttons=c,p(r).on("init.dt plugin-init.dt",function(t,n){"dt"===t.namespace&&(t=n.oInit.buttons||e.defaults.buttons)&&!n._buttons&&new c(n,t).container()}),e.ext.feature.push({fnInit:function(t){var t=new e.Api(t),n=t.init().buttons||e.defaults.buttons;return new c(t,n).container()},cFeature:"B"}),c});