2 var _typeof=
"function"==typeof Symbol&&
"symbol"==typeof Symbol.iterator?
function(e){
return typeof e}:
function(e){
return e&&
"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?
"symbol":typeof e},Ajax=
function(e){this.table=e,this.config=!1,this.url=
"",this.urlGenerator=!1,this.params=!1,this.loaderElement=this.createLoaderElement(),this.msgElement=this.createMsgElement(),this.loadingElement=!1,this.errorElement=!1,this.loaderPromise=!1,this.progressiveLoad=!1,this.loading=!1,this.requestOrder=0};Ajax.prototype.initialize=
function(){var e;this.loaderElement.appendChild(this.msgElement),this.table.options.ajaxLoaderLoading&&(
"string"==typeof this.table.options.ajaxLoaderLoading?(e=document.createElement(
"template"),e.innerHTML=this.table.options.ajaxLoaderLoading.trim(),this.loadingElement=e.content.firstChild):this.loadingElement=this.table.options.ajaxLoaderLoading),this.loaderPromise=this.table.options.ajaxRequestFunc||this.defaultLoaderPromise,this.urlGenerator=this.table.options.ajaxURLGenerator||this.defaultURLGenerator,this.table.options.ajaxLoaderError&&(
"string"==typeof this.table.options.ajaxLoaderError?(e=document.createElement(
"template"),e.innerHTML=this.table.options.ajaxLoaderError.trim(),this.errorElement=e.content.firstChild):this.errorElement=this.table.options.ajaxLoaderError),this.table.options.ajaxParams&&this.setParams(this.table.options.ajaxParams),this.table.options.ajaxConfig&&this.setConfig(this.table.options.ajaxConfig),this.table.options.ajaxURL&&this.setUrl(this.table.options.ajaxURL),this.table.options.ajaxProgressiveLoad&&(this.table.options.pagination?(this.progressiveLoad=!1,console.error(
"Progressive Load Error - Pagination and progressive load cannot be used at the same time")):this.table.modExists(
"page")?(this.progressiveLoad=this.table.options.ajaxProgressiveLoad,this.table.modules.page.initializeProgressive(this.progressiveLoad)):console.error(
"Pagination plugin is required for progressive ajax loading"))},Ajax.prototype.createLoaderElement=
function(){var e=document.createElement(
"div");
return e.classList.add(
"tabulator-loader"),e},Ajax.prototype.createMsgElement=
function(){var e=document.createElement(
"div");
return e.classList.add(
"tabulator-loader-msg"),e.setAttribute(
"role",
"alert"),e},Ajax.prototype.setParams=
function(e,t){
if(t){this.params=this.params||{};
for(var o in e)this.params[o]=e[o]}
else this.params=e},Ajax.prototype.getParams=
function(){
return this.params||{}},Ajax.prototype.setConfig=
function(e){
if(this._loadDefaultConfig(),
"string"==typeof e)this.config.method=e;
else for(var t in e)this.config[t]=e[t]},Ajax.prototype._loadDefaultConfig=
function(e){var t=
this;
if(!t.config||e){t.config={};
for(var o in t.defaultConfig)t.config[o]=t.defaultConfig[o]}},Ajax.prototype.setUrl=
function(e){this.url=e},Ajax.prototype.getUrl=
function(){
return this.url},Ajax.prototype.loadData=
function(e){
return this.progressiveLoad?this._loadDataProgressive():this._loadDataStandard(e)},Ajax.prototype.nextPage=function(e){var t;this.loading||(t=this.table.options.ajaxProgressiveLoadScrollMargin||2*this.table.rowManager.getElement().clientHeight,e<t&&this.table.modules.page.nextPage().then(
function(){}).
catch(
function(){}))},Ajax.prototype.blockActiveRequest=
function(){this.requestOrder++},Ajax.prototype._loadDataProgressive=
function(){
return this.table.rowManager.setData([]),this.table.modules.page.setPage(1)},Ajax.prototype._loadDataStandard=
function(e){var t=
this;
return new Promise(
function(o,a){t.sendRequest(e).then(
function(r){t.table.rowManager.setData(r,e).then(
function(){o()}).
catch(
function(e){a(e)})}).catch(
function(e){a(e)})})},Ajax.prototype.generateParamsList=
function(e,t){var o=
this,a=[];
if(t=t||
"",Array.isArray(e))e.forEach(
function(e,r){a=a.concat(o.generateParamsList(e,t?t+
"["+r+
"]":r))});
else if(
"object"===(
void 0===e?
"undefined":_typeof(e)))
for(var r in e)a=a.concat(o.generateParamsList(e[r],t?t+
"["+r+
"]":r));
else a.push({key:t,value:e});
return a},Ajax.prototype.serializeParams=
function(e){var t=this.generateParamsList(e),o=[];
return t.forEach(
function(e){o.push(encodeURIComponent(e.key)+
"="+encodeURIComponent(e.value))}),o.join(
"&")},Ajax.prototype.sendRequest=
function(e){var t,o=
this,a=
this,r=a.url;
return a.requestOrder++,t=a.requestOrder,a._loadDefaultConfig(),
new Promise(
function(i,n){!1!==a.table.options.ajaxRequesting.call(o.table,a.url,a.params)?(a.loading=!0,e||a.showLoader(),o.loaderPromise(r,a.config,a.params).then(
function(e){t===a.requestOrder?(a.table.options.ajaxResponse&&(e=a.table.options.ajaxResponse.call(a.table,a.url,a.params,e)),i(e)):console.warn(
"Ajax Response Blocked - An active ajax request was blocked by an attempt to change table data while the request was being made"),a.hideLoader(),a.loading=!1}).
catch(
function(e){console.error(
"Ajax Load Error: ",e),a.table.options.ajaxError.call(a.table,e),a.showError(),setTimeout(
function(){a.hideLoader()},3e3),a.loading=!1,n()})):n()})},Ajax.prototype.showLoader=
function(){
if(
"function"==typeof this.table.options.ajaxLoader?
this.table.options.ajaxLoader():this.table.options.ajaxLoader){
for(this.hideLoader();this.msgElement.firstChild;)this.msgElement.removeChild(
this.msgElement.firstChild);this.msgElement.classList.remove(
"tabulator-error"),this.msgElement.classList.add(
"tabulator-loading"),this.loadingElement?this.msgElement.appendChild(this.loadingElement):this.msgElement.innerHTML=this.table.modules.localize.getText(
"ajax|loading"),this.table.element.appendChild(this.loaderElement)}},Ajax.prototype.showError=
function(){
for(this.hideLoader();this.msgElement.firstChild;)this.msgElement.removeChild(
this.msgElement.firstChild);this.msgElement.classList.remove(
"tabulator-loading"),this.msgElement.classList.add(
"tabulator-error"),this.errorElement?this.msgElement.appendChild(this.errorElement):this.msgElement.innerHTML=this.table.modules.localize.getText(
"ajax|error"),this.table.element.appendChild(this.loaderElement)},Ajax.prototype.hideLoader=
function(){this.loaderElement.parentNode&&this.loaderElement.parentNode.removeChild(this.loaderElement)},Ajax.prototype.defaultConfig={method:
"GET"},Ajax.prototype.defaultURLGenerator=
function(e,t,o){
return e&&o&&Object.keys(o).length&&(t.method&&
"get"!=t.method.toLowerCase()||(t.method=
"get",e+=(e.includes(
"?")?
"&":
"?")+this.serializeParams(o))),e},Ajax.prototype.defaultLoaderPromise=
function(e,t,o){var a,r=
this;
return new Promise(
function(i,n){
if(e=r.urlGenerator(e,t,o),
"GET"!=t.method.toUpperCase())
if(a=
"object"===_typeof(r.table.options.ajaxContentType)?r.table.options.ajaxContentType:r.contentTypeFormatters[r.table.options.ajaxContentType]){
for(var s in a.headers)t.headers||(t.headers={}),
void 0===t.headers[s]&&(t.headers[s]=a.headers[s]);t.body=a.body.call(r,e,t,o)}
else console.warn(
"Ajax Error - Invalid ajaxContentType value:",r.table.options.ajaxContentType);e?(
void 0===t.headers&&(t.headers={}),
void 0===t.headers.Accept&&(t.headers.Accept=
"application/json"),
void 0===t.headers[
"X-Requested-With"]&&(t.headers[
"X-Requested-With"]=
"XMLHttpRequest"),
void 0===t.mode&&(t.mode=
"cors"),
"cors"==t.mode?(
void 0===t.headers[
"Access-Control-Allow-Origin"]&&(t.headers[
"Access-Control-Allow-Origin"]=window.location.origin),
void 0===t.credentials&&(t.credentials=
"same-origin")):
void 0===t.credentials&&(t.credentials=
"include"),fetch(e,t).then(
function(e){e.ok?e.json().then(
function(e){i(e)}).
catch(
function(e){n(e),console.warn(
"Ajax Load Error - Invalid JSON returned",e)}):(console.error(
"Ajax Load Error - Connection Error: "+e.status,e.statusText),n(e))}).catch(
function(e){console.error(
"Ajax Load Error - Connection Error: ",e),n(e)})):(console.warn(
"Ajax Load Error - No URL Set"),i([]))})},Ajax.prototype.contentTypeFormatters={json:{headers:{
"Content-Type":
"application/json"},body:
function(e,t,o){
return JSON.stringify(o)}},form:{headers:{},body:
function(e,t,o){var a=this.generateParamsList(o),r=
new FormData;
return a.forEach(
function(e){r.append(e.key,e.value)}),r}}},Tabulator.prototype.registerModule(
"ajax",Ajax);