You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
validator/dist/js/demo.js

12 lines
34 KiB

(()=>{var e={422:e=>{var t=/^(?:submit|button|image|reset|file)$/i,n=/^(?:input|select|textarea|keygen)/i,r=/(\[[^\[\]]*\])/g;function i(e,t,n){if(0===t.length)return e=n;var r=t.shift(),o=r.match(/^\[(.+?)\]$/);if("[]"===r)return e=e||[],Array.isArray(e)?e.push(i(null,t,n)):(e._values=e._values||[],e._values.push(i(null,t,n))),e;if(o){var s=o[1],a=+s;isNaN(a)?(e=e||{})[s]=i(e[s],t,n):(e=e||[])[a]=i(e[a],t,n)}else e[r]=i(e[r],t,n);return e}function o(e,t,n){if(t.match(r)){i(e,function(e){var t=[],n=new RegExp(r),i=/^([^\[\]]*)/.exec(e);for(i[1]&&t.push(i[1]);null!==(i=n.exec(e));)t.push(i[1]);return t}(t),n)}else{var o=e[t];o?(Array.isArray(o)||(e[t]=[o]),e[t].push(n)):e[t]=n}return e}function s(e,t,n){return n=n.replace(/(\r)?\n/g,"\r\n"),n=(n=encodeURIComponent(n)).replace(/%20/g,"+"),e+(e?"&":"")+encodeURIComponent(t)+"="+n}e.exports=function(e,r){"object"!=typeof r?r={hash:!!r}:void 0===r.hash&&(r.hash=!0);for(var i=r.hash?{}:"",a=r.serializer||(r.hash?o:s),u=e&&e.elements?e.elements:[],l=Object.create(null),c=0;c<u.length;++c){var f=u[c];if((r.disabled||!f.disabled)&&f.name&&(n.test(f.nodeName)&&!t.test(f.type))){var p=f.name,d=f.value;if("checkbox"!==f.type&&"radio"!==f.type||f.checked||(d=void 0),r.empty){if("checkbox"!==f.type||f.checked||(d=""),"radio"===f.type&&(l[f.name]||f.checked?f.checked&&(l[f.name]=!0):l[f.name]=!1),null==d&&"radio"==f.type)continue}else if(!d)continue;if("select-multiple"!==f.type)i=a(i,p,d);else{d=[];for(var h=f.options,m=!1,g=0;g<h.length;++g){var b=h[g],v=r.empty&&!b.value,y=b.value||v;b.selected&&y&&(m=!0,i=r.hash&&"[]"!==p.slice(p.length-2)?a(i,p+"[]",b.value):a(i,p,b.value))}!m&&r.empty&&(i=a(i,p,""))}}}if(r.empty)for(var p in l)l[p]||(i=a(i,p,""));return i}},765:function(e,t,n){e=n.nmd(e),
/*!
* validate.js 0.13.1
*
* (c) 2013-2019 Nicklas Ansman, 2013 Wrapp
* Validate.js may be freely distributed under the MIT license.
* For all details and documentation:
* http://validatejs.org/
*/
function(e,t,r){"use strict";var i=function(e,t,n){n=o.extend({},o.options,n);var r=o.runValidations(e,t,n);if(r.some((function(e){return o.isPromise(e.error)})))throw new Error("Use validate.async if you want support for promises");return i.processValidationResults(r,n)},o=i;o.extend=function(e){return[].slice.call(arguments,1).forEach((function(t){for(var n in t)e[n]=t[n]})),e},o.extend(i,{version:{major:0,minor:13,patch:1,metadata:null,toString:function(){var e=o.format("%{major}.%{minor}.%{patch}",o.version);return o.isEmpty(o.version.metadata)||(e+="+"+o.version.metadata),e}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(e,t,n){var r,i,s,a,u,l,c,f=[];for(r in(o.isDomElement(e)||o.isJqueryElement(e))&&(e=o.collectFormValues(e)),t)for(i in s=o.getDeepObjectValue(e,r),a=o.result(t[r],s,e,r,n,t)){if(!(u=o.validators[i]))throw c=o.format("Unknown validator %{name}",{name:i}),new Error(c);l=a[i],(l=o.result(l,s,e,r,n,t))&&f.push({attribute:r,value:s,validator:i,globalOptions:n,attributes:e,options:l,error:u.call(u,s,l,r,e,n)})}return f},processValidationResults:function(e,t){e=o.pruneEmptyErrors(e,t),e=o.expandMultipleErrors(e,t),e=o.convertErrorMessages(e,t);var n=t.format||"grouped";if("function"!=typeof o.formatters[n])throw new Error(o.format("Unknown format %{format}",t));return e=o.formatters[n](e),o.isEmpty(e)?void 0:e},async:function(e,t,n){var r=(n=o.extend({},o.async.options,n)).wrapErrors||function(e){return e};!1!==n.cleanAttributes&&(e=o.cleanAttributes(e,t));var i=o.runValidations(e,t,n);return new o.Promise((function(s,a){o.waitForResults(i).then((function(){var u=o.processValidationResults(i,n);u?a(new r(u,n,e,t)):s(e)}),(function(e){a(e)}))}))},single:function(e,t,n){return n=o.extend({},o.single.options,n,{format:"flat",fullMessages:!1}),o({single:e},{single:t},n)},waitForResults:function(e){return e.reduce((function(e,t){return o.isPromise(t.error)?e.then((function(){return t.error.then((function(e){t.error=e||null}))})):e}),new o.Promise((function(e){e()})))},result:function(e){var t=[].slice.call(arguments,1);return"function"==typeof e&&(e=e.apply(null,t)),e},isNumber:function(e){return"number"==typeof e&&!isNaN(e)},isFunction:function(e){return"function"==typeof e},isInteger:function(e){return o.isNumber(e)&&e%1==0},isBoolean:function(e){return"boolean"==typeof e},isObject:function(e){return e===Object(e)},isDate:function(e){return e instanceof Date},isDefined:function(e){return null!=e},isPromise:function(e){return!!e&&o.isFunction(e.then)},isJqueryElement:function(e){return e&&o.isString(e.jquery)},isDomElement:function(e){return!!e&&(!(!e.querySelectorAll||!e.querySelector)&&(!(!o.isObject(document)||e!==document)||("object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName)))},isEmpty:function(e){var t;if(!o.isDefined(e))return!0;if(o.isFunction(e))return!1;if(o.isString(e))return o.EMPTY_STRING_REGEXP.test(e);if(o.isArray(e))return 0===e.length;if(o.isDate(e))return!1;if(o.isObject(e)){for(t in e)return!1;return!0}return!1},format:o.extend((function(e,t){return o.isString(e)?e.replace(o.format.FORMAT_REGEXP,(function(e,n,r){return"%"===n?"%{"+r+"}":String(t[r])})):e}),{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(e){return o.isNumber(e)?100*e%1==0?""+e:parseFloat(Math.round(100*e)/100).toFixed(2):o.isArray(e)?e.map((function(e){return o.prettify(e)})).join(", "):o.isObject(e)?o.isDefined(e.toString)?e.toString():JSON.stringify(e):(e=""+e).replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,(function(e,t,n){return t+" "+n.toLowerCase()})).toLowerCase()},stringifyValue:function(e,t){return(t&&t.prettify||o.prettify)(e)},isString:function(e){return"string"==typeof e},isArray:function(e){return"[object Array]"==={}.toString.call(e)},isHash:function(e){return o.isObject(e)&&!o.isArray(e)&&!o.isFunction(e)},contains:function(e,t){return!!o.isDefined(e)&&(o.isArray(e)?-1!==e.indexOf(t):t in e)},unique:function(e){return o.isArray(e)?e.filter((function(e,t,n){return n.indexOf(e)==t})):e},forEachKeyInKeypath:function(e,t,n){if(o.isString(t)){var r,i="",s=!1;for(r=0;r<t.length;++r)switch(t[r]){case".":s?(s=!1,i+="."):(e=n(e,i,!1),i="");break;case"\\":s?(s=!1,i+="\\"):s=!0;break;default:s=!1,i+=t[r]}return n(e,i,!0)}},getDeepObjectValue:function(e,t){if(o.isObject(e))return o.forEachKeyInKeypath(e,t,(function(e,t){if(o.isObject(e))return e[t]}))},collectFormValues:function(e,t){var n,r,i,s,a,u,l={};if(o.isJqueryElement(e)&&(e=e[0]),!e)return l;for(t=t||{},s=e.querySelectorAll("input[name], textarea[name]"),n=0;n<s.length;++n)if(i=s.item(n),!o.isDefined(i.getAttribute("data-ignored"))){var c=i.name.replace(/\./g,"\\\\.");u=o.sanitizeFormValue(i.value,t),"number"===i.type?u=u?+u:null:"checkbox"===i.type?i.attributes.value?i.checked||(u=l[c]||null):u=i.checked:"radio"===i.type&&(i.checked||(u=l[c]||null)),l[c]=u}for(s=e.querySelectorAll("select[name]"),n=0;n<s.length;++n)if(i=s.item(n),!o.isDefined(i.getAttribute("data-ignored"))){if(i.multiple)for(r in u=[],i.options)(a=i.options[r])&&a.selected&&u.push(o.sanitizeFormValue(a.value,t));else{var f=void 0!==i.options[i.selectedIndex]?i.options[i.selectedIndex].value:"";u=o.sanitizeFormValue(f,t)}l[i.name]=u}return l},sanitizeFormValue:function(e,t){return t.trim&&o.isString(e)&&(e=e.trim()),!1!==t.nullify&&""===e?null:e},capitalize:function(e){return o.isString(e)?e[0].toUpperCase()+e.slice(1):e},pruneEmptyErrors:function(e){return e.filter((function(e){return!o.isEmpty(e.error)}))},expandMultipleErrors:function(e){var t=[];return e.forEach((function(e){o.isArray(e.error)?e.error.forEach((function(n){t.push(o.extend({},e,{error:n}))})):t.push(e)})),t},convertErrorMessages:function(e,t){var n=[],r=(t=t||{}).prettify||o.prettify;return e.forEach((function(e){var i=o.result(e.error,e.value,e.attribute,e.options,e.attributes,e.globalOptions);o.isString(i)?("^"===i[0]?i=i.slice(1):!1!==t.fullMessages&&(i=o.capitalize(r(e.attribute))+" "+i),i=i.replace(/\\\^/g,"^"),i=o.format(i,{value:o.stringifyValue(e.value,t)}),n.push(o.extend({},e,{error:i}))):n.push(e)})),n},groupErrorsByAttribute:function(e){var t={};return e.forEach((function(e){var n=t[e.attribute];n?n.push(e):t[e.attribute]=[e]})),t},flattenErrorsToArray:function(e){return e.map((function(e){return e.error})).filter((function(e,t,n){return n.indexOf(e)===t}))},cleanAttributes:function(e,t){function n(e,t,n){return o.isObject(e[t])?e[t]:e[t]=!!n||{}}return o.isObject(t)&&o.isObject(e)?function e(t,n){if(!o.isObject(t))return t;var r,i,s=o.extend({},t);for(i in t)r=n[i],o.isObject(r)?s[i]=e(s[i],r):r||delete s[i];return s}(e,t=function(e){var t,r={};for(t in e)e[t]&&o.forEachKeyInKeypath(r,t,n);return r}(t)):{}},exposeModule:function(e,t,n,r,i){n?(r&&r.exports&&(n=r.exports=e),n.validate=e):(t.validate=e,e.isFunction(i)&&i.amd&&i([],(function(){return e})))},warn:function(e){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+e)},error:function(e){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+e)}}),i.validators={presence:function(e,t){if(!1!==(t=o.extend({},this.options,t)).allowEmpty?!o.isDefined(e):o.isEmpty(e))return t.message||this.message||"can't be blank"},length:function(e,t,n){if(o.isDefined(e)){var r,i=(t=o.extend({},this.options,t)).is,s=t.maximum,a=t.minimum,u=[],l=(e=(t.tokenizer||function(e){return e})(e)).length;return o.isNumber(l)?(o.isNumber(i)&&l!==i&&(r=t.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",u.push(o.format(r,{count:i}))),o.isNumber(a)&&l<a&&(r=t.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",u.push(o.format(r,{count:a}))),o.isNumber(s)&&l>s&&(r=t.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",u.push(o.format(r,{count:s}))),u.length>0?t.message||u:void 0):t.message||this.notValid||"has an incorrect length"}},numericality:function(e,t,n,r,i){if(o.isDefined(e)){var s,a,u=[],l={greaterThan:function(e,t){return e>t},greaterThanOrEqualTo:function(e,t){return e>=t},equalTo:function(e,t){return e===t},lessThan:function(e,t){return e<t},lessThanOrEqualTo:function(e,t){return e<=t},divisibleBy:function(e,t){return e%t==0}},c=(t=o.extend({},this.options,t)).prettify||i&&i.prettify||o.prettify;if(o.isString(e)&&t.strict){var f="^-?(0|[1-9]\\d*)";if(t.onlyInteger||(f+="(\\.\\d+)?"),f+="$",!new RegExp(f).test(e))return t.message||t.notValid||this.notValid||this.message||"must be a valid number"}if(!0!==t.noStrings&&o.isString(e)&&!o.isEmpty(e)&&(e=+e),!o.isNumber(e))return t.message||t.notValid||this.notValid||this.message||"is not a number";if(t.onlyInteger&&!o.isInteger(e))return t.message||t.notInteger||this.notInteger||this.message||"must be an integer";for(s in l)if(a=t[s],o.isNumber(a)&&!l[s](e,a)){var p="not"+o.capitalize(s),d=t[p]||this[p]||this.message||"must be %{type} %{count}";u.push(o.format(d,{count:a,type:c(s)}))}return t.odd&&e%2!=1&&u.push(t.notOdd||this.notOdd||this.message||"must be odd"),t.even&&e%2!=0&&u.push(t.notEven||this.notEven||this.message||"must be even"),u.length?t.message||u:void 0}},datetime:o.extend((function(e,t){if(!o.isFunction(this.parse)||!o.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(o.isDefined(e)){var n,r=[],i=(t=o.extend({},this.options,t)).earliest?this.parse(t.earliest,t):NaN,s=t.latest?this.parse(t.latest,t):NaN;return e=this.parse(e,t),isNaN(e)||t.dateOnly&&e%864e5!=0?(n=t.notValid||t.message||this.notValid||"must be a valid date",o.format(n,{value:arguments[0]})):(!isNaN(i)&&e<i&&(n=t.tooEarly||t.message||this.tooEarly||"must be no earlier than %{date}",n=o.format(n,{value:this.format(e,t),date:this.format(i,t)}),r.push(n)),!isNaN(s)&&e>s&&(n=t.tooLate||t.message||this.tooLate||"must be no later than %{date}",n=o.format(n,{date:this.format(s,t),value:this.format(e,t)}),r.push(n)),r.length?o.unique(r):void 0)}}),{parse:null,format:null}),date:function(e,t){return t=o.extend({},t,{dateOnly:!0}),o.validators.datetime.call(o.validators.datetime,e,t)},format:function(e,t){(o.isString(t)||t instanceof RegExp)&&(t={pattern:t});var n,r=(t=o.extend({},this.options,t)).message||this.message||"is invalid",i=t.pattern;if(o.isDefined(e))return o.isString(e)?(o.isString(i)&&(i=new RegExp(t.pattern,t.flags)),(n=i.exec(e))&&n[0].length==e.length?void 0:r):r},inclusion:function(e,t){if(o.isDefined(e)&&(o.isArray(t)&&(t={within:t}),t=o.extend({},this.options,t),!o.contains(t.within,e))){var n=t.message||this.message||"^%{value} is not included in the list";return o.format(n,{value:e})}},exclusion:function(e,t){if(o.isDefined(e)&&(o.isArray(t)&&(t={within:t}),t=o.extend({},this.options,t),o.contains(t.within,e))){var n=t.message||this.message||"^%{value} is restricted";return o.isString(t.within[e])&&(e=t.within[e]),o.format(n,{value:e})}},email:o.extend((function(e,t){var n=(t=o.extend({},this.options,t)).message||this.message||"is not a valid email";if(o.isDefined(e))return o.isString(e)&&this.PATTERN.exec(e)?void 0:n}),{PATTERN:/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i}),equality:function(e,t,n,r,i){if(o.isDefined(e)){o.isString(t)&&(t={attribute:t});var s=(t=o.extend({},this.options,t)).message||this.message||"is not equal to %{attribute}";if(o.isEmpty(t.attribute)||!o.isString(t.attribute))throw new Error("The attribute must be a non empty string");var a=o.getDeepObjectValue(r,t.attribute),u=t.comparator||function(e,t){return e===t},l=t.prettify||i&&i.prettify||o.prettify;return u(e,a,t,n,r)?void 0:o.format(s,{attribute:l(t.attribute)})}},url:function(e,t){if(o.isDefined(e)){var n=(t=o.extend({},this.options,t)).message||this.message||"is not a valid url",r=t.schemes||this.schemes||["http","https"],i=t.allowLocal||this.allowLocal||!1,s=t.allowDataUrl||this.allowDataUrl||!1;if(!o.isString(e))return n;var a="^(?:(?:"+r.join("|")+")://)(?:\\S+(?::\\S*)?@)?(?:",u="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";if(i?u+="?":a+="(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})",a+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*"+u+")(?::\\d{2,5})?(?:[/?#]\\S*)?$",s){a="(?:"+a+")|(?:^data:(?:\\w+\\/[-+.\\w]+(?:;[\\w=]+)*)?(?:;base64)?,[A-Za-z0-9-_.!~\\*'();\\/?:@&=+$,%]*$)"}return new RegExp(a,"i").exec(e)?void 0:n}},type:o.extend((function(e,t,n,r,i){if(o.isString(t)&&(t={type:t}),o.isDefined(e)){var s,a=o.extend({},this.options,t),u=a.type;if(!o.isDefined(u))throw new Error("No type was specified");if(s=o.isFunction(u)?u:this.types[u],!o.isFunction(s))throw new Error("validate.validators.type.types."+u+" must be a function.");if(!s(e,a,n,r,i)){var l=t.message||this.messages[u]||this.message||a.message||(o.isFunction(u)?"must be of the correct type":"must be of type %{type}");return o.isFunction(l)&&(l=l(e,t,n,r,i)),o.format(l,{attribute:o.prettify(n),type:u})}}}),{types:{object:function(e){return o.isObject(e)&&!o.isArray(e)},array:o.isArray,integer:o.isInteger,number:o.isNumber,string:o.isString,date:o.isDate,boolean:o.isBoolean},messages:{}})},i.formatters={detailed:function(e){return e},flat:o.flattenErrorsToArray,grouped:function(e){var t;for(t in e=o.groupErrorsByAttribute(e))e[t]=o.flattenErrorsToArray(e[t]);return e},constraint:function(e){var t;for(t in e=o.groupErrorsByAttribute(e))e[t]=e[t].map((function(e){return e.validator})).sort();return e}},i.exposeModule(i,this,e,t,n.amdD)}.call(this,t,e,n.amdD)}},t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";function e(e){return e.replace(/-(\w)/g,((e,t)=>t.toUpperCase()))}function t(e,n){e.firstChild&&(n.appendChild(e.firstChild),t(e,n))}function r(e){Array.from(e).forEach(i)}const i=e=>e&&e.parentNode&&e.parentNode.removeChild(e),o=(e,t)=>t&&t.parentNode&&t.parentNode.insertBefore(e,t),s=new Map,a=Symbol("riot-component"),u=new Set,l="is",c="mount",f="update",p="unmount",d="shouldUpdate",h="onBeforeMount",m="onMounted",g="onBeforeUpdate",b="onUpdated",v="onBeforeUnmount",y="onUnmounted",E="props",x="state",O="slots",N="root",T=Symbol.for("pure"),w=Symbol("parent"),A=Symbol("attributes"),j=Symbol("template");var _=Object.freeze({__proto__:null,COMPONENTS_IMPLEMENTATION_MAP:s,DOM_COMPONENT_INSTANCE_PROPERTY:a,PLUGINS_SET:u,IS_DIRECTIVE:l,VALUE_ATTRIBUTE:"value",MOUNT_METHOD_KEY:c,UPDATE_METHOD_KEY:f,UNMOUNT_METHOD_KEY:p,SHOULD_UPDATE_KEY:d,ON_BEFORE_MOUNT_KEY:h,ON_MOUNTED_KEY:m,ON_BEFORE_UPDATE_KEY:g,ON_UPDATED_KEY:b,ON_BEFORE_UNMOUNT_KEY:v,ON_UNMOUNTED_KEY:y,PROPS_KEY:E,STATE_KEY:x,SLOTS_KEY:O,ROOT_KEY:N,IS_PURE_SYMBOL:T,PARENT_KEY_SYMBOL:w,ATTRIBUTES_KEY_SYMBOL:A,TEMPLATE_KEY_SYMBOL:j});var S={EACH:0,IF:1,SIMPLE:2,TAG:3,SLOT:4};var M={ATTRIBUTE:0,EVENT:1,TEXT:2,VALUE:3};function D(e,t){return typeof e===t}function P(e){const t=e.ownerSVGElement;return!!t||null===t}function I(e){return!C(e.content)}function U(e){return D(e,"function")}function R(e){return!C(e)&&D(e,"object")}function C(e){return null==e}const k=Symbol("unmount"),L={nodes:[],mount(e,t){return this.update(e,t)},update(e,t){const{placeholder:n,nodes:r,childrenMap:s}=this,a=e===k?null:this.evaluate(e),u=a?Array.from(a):[],{newChildrenMap:l,batches:c,futureNodes:f}=(n.parentNode,function(e,t,n,r){const{condition:i,template:o,childrenMap:s,itemName:a,getKey:u,indexName:l,root:c,isTemplateTag:f}=r,p=new Map,d=[],h=[];return e.forEach(((e,r)=>{const m=function(e,t){let{itemName:n,indexName:r,index:i,item:o}=t;e[n]=o,r&&(e[r]=i);return e}(Object.create(t),{itemName:a,indexName:l,index:r,item:e}),g=u?u(m):r,b=s.get(g);if(function(e,t){return!!e&&!1===Boolean(e(t))}(i,m))return;const v=b?b.template:o.clone(),y=b?v.el:c.cloneNode(),E=!b,x=f&&E?function(e){const t=e.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:t,children:Array.from(t.childNodes)}}(v):{};if(E?d.push((()=>v.mount(y,m,n,x))):d.push((()=>v.update(m,n))),f){const e=x.children||v.children;h.push(...e)}else h.push(y);s.delete(g),p.set(g,{template:v,context:m,index:r})})),{newChildrenMap:p,batches:d,futureNodes:h}}(u,e,t,this));return((e,t,n,r,s)=>{const a=n.length;let u=t.length,l=a,c=0,f=0,p=null;for(;c<u||f<l;)if(u===c){const e=l<a?f?r(n[f-1],-0).nextSibling:r(n[l-f],0):s;for(;f<l;)o(r(n[f++],1),e)}else if(l===f)for(;c<u;)p&&p.has(t[c])||i(r(t[c],-1)),c++;else if(t[c]===n[f])c++,f++;else if(t[u-1]===n[l-1])u--,l--;else if(t[c]===n[l-1]&&n[f]===t[u-1]){const e=r(t[--u],-1).nextSibling;o(r(n[f++],1),r(t[c++],-1).nextSibling),o(r(n[--l],1),e),t[u]=n[l]}else{if(!p){p=new Map;let e=f;for(;e<l;)p.set(n[e],e++)}if(p.has(t[c])){const e=p.get(t[c]);if(f<e&&e<l){let i=c,s=1;for(;++i<u&&i<l&&p.get(t[i])===e+s;)s++;if(s>e-f){const i=r(t[c],0);for(;f<e;)o(r(n[f++],1),i)}else d=r(n[f++],1),(h=r(t[c++],-1))&&h.parentNode&&h.parentNode.replaceChild(d,h)}else c++}else i(r(t[c++],-1))}var d,h})(0,r,f,function(e,t){return(n,r)=>{if(r<0){const n=e.pop();if(n){const{template:e,context:r}=n;e.unmount(r,t,null)}}return n}}(Array.from(s.values()),t),n),c.forEach((e=>e())),this.childrenMap=l,this.nodes=f,this},unmount(e,t){return this.update(k,t),this}};const z={mount(e,t){return this.update(e,t)},update(e,t){const n=!!this.evaluate(e),r=!this.value&&n,i=this.value&&!n,s=()=>{const n=this.node.cloneNode();o(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,e,t)};switch(!0){case r:s();break;case i:this.unmount(e);break;default:n&&this.template.update(e,t)}return this.value=n,this},unmount(e,t){return this.template.unmount(e,t,!0),this}};function V(e){throw new Error(e)}function B(t){return t.reduce(((t,n)=>{const{value:r,type:i}=n;switch(!0){case!n.name&&0===i:return Object.assign({},t,r);case 3===i:t.value=n.value;break;default:t[e(n.name)]=n.value}return t}),{})}const F="removeAttribute",K="setAttribute",Y="undefined"==typeof Element?{}:Element.prototype,$=function(e){const t=new Map,n=n=>(t.has(n)||t.set(n,e.call(this,n)))&&t.get(n);return n.cache=t,n}((e=>Y.hasOwnProperty(e)));function q(e,t,n,r){let{name:i}=t;if(!i)return r&&function(e,t,n){const r=t?Object.keys(t):[];Object.keys(n).filter((e=>!r.includes(e))).forEach((t=>e.removeAttribute(t)))}(e,n,r),void(n&&function(e,t){Object.entries(t).forEach((t=>{let[n,r]=t;return q(e,{name:n},r)}))}(e,n));!$(i)&&(function(e){return D(e,"boolean")}(n)||R(n)||U(n))&&(e[i]=n),e[function(e){return C(e)||!1===e||""===e||R(e)||U(e)?F:K}(n)](i,function(e,t){return!0===t?e:t}(i,n))}const G=/^on/,H={handleEvent(e){this[e.type](e)}},X=new WeakMap;function J(e){return C(e)?"":e}const Z=(e,t)=>{const n=e.childNodes[t];if(n.nodeType===Node.COMMENT_NODE){const t=document.createTextNode("");return e.replaceChild(t,n),t}return n};var W={0:q,1:function(e,t,n){let{name:r}=t;const i=r.replace(G,""),o=X.get(e)||(e=>{const t=Object.create(H);return X.set(e,t),t})(e),[s,a]=(e=>Array.isArray(e)?e:[e,!1])(n),u=o[i],l=s&&!u;u&&!s&&e.removeEventListener(i,o),l&&e.addEventListener(i,o,a),o[i]=s},2:function(e,t,n){e.data=J(n)},3:function(e,t,n){e.value=J(n)}};const Q={mount(e){return this.value=this.evaluate(e),ee(this,this.value),this},update(e){const t=this.evaluate(e);return this.value!==t&&(ee(this,t),this.value=t),this},unmount(){return 1===this.type&&ee(this,null),this}};function ee(e,t){return W[e.type](e.node,e,t,e.value)}function te(e,t){return Object.assign({},Q,t,{node:2===t.type?Z(e,t.childNodeIndex):e})}const ne=(e,t)=>e[w]||t,re={attributes:[],getTemplateScope(e,t){return function(e,t,n){if(!e||!e.length)return n;const r=e.map((e=>Object.assign({},e,{value:e.evaluate(t)})));return Object.assign(Object.create(n||null),B(r))}(this.attributes,e,t)},mount(e,t){const n=!!e.slots&&e.slots.find((e=>{let{id:t}=e;return t===this.name})),{parentNode:r}=this.node,o=ne(e,t);return this.template=n&&de(n.html,n.bindings).createDOM(r),this.template&&(this.template.mount(this.node,this.getTemplateScope(e,o),o),this.template.children=Array.from(this.node.childNodes),ie(this.node)),i(this.node),this},update(e,t){if(this.template){const n=ne(e,t);this.template.update(this.getTemplateScope(e,n),n)}return this},unmount(e,t,n){return this.template&&this.template.unmount(this.getTemplateScope(e,t),null,n),this}};function ie(e){const t=e&&e.firstChild;t&&(o(t,e),ie(e))}function oe(e){return e.reduce(((e,t)=>{let{bindings:n}=t;return e.concat(n)}),[])}const se={mount(e){return this.update(e)},update(e,t){const n=this.evaluate(e);return n===this.name?this.tag.update(e):(this.unmount(e,t,!0),this.name=n,this.tag=function(e,t,n){return void 0===t&&(t=[]),void 0===n&&(n=[]),e?e({slots:t,attributes:n}):de(function(e){return e.reduce(((e,t)=>e+t.html),"")}(t),[...oe(t),{expressions:n.map((e=>Object.assign({type:0},e)))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,e)),this},unmount(e,t,n){return this.tag&&this.tag.unmount(n),this}};var ae={1:function(e,t){let{evaluate:n,template:r}=t;const s=document.createTextNode("");return o(s,e),i(e),Object.assign({},z,{node:e,evaluate:n,placeholder:s,template:r.createDOM(e)})},2:function(e,t){let{expressions:n}=t;return Object.assign({},(r=n.map((t=>te(e,t))),["mount","update","unmount"].reduce(((e,t)=>Object.assign({},e,{[t]:e=>r.map((n=>n[t](e)))&&i})),{})));var r,i},0:function(e,t){let{evaluate:n,condition:r,itemName:s,indexName:a,getKey:u,template:l}=t;const c=document.createTextNode(""),f=e.cloneNode();return o(c,e),i(e),Object.assign({},L,{childrenMap:new Map,node:e,root:f,condition:r,evaluate:n,isTemplateTag:I(f),template:l.createDOM(e),getKey:u,indexName:a,itemName:s,placeholder:c})},3:function(e,t){let{evaluate:n,getComponent:r,slots:i,attributes:o}=t;return Object.assign({},se,{node:e,evaluate:n,slots:i,attributes:o,getComponent:r})},4:function(e,t){let{name:n,attributes:r}=t;return Object.assign({},re,{attributes:r,node:e,name:n})}};function ue(e,t){return e.map((e=>2===e.type?Object.assign({},e,{childNodeIndex:e.childNodeIndex+t}):e))}function le(e,t,n){const{selector:r,type:i,redundantAttribute:o,expressions:s}=t,a=r?e.querySelector(r):e;o&&a.removeAttribute(o);const u=s||[];return(ae[i]||ae[2])(a,Object.assign({},t,{expressions:n&&!r?ue(u,n):u}))}function ce(e,t){return P(e)?function(e,t){return t.ownerDocument.importNode((new window.DOMParser).parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${e}</svg>`,"application/xml").documentElement,!0)}(t,e):function(e,t){const n=I(t)?t:document.createElement("template");return n.innerHTML=e,n.content}(t,e)}function fe(e,n){switch(!0){case P(e):t(n,e);break;case I(e):e.parentNode.replaceChild(n,e);break;default:e.appendChild(n)}}const pe=Object.freeze({createDOM(e){return this.dom=this.dom||function(e,t){return t&&("string"==typeof t?ce(e,t):t)}(e,this.html),this},mount(e,t,n,r){if(void 0===r&&(r={}),!e)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(t);const{fragment:i,children:o,avoidDOMInjection:s}=r,{parentNode:a}=o?o[0]:e,u=I(e),l=u?Math.max(Array.from(a.childNodes).indexOf(e),0):null;return this.isTemplateTag=u,this.createDOM(e),this.dom&&(this.fragment=i||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?a:e,this.children=this.isTemplateTag?o||Array.from(this.fragment.childNodes):null,!s&&this.fragment&&fe(e,this.fragment),this.bindings=this.bindingsData.map((e=>le(this.el,e,l))),this.bindings.forEach((e=>e.mount(t,n))),this},update(e,t){return this.bindings.forEach((n=>n.update(e,t))),this},unmount(e,t,n){if(this.el){switch(this.bindings.forEach((r=>r.unmount(e,t,n))),!0){case this.el[T]:break;case this.children&&null!==n:r(this.children);break;case!0===n:i(this.el);break;case null!==n:r(this.el.childNodes)}this.el=null}return this},clone(){return Object.assign({},this,{el:null})}});function de(e,t){return void 0===t&&(t=[]),Object.assign({},pe,{html:e,bindingsData:t})}function he(){return this}function me(e){return U(e)?e.prototype&&e.prototype.constructor?new e:e():e}function ge(e,t,n,r){return void 0===r&&(r={}),Object.defineProperty(e,t,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),e}function be(e,t,n){return Object.entries(t).forEach((t=>{let[r,i]=t;ge(e,r,i,n)})),e}function ve(e,t){return Object.entries(t).forEach((t=>{let[n,r]=t;e[n]||(e[n]=r)})),e}function ye(e){return Array.isArray(e)?e:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&"number"==typeof e.length?Array.from(e):[e]}function Ee(e,t){return ye("string"==typeof e?(t||document).querySelectorAll(e):e)}const xe=e=>1===e.length?e[0]:e;function Oe(e,t,n){const r="object"==typeof t?t:{[t]:n},i=Object.keys(r);return ye(e).forEach((e=>{i.forEach((t=>e.setAttribute(t,r[t])))})),e}function Ne(e,t){return function(e,t,n){const r="string"==typeof t?[t]:t;return xe(ye(e).map((e=>xe(r.map((t=>e[n](t)))))))}(e,t,"getAttribute")}const Te=new Map,we=()=>Ae||(Oe(Ae=Ee("style[riot]")[0]||document.createElement("style"),"type","text/css"),Ae.parentNode||document.head.appendChild(Ae),Ae);var Ae,je={CSS_BY_NAME:Te,add(e,t){return Te.has(e)||(Te.set(e,t),this.inject()),this},inject(){return we().innerHTML=[...Te.values()].join("\n"),this},remove(e){return Te.has(e)&&(Te.delete(e),this.inject()),this}};function _e(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return(r=[...n,...r]).length<e.length?_e(e,...r):e(...r)}}function Se(e){return Ne(e,l)||e.tagName.toLowerCase()}const Me=Object.freeze({$(e){return Ee(e,this.root)[0]},$$(e){return Ee(e,this.root)}}),De=Object.freeze({[c]:he,[f]:he,[p]:he}),Pe=Object.freeze({[d]:he,[h]:he,[m]:he,[g]:he,[b]:he,[v]:he,[y]:he}),Ie=Object.assign({},De,{clone:he,createDOM:he});function Ue(t,n){return void 0===n&&(n={}),Object.assign({},function(t){return Array.from(t.attributes).reduce(((t,n)=>(t[e(n.name)]=n.value,t)),{})}(t),me(n))}const Re=(e,t)=>e[a]=t;function Ce(e){return[c,f,p].reduce(((t,n)=>(t[n]=e(n),t)),{})}function ke(e){let{css:t,template:n,exports:r,name:i}=e;const o=n?function(e,t){return e(de,M,S,(e=>t[e]||s.get(e)))}(n,r?function(e){void 0===e&&(e={});return Object.entries(me(e)).reduce(((e,t)=>{let[n,r]=t;
/* Riot v5.1.2, @license MIT */
var i;return e[(i=n,i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())]=ke(r),e}),{})}(r.components):{}):Ie;return e=>{let{slots:s,attributes:a,props:u}=e;if(r&&r[T])return function(e,t){let{slots:n,attributes:r,props:i,css:o,template:s}=t;s&&V("Pure components can not have html"),o&&V("Pure components do not have css");const a=ve(e({slots:n,attributes:r,props:i}),De);return Ce((e=>function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(e===c){const[e]=n;e[T]=!0,Re(e,a)}return a[e](...n),a}))}(r,{slots:s,attributes:a,props:u,css:t,template:n});const l=me(r)||{},f=Le({css:t,template:o,componentAPI:l,name:i})({slots:s,attributes:a,props:u});return{mount:(e,t,n)=>f.mount(e,n,t),update:(e,t)=>f.update(t,e),unmount:e=>f.unmount(e)}}}function Le(e){let{css:t,template:n,componentAPI:r,name:i}=e;return t&&i&&je.add(i,t),_e(Ve)(be(ve(r,Object.assign({},Pe,{[x]:{}})),Object.assign({[O]:null,[N]:null},Me,{name:i,css:t,template:n})))}function ze(e,t){return Object.assign({},e,me(t))}function Ve(e,t){let{slots:n,attributes:r,props:i}=t;return o=function(e){return[...u].reduce(((e,t)=>t(e)||e),e)}(be(Object.create(e),{mount(t,o,s){return void 0===o&&(o={}),this[A]=function(e,t){void 0===t&&(t=[]);const n=t.map((t=>te(e,t))),r={};return Object.assign(r,Object.assign({expressions:n},Ce((e=>t=>(n.forEach((n=>n[e](t))),r)))))}(t,r).mount(s),ge(this,E,Object.freeze(Object.assign({},Ue(t,i),B(this[A].expressions)))),this.state=ze(this.state,o),this[j]=this.template.createDOM(t).clone(),Re(t,this),e.name&&function(e,t){Se(e)!==t&&Oe(e,l,t)}(t,e.name),ge(this,N,t),ge(this,O,n),this.onBeforeMount(this.props,this.state),this[w]=s,this[j].mount(t,this,s),this.onMounted(this.props,this.state),this},update(e,t){void 0===e&&(e={}),t&&(this[w]=t,this[A].update(t));const n=B(this[A].expressions);if(!1!==this.shouldUpdate(n,this.props))return ge(this,E,Object.freeze(Object.assign({},this.props,n))),this.state=ze(this.state,e),this.onBeforeUpdate(this.props,this.state),this[j].update(this,this[w]),this.onUpdated(this.props,this.state),this},unmount(e){return this.onBeforeUnmount(this.props,this.state),this[A].unmount(),this[j].unmount(this,this[w],null===e?null:!e),this.onUnmounted(this.props,this.state),this}})),Object.keys(e).filter((t=>U(e[t]))).forEach((e=>{o[e]=o[e].bind(o)})),o;var o}const{DOM_COMPONENT_INSTANCE_PROPERTY:Be,COMPONENTS_IMPLEMENTATION_MAP:Fe,PLUGINS_SET:Ke}=_;function Ye(e,t){let{css:n,template:r,exports:i}=t;return Fe.has(e)&&V(`The component "${e}" was already registered`),Fe.set(e,ke({name:e,css:n,template:r,exports:i})),Fe}function $e(e,t,n){return Ee(e).map((e=>function(e,t,n){const r=n||Se(e);return s.has(r)||V(`The component named "${r}" was never registered`),s.get(r)({props:t}).mount(e)}(e,t,n)))}var qe=n(765),Ge=n.n(qe),He=n(422),Xe=n.n(He);function Je(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}const Ze=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._rules=t,this._component=n,this._errors={}}var t,n,r;return t=e,(n=[{key:"handle",value:function(e,t){e.preventDefault();var n,r,i=null;t?e.target.value&&(i=e.target.value):i=Xe()(e.target,{hash:!0}),t?(n=this._rules[t],(r=Ge().single(i,n,{flat:!0}))?this._errors[t]=r:delete this._errors[t]):this._errors=Ge()(i,this._rules),this._component.update()}},{key:"errors",value:function(e){return e?this._errors[e]:this._errors}}])&&Je(t.prototype,n),r&&Je(t,r),e}(),We={css:null,exports:{onBeforeMount(){this.state.validator=new Ze({name:{presence:!0,email:!0},password:{presence:!0}},this)}},template:function(e,t,n,r){return e('<form expr0="expr0" novalidate><div class="field"><label>\n email\n <input expr1="expr1" type="email" name="email"/></label><field-error expr2="expr2"></field-error></div><div class="field"><label>\n password\n <input expr3="expr3" type="password" name="email"/></label><field-error expr4="expr4"></field-error></div><button type="submit">Send</button></form>',[{redundantAttribute:"expr0",selector:"[expr0]",expressions:[{type:t.EVENT,name:"onsubmit",evaluate:function(e){return t=>{e.state.validator.handle(t)}}}]},{redundantAttribute:"expr1",selector:"[expr1]",expressions:[{type:t.EVENT,name:"onkeyup",evaluate:function(e){return t=>{e.state.validator.handle(t,"email")}}}]},{type:n.TAG,getComponent:r,evaluate:function(e){return"field-error"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"errors",evaluate:function(e){return e.state.validator.errors("email")}}],redundantAttribute:"expr2",selector:"[expr2]"},{redundantAttribute:"expr3",selector:"[expr3]",expressions:[{type:t.EVENT,name:"onkeyup",evaluate:function(e){return t=>{e.state.validator.handle(t,"password")}}}]},{type:n.TAG,getComponent:r,evaluate:function(e){return"field-error"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"errors",evaluate:function(e){return e.state.validator.errors("password")}}],redundantAttribute:"expr4",selector:"[expr4]"}])},name:"demo"};Ye("field-error",{css:null,exports:{state:{errors:[]},onBeforeUpdate(e,t){e.errors&&e.errors.length>0?t.errors=e.errors:t.errors=[]}},template:function(e,t,n,r){return e('<div expr5="expr5" class="field__error"></div>',[{type:n.IF,evaluate:function(e){return e.state.errors.length>0},redundantAttribute:"expr5",selector:"[expr5]",template:e('<ul><li expr6="expr6"></li></ul>',[{type:n.EACH,getKey:null,condition:null,template:e(" ",[{expressions:[{type:t.TEXT,childNodeIndex:0,evaluate:function(e){return e.error}}]}]),redundantAttribute:"expr6",selector:"[expr6]",itemName:"error",indexName:null,evaluate:function(e){return e.state.errors}}])}])},name:"field-error"}),$e("field-error"),Ye("demo",We),$e("demo")})()})();