import Import from"./import";var selectors={formId:"#tablesome-importing-data-form",submit:"#tablesome-importing-data-form .tablesome__button--submit",readFirstRowAsColumn:"#read_first_row_as_column",readEmptyRows:"#read_empty_rows",tableTitle:"#table_title",spinner:".tablesome__spinner"},form={init:function(){this.eventListeners()},eventListeners:function(){jQuery(selectors.submit).on("click",(function(e){e.preventDefault();const t=form.getTableData(),r=Import.validateFile(t);if("fail"==r.type)return alert(r.message),!1;form.disableSubmitButton(),form.loadSpinner(),Import.process(t)}))},getTableData:function(){let e=!1;jQuery(selectors.formId).find(selectors.readFirstRowAsColumn).is(":checked")&&(e=!0);let t=jQuery(selectors.formId).find(selectors.tableTitle).val();t=""!=t?t:"Untitled Table";const r=document.getElementById("file_attachment"),o=r?r.files[0]:[],s=o?o.name.split(".").pop().toLowerCase():"";return{table_title:t,read_first_row_as_column:e,file:o,extension:s}},disableSubmitButton:function(){jQuery(selectors.submit).attr("disabled","disabled")},enableSubmitButton:function(){jQuery(selectors.submit).removeAttr("disabled")},loadSpinner:function(){jQuery(selectors.spinner).addClass("active")},stopSpinner:function(){jQuery(selectors.spinner).removeClass("active")}};export default form;