1const r=/.+/;class o{constructor(){this.$form=$(".j-tax-exemption-form"),this.elements=this.getElements(),this.state={exemptionType:null,states:[],resaleLicenses:[],resaleCertificates:[],otherLicenses:[]},this.bindEvents()}getElements(){return{$firstNameInput:this.$form.find("#firstName"),$lastNameInput:this.$form.find("#lastName"),$companyInput:this.$form.find("#company"),$resaleNumberInput:this.$form.find("#resaleNumber"),$phoneInput:this.$form.find("#phone"),$exemptionTypeDropdown:this.$form.find(".j-exemption-type-dropdown"),$exemptionTypeInput:this.$form.find(".j-exemption-type-input"),$stateOptionsContainer:this.$form.find(".j-state-options"),$stateMultiSelect:this.$form.find(".j-state-options .j-multi-select"),$resellerUploadContainer:this.$form.find(".j-reseller-upload-container"),$otherUploadContainer:this.$form.find(".j-other-upload-container"),$resellerExpander:this.$form.find(".j-reseller-expander"),$resellerTermsCheckboxContainer:this.$form.find(".j-reseller-terms-checkbox-container"),$otherTermsCheckboxContainer:this.$form.find(".j-other-terms-checkbox-container"),$submitButton:this.$form.find(".j-submit")}}bindEvents(){this.bindExemptionTypeDropdown(),this.bindStateMultiSelect(),this.bindResellerLicensesFileUpload(),this.bindResellerResaleCertificatesFileUpload(),this.bindOtherLicensesFileUpload(),this.bindSubmit(),this.bindTermsCheckboxes()}bindExemptionTypeDropdown(){this.elements.$exemptionTypeDropdown.on("dropdown.change",(e,t)=>{const s=t.$target.find("a").data("value");this.state.exemptionType=s,this.elements.$exemptionTypeInput.val(s),s==="RESELLER"?(this.hideExemptionForm(),this.showResellerForm()):(this.hideResellerForm(),this.showExemptionForm()),this.elements.$submitButton.removeClass("hidden")})}bindStateMultiSelect(){this.elements.$stateMultiSelect.on("multiSelect.change",(e,t)=>{this.state.states=t.selectedItems})}bindResellerLicensesFileUpload(){this.elements.$resellerUploadContainer.on("fileUpload.change",".j-licenses-file-upload",(e,t)=>{this.state.resaleLicenses=t.files})}bindResellerResaleCertificatesFileUpload(){this.elements.$resellerUploadContainer.on("fileUpload.change",".j-resale-certificates-file-upload",(e,t)=>{this.state.resaleCertificates=t.files})}bindOtherLicensesFileUpload(){this.elements.$otherUploadContainer.on("fileUpload.change",".j-licenses-file-upload",(e,t)=>{this.state.otherLicenses=t.files})}bindTermsCheckboxes(){this.elements.$resellerTermsCheckboxContainer.on("change","input",e=>{this.elements.$submitButton.prop("disabled",!e.target.checked)}),this.elements.$otherTermsCheckboxContainer.on("change","input",e=>{this.elements.$submitButton.prop("disabled",!e.target.checked)})}bindSubmit(){this.$form.on("submit",e=>{this.validateForm()||(e.preventDefault(),e.stopPropagation(),this.scrollToFirstError())})}validateForm(){let e=[this.isFieldValid(this.elements.$firstNameInput,r),this.isFieldValid(this.elements.$lastNameInput,r),this.isFieldValid(this.elements.$companyInput,r),this.isFieldValid(this.elements.$resaleNumberInput,r),this.isFieldValid(this.elements.$phoneInput,ACC.config.phoneRegex,/\s|-/g)].every(Boolean);if(this.state.exemptionType==="RESELLER"){const t=!!this.state.states.length;this.toggleError(this.elements.$stateMultiSelect,t),e=e&&t;const s=this.elements.$resellerUploadContainer.find(".j-licenses-file-upload"),i=!!this.state.resaleLicenses.length;this.toggleError(s,i),e=e&&i;const l=this.elements.$resellerUploadContainer.find(".j-resale-certificates-file-upload"),n=!!this.state.resaleCertificates.length;this.toggleError(l,n),e=e&&n}else{const t=this.elements.$otherUploadContainer.find(".j-licenses-file-upload"),s=!!this.state.otherLicenses.length;this.toggleError(t,s),e=e&&s}return e}isFieldValid(e,t,s){const i=e.val().trim(),l=s?i.replace(s,""):i,n=l&&t.test(l);return this.toggleError(e,n),n}toggleError(e,t){e.closest(".custom-input-group, .j-file-upload, .j-multi-select").find(".j-input-error").toggle(!t)}scrollToFirstError(){const e=this.$form.find(".j-input-error:visible").first();if(e.length){const t=e.closest(".custom-input-group, .j-file-upload, .j-multi-select").find("input,button");$("html, body").scrollTop(t.offset().top-100),t.focus()}}showExemptionForm(){this.elements.$otherUploadContainer.removeClass("hidden"),this.elements.$otherUploadContainer.find("input").prop("disabled",!1),this.elements.$otherTermsCheckboxContainer.removeClass("hidden"),this.elements.$otherTermsCheckboxContainer.find("input").prop("disabled",!1)}hideExemptionForm(){this.elements.$otherUploadContainer.addClass("hidden"),this.elements.$otherUploadContainer.find("input").prop("disabled",!0),this.elements.$otherTermsCheckboxContainer.addClass("hidden"),this.elements.$otherTermsCheckboxContainer.find("input").prop("disabled",!0)}showResellerForm(){this.elements.$resellerUploadContainer.removeClass("hidden"),this.elements.$resellerUploadContainer.find("input").prop("disabled",!1),this.elements.$resellerExpander.removeClass("hidden"),this.elements.$resellerExpander.find("input").prop("disabled",!1),this.elements.$stateOptionsContainer.removeClass("hidden"),this.elements.$stateOptionsContainer.find("input").prop("disabled",!1),this.elements.$resellerTermsCheckboxContainer.removeClass("hidden"),this.elements.$resellerTermsCheckboxContainer.find("input").prop("disabled",!1)}hideResellerForm(){this.elements.$resellerUploadContainer.addClass("hidden"),this.elements.$resellerUploadContainer.find("input").prop("disabled",!0),this.elements.$resellerExpander.addClass("hidden"),this.elements.$resellerExpander.find("input").prop("disabled",!0),this.elements.$stateOptionsContainer.addClass("hidden"),this.elements.$stateOptionsContainer.find("input").prop("disabled",!0),this.elements.$resellerTermsCheckboxContainer.addClass("hidden"),this.elements.$resellerTermsCheckboxContainer.find("input").prop("disabled",!0)}}const d=()=>new o;export{d as init};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.