/*!
 * jQuery Form Plugin
 * version: 4.3.0
 * Requires jQuery v1.7.2 or later
 * Project repository: https://github.com/jquery-form/form

 * Copyright 2017 Kevin Morris
 * Copyright 2006 M. Alsup

 * Dual licensed under the LGPL-2.1+ or MIT licenses
 * https://github.com/jquery-form/form#license

 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(t,r){return void 0===r&&(r="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(r),r}:e(jQuery)}((function(e){"use strict";var t=/\r?\n/g,r={};r.fileapi=void 0!==e('<input type="file">').get(0).files,r.formdata=void 0!==window.FormData;var a=!!e.fn.prop;function n(t){var r=t.data;t.isDefaultPrevented()||(t.preventDefault(),e(t.target).closest("form").ajaxSubmit(r))}function o(t){var r=t.target,a=e(r);if(!a.is("[type=submit],[type=image]")){var n=a.closest("[type=submit]");if(0===n.length)return;r=n[0]}var o=r.form;if(o.clk=r,"image"===r.type)if(void 0!==t.offsetX)o.clk_x=t.offsetX,o.clk_y=t.offsetY;else if("function"==typeof e.fn.offset){var i=a.offset();o.clk_x=t.pageX-i.left,o.clk_y=t.pageY-i.top}else o.clk_x=t.pageX-r.offsetLeft,o.clk_y=t.pageY-r.offsetTop;setTimeout((function(){o.clk=o.clk_x=o.clk_y=null}),100)}function i(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}e.fn.attr2=function(){if(!a)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t,n,o,s){if(!this.length)return i("ajaxSubmit: skipping submit process - no element selected"),this;var u,c,l,f,d=this;"function"==typeof t?t={success:t}:"string"==typeof t||!1===t&&arguments.length>0?(t={url:t,data:n,dataType:o},"function"==typeof s&&(t.success=s)):void 0===t&&(t={}),u=t.method||t.type||this.attr2("method"),(l=(l="string"==typeof(c=t.url||this.attr2("action"))?e.trim(c):"")||window.location.href||"")&&(l=(l.match(/^([^#]+)/)||[])[1]),f=/(MSIE|Trident)/.test(navigator.userAgent||"")&&/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",t=e.extend(!0,{url:l,success:e.ajaxSettings.success,type:u||e.ajaxSettings.type,iframeSrc:f},t);var p={};if(this.trigger("form-pre-serialize",[this,t,p]),p.veto)return i("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(t.beforeSerialize&&!1===t.beforeSerialize(this,t))return i("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var m=t.traditional;void 0===m&&(m=e.ajaxSettings.traditional);var h,v=[],g=this.formToArray(t.semantic,v,t.filtering);if(t.data){var x="function"==typeof t.data?t.data(g):t.data;t.extraData=x,h=e.param(x,m)}if(t.beforeSubmit&&!1===t.beforeSubmit(g,this,t))return i("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[g,this,t,p]),p.veto)return i("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var y=e.param(g,m);h&&(y=y?y+"&"+h:h),"GET"===t.type.toUpperCase()?(t.url+=(t.url.indexOf("?")>=0?"&":"?")+y,t.data=null):t.data=y;var b=[];if(t.resetForm&&b.push((function(){d.resetForm()})),t.clearForm&&b.push((function(){d.clearForm(t.includeHidden)})),!t.dataType&&t.target){var T=t.success||function(){};b.push((function(r,a,n){var o=arguments,i=t.replaceTarget?"replaceWith":"html";e(t.target)[i](r).each((function(){T.apply(this,o)}))}))}else t.success&&(Array.isArray(t.success)?e.merge(b,t.success):b.push(t.success));if(t.success=function(e,r,a){for(var n=t.context||this,o=0,i=b.length;o<i;o++)b[o].apply(n,[e,r,a||d,d])},t.error){var j=t.error;t.error=function(e,r,a){var n=t.context||this;j.apply(n,[e,r,a,d])}}if(t.complete){var S=t.complete;t.complete=function(e,r){var a=t.context||this;S.apply(a,[e,r,d])}}var w=e("input[type=file]:enabled",this).filter((function(){return""!==e(this).val()})),k=w.length>0,D="multipart/form-data",A=d.attr("enctype")===D||d.attr("encoding")===D,L=r.fileapi&&r.formdata;i("fileAPI :"+L);var E,F=(k||A)&&!L;!1!==t.iframe&&(t.iframe||F)?t.closeKeepAlive?e.get(t.closeKeepAlive,(function(){E=C(g)})):E=C(g):E=(k||A)&&L?X(g):e.ajax(t),d.removeData("jqxhr").data("jqxhr",E);for(var M=0;M<v.length;M++)v[M]=null;return this.trigger("form-submit-notify",[this,t]),this;function O(r){var a,n,o=e.param(r,t.traditional).split("&"),i=o.length,s=[];for(a=0;a<i;a++)o[a]=o[a].replace(/\+/g," "),n=o[a].split("="),s.push([decodeURIComponent(n[0]),decodeURIComponent(n[1])]);return s}function X(r){for(var a=new FormData,n=0;n<r.length;n++)a.append(r[n].name,r[n].value);if(t.extraData){var o=O(t.extraData);for(n=0;n<o.length;n++)o[n]&&a.append(o[n][0],o[n][1])}t.data=null;var i=e.extend(!0,{},e.ajaxSettings,t,{contentType:!1,processData:!1,cache:!1,type:u||"POST"});t.uploadProgress&&(i.xhr=function(){var r=e.ajaxSettings.xhr();return r.upload&&r.upload.addEventListener("progress",(function(e){var r=0,a=e.loaded||e.position,n=e.total;e.lengthComputable&&(r=Math.ceil(a/n*100)),t.uploadProgress(e,a,n,r)}),!1),r}),i.data=null;var s=i.beforeSend;return i.beforeSend=function(e,r){t.formData?r.data=t.formData:r.data=a,s&&s.call(this,e,r)},e.ajax(i)}function C(r){var n,o,s,c,l,f,p,m,h,g,x,y,b=d[0],T=e.Deferred();if(T.abort=function(e){m.abort(e)},r)for(o=0;o<v.length;o++)n=e(v[o]),a?n.prop("disabled",!1):n.removeAttr("disabled");(s=e.extend(!0,{},e.ajaxSettings,t)).context=s.context||s,l="jqFormIO"+(new Date).getTime();var j=b.ownerDocument,S=d.closest("body");if(s.iframeTarget?(g=(f=e(s.iframeTarget,j)).attr2("name"))?l=g:f.attr2("name",l):(f=e('<iframe name="'+l+'" src="'+s.iframeSrc+'" />',j)).css({position:"absolute",top:"-1000px",left:"-1000px"}),p=f[0],m={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(t){var r="timeout"===t?"timeout":"aborted";i("aborting upload... "+r),this.aborted=1;try{p.contentWindow.document.execCommand&&p.contentWindow.document.execCommand("Stop")}catch(e){}f.attr("src",s.iframeSrc),m.error=r,s.error&&s.error.call(s.context,m,r,t),c&&e.event.trigger("ajaxError",[m,s,r]),s.complete&&s.complete.call(s.context,m,r)}},(c=s.global)&&0==e.active++&&e.event.trigger("ajaxStart"),c&&e.event.trigger("ajaxSend",[m,s]),s.beforeSend&&!1===s.beforeSend.call(s.context,m,s))return s.global&&e.active--,T.reject(),T;if(m.aborted)return T.reject(),T;(h=b.clk)&&(g=h.name)&&!h.disabled&&(s.extraData=s.extraData||{},s.extraData[g]=h.value,"image"===h.type&&(s.extraData[g+".x"]=b.clk_x,s.extraData[g+".y"]=b.clk_y));function w(e){var t=null;try{e.contentWindow&&(t=e.contentWindow.document)}catch(e){i("cannot get iframe.contentWindow document: "+e)}if(t)return t;try{t=e.contentDocument?e.contentDocument:e.document}catch(r){i("cannot get iframe.contentDocument: "+r),t=e.document}return t}var k=e("meta[name=csrf-token]").attr("content"),D=e("meta[name=csrf-param]").attr("content");function A(){var t=d.attr2("target"),r=d.attr2("action"),a=d.attr("enctype")||d.attr("encoding")||"multipart/form-data";b.setAttribute("target",l),u&&!/post/i.test(u)||b.setAttribute("method","POST"),r!==s.url&&b.setAttribute("action",s.url),s.skipEncodingOverride||u&&!/post/i.test(u)||d.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),s.timeout&&(y=setTimeout((function(){x=!0,O(1)}),s.timeout));var n=[];try{if(s.extraData)for(var o in s.extraData)s.extraData.hasOwnProperty(o)&&(e.isPlainObject(s.extraData[o])&&s.extraData[o].hasOwnProperty("name")&&s.extraData[o].hasOwnProperty("value")?n.push(e('<input type="hidden" name="'+s.extraData[o].name+'">',j).val(s.extraData[o].value).appendTo(b)[0]):n.push(e('<input type="hidden" name="'+o+'">',j).val(s.extraData[o]).appendTo(b)[0]));s.iframeTarget||f.appendTo(S),p.attachEvent?p.attachEvent("onload",O):p.addEventListener("load",O,!1),setTimeout((function e(){try{var t=w(p).readyState;i("state = "+t),t&&"uninitialized"===t.toLowerCase()&&setTimeout(e,50)}catch(e){i("Server abort: ",e," (",e.name,")"),O(2),y&&clearTimeout(y),y=void 0}}),15);try{b.trigger("submit")}catch(e){document.createElement("form").submit.apply(b)}}finally{b.setAttribute("action",r),b.setAttribute("enctype",a),t?b.setAttribute("target",t):d.removeAttr("target"),e(n).remove()}}D&&k&&(s.extraData=s.extraData||{},s.extraData[D]=k),s.forceSync?A():setTimeout(A,10);var L,E,F,M=50;function O(t){if(!m.aborted&&!F){if((E=w(p))||(i("cannot access response document"),t=2),1===t&&m)return m.abort("timeout"),void T.reject(m,"timeout");if(2===t&&m)return m.abort("server abort"),void T.reject(m,"error","server abort");if(E&&E.location.href!==s.iframeSrc||x){p.detachEvent?p.detachEvent("onload",O):p.removeEventListener("load",O,!1);var r,a="success";try{if(x)throw"timeout";var n="xml"===s.dataType||E.XMLDocument||e.isXMLDoc(E);if(i("isXml="+n),!n&&window.opera&&(null===E.body||!E.body.innerHTML)&&--M)return i("requeing onLoad callback, DOM not available"),void setTimeout(O,250);var o=E.body?E.body:E.documentElement;m.responseText=o?o.innerHTML:null,m.responseXML=E.XMLDocument?E.XMLDocument:E,n&&(s.dataType="xml"),m.getResponseHeader=function(e){return{"content-type":s.dataType}[e.toLowerCase()]},o&&(m.status=Number(o.getAttribute("status"))||m.status,m.statusText=o.getAttribute("statusText")||m.statusText);var u=(s.dataType||"").toLowerCase(),l=/(json|script|text)/.test(u);if(l||s.textarea){var d=E.getElementsByTagName("textarea")[0];if(d)m.responseText=d.value,m.status=Number(d.getAttribute("status"))||m.status,m.statusText=d.getAttribute("statusText")||m.statusText;else if(l){var h=E.getElementsByTagName("pre")[0],v=E.getElementsByTagName("body")[0];h?m.responseText=h.textContent?h.textContent:h.innerText:v&&(m.responseText=v.textContent?v.textContent:v.innerText)}}else"xml"===u&&!m.responseXML&&m.responseText&&(m.responseXML=X(m.responseText));try{L=C(m,u,s)}catch(e){a="parsererror",m.error=r=e||a}}catch(e){i("error caught: ",e),a="error",m.error=r=e||a}m.aborted&&(i("upload aborted"),a=null),m.status&&(a=m.status>=200&&m.status<300||304===m.status?"success":"error"),"success"===a?(s.success&&s.success.call(s.context,L,"success",m),T.resolve(m.responseText,"success",m),c&&e.event.trigger("ajaxSuccess",[m,s])):a&&(void 0===r&&(r=m.statusText),s.error&&s.error.call(s.context,m,a,r),T.reject(m,"error",r),c&&e.event.trigger("ajaxError",[m,s,r])),c&&e.event.trigger("ajaxComplete",[m,s]),c&&!--e.active&&e.event.trigger("ajaxStop"),s.complete&&s.complete.call(s.context,m,a),F=!0,s.timeout&&clearTimeout(y),setTimeout((function(){s.iframeTarget?f.attr("src",s.iframeSrc):f.remove(),m.responseXML=null}),100)}}}var X=e.parseXML||function(e,t){return window.ActiveXObject?((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!==t.documentElement.nodeName?t:null},C=function(t,r,a){var n=t.getResponseHeader("content-type")||"",o=("xml"===r||!r)&&n.indexOf("xml")>=0,i=o?t.responseXML:t.responseText;return o&&"parsererror"===i.documentElement.nodeName&&e.error&&e.error("parsererror"),a&&a.dataFilter&&(i=a.dataFilter(i,r)),"string"==typeof i&&(("json"===r||!r)&&n.indexOf("json")>=0?i=JSON.parse(i):("script"===r||!r)&&n.indexOf("javascript")>=0&&e.globalEval(i)),i};return T}},e.fn.ajaxForm=function(t,r,a,s){if(("string"==typeof t||!1===t&&arguments.length>0)&&(t={url:t,data:r,dataType:a},"function"==typeof s&&(t.success=s)),(t=t||{}).delegation=t.delegation&&"function"==typeof e.fn.on,!t.delegation&&0===this.length){var u={s:this.selector,c:this.context};return!e.isReady&&u.s?(i("DOM not ready, queuing ajaxForm"),e((function(){e(u.s,u.c).ajaxForm(t)})),this):(i("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)")),this)}return t.delegation?(e(document).off("submit.form-plugin",this.selector,n).off("click.form-plugin",this.selector,o).on("submit.form-plugin",this.selector,t,n).on("click.form-plugin",this.selector,t,o),this):(t.beforeFormUnbind&&t.beforeFormUnbind(this,t),this.ajaxFormUnbind().on("submit.form-plugin",t,n).on("click.form-plugin",t,o))},e.fn.ajaxFormUnbind=function(){return this.off("submit.form-plugin click.form-plugin")},e.fn.formToArray=function(t,a,n){var o=[];if(0===this.length)return o;var i,s,u,c,l,f,d,p,m=this[0],h=this.attr("id"),v=t||void 0===m.elements?m.getElementsByTagName("*"):m.elements;if(v&&(v=e.makeArray(v)),h&&(t||/(Edge|Trident)\//.test(navigator.userAgent))&&(i=e(':input[form="'+h+'"]').get()).length&&(v=(v||[]).concat(i)),!v||!v.length)return o;for("function"==typeof n&&(v=e.map(v,n)),s=0,d=v.length;s<d;s++)if((c=(f=v[s]).name)&&!f.disabled)if(t&&m.clk&&"image"===f.type)m.clk===f&&(o.push({name:c,value:e(f).val(),type:f.type}),o.push({name:c+".x",value:m.clk_x},{name:c+".y",value:m.clk_y}));else if((l=e.fieldValue(f,!0))&&l.constructor===Array)for(a&&a.push(f),u=0,p=l.length;u<p;u++)o.push({name:c,value:l[u]});else if(r.fileapi&&"file"===f.type){a&&a.push(f);var g=f.files;if(g.length)for(u=0;u<g.length;u++)o.push({name:c,value:g[u],type:f.type});else o.push({name:c,value:"",type:f.type})}else null!=l&&(a&&a.push(f),o.push({name:c,value:l,type:f.type,required:f.required}));if(!t&&m.clk){var x=e(m.clk),y=x[0];(c=y.name)&&!y.disabled&&"image"===y.type&&(o.push({name:c,value:x.val()}),o.push({name:c+".x",value:m.clk_x},{name:c+".y",value:m.clk_y}))}return o},e.fn.formSerialize=function(t){return e.param(this.formToArray(t))},e.fn.fieldSerialize=function(t){var r=[];return this.each((function(){var a=this.name;if(a){var n=e.fieldValue(this,t);if(n&&n.constructor===Array)for(var o=0,i=n.length;o<i;o++)r.push({name:a,value:n[o]});else null!=n&&r.push({name:this.name,value:n})}})),e.param(r)},e.fn.fieldValue=function(t){for(var r=[],a=0,n=this.length;a<n;a++){var o=this[a],i=e.fieldValue(o,t);null==i||i.constructor===Array&&!i.length||(i.constructor===Array?e.merge(r,i):r.push(i))}return r},e.fieldValue=function(r,a){var n=r.name,o=r.type,i=r.tagName.toLowerCase();if(void 0===a&&(a=!0),a&&(!n||r.disabled||"reset"===o||"button"===o||("checkbox"===o||"radio"===o)&&!r.checked||("submit"===o||"image"===o)&&r.form&&r.form.clk!==r||"select"===i&&-1===r.selectedIndex))return null;if("select"===i){var s=r.selectedIndex;if(s<0)return null;for(var u=[],c=r.options,l="select-one"===o,f=l?s+1:c.length,d=l?s:0;d<f;d++){var p=c[d];if(p.selected&&!p.disabled){var m=p.value;if(m||(m=p.attributes&&p.attributes.value&&!p.attributes.value.specified?p.text:p.value),l)return m;u.push(m)}}return u}return e(r).val().replace(t,"\r\n")},e.fn.clearForm=function(t){return this.each((function(){e("input,select,textarea",this).clearFields(t)}))},e.fn.clearFields=e.fn.clearInputs=function(t){var r=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each((function(){var a=this.type,n=this.tagName.toLowerCase();r.test(a)||"textarea"===n?this.value="":"checkbox"===a||"radio"===a?this.checked=!1:"select"===n?this.selectedIndex=-1:"file"===a?/MSIE/.test(navigator.userAgent)?e(this).replaceWith(e(this).clone(!0)):e(this).val(""):t&&(!0===t&&/hidden/.test(a)||"string"==typeof t&&e(this).is(t))&&(this.value="")}))},e.fn.resetForm=function(){return this.each((function(){var t=e(this),r=this.tagName.toLowerCase();switch(r){case"input":this.checked=this.defaultChecked;case"textarea":return this.value=this.defaultValue,!0;case"option":case"optgroup":var a=t.parents("select");return a.length&&a[0].multiple?"option"===r?this.selected=this.defaultSelected:t.find("option").resetForm():a.resetForm(),!0;case"select":return t.find("option").each((function(e){if(this.selected=this.defaultSelected,this.defaultSelected&&!t[0].multiple)return t[0].selectedIndex=e,!1})),!0;case"label":var n=e(t.attr("for")),o=t.find("input,select,textarea");return n[0]&&o.unshift(n[0]),o.resetForm(),!0;case"form":return("function"==typeof this.reset||"object"==typeof this.reset&&!this.reset.nodeType)&&this.reset(),!0;default:return t.find("form,input,label,select,textarea").resetForm(),!0}}))},e.fn.enable=function(e){return void 0===e&&(e=!0),this.each((function(){this.disabled=!e}))},e.fn.selected=function(t){return void 0===t&&(t=!0),this.each((function(){var r=this.type;if("checkbox"===r||"radio"===r)this.checked=t;else if("option"===this.tagName.toLowerCase()){var a=e(this).parent("select");t&&a[0]&&"select-one"===a[0].type&&a.find("option").selected(!1),this.selected=t}}))},e.fn.ajaxSubmit.debug=!1}));
