"use strict";var m=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var c=Object.getPrototypeOf;var h=Object.prototype.hasOwnProperty;var l=(e,i)=>r(e,"name",{value:i,configurable:true});var M=(e,i)=>{for(var a in i)r(e,a,{get:i[a],enumerable:true})};var o=(e,i,a,n)=>{if(i&&typeof i==="object"||typeof i==="function"){for(let t of v(i))if(!h.call(e,t)&&t!==a)r(e,t,{get:()=>i[t],enumerable:!(n=g(i,t))||n.enumerable})}return e};var q=(e,i,a)=>(a=e!=null?m(c(e)):{},o(i||!e||!e.__esModule?r(a,"default",{value:e,enumerable:true}):a,e));var w=e=>o(r({},"__esModule",{value:true}),e);var y={};M(y,{email:()=>b,minLength:()=>L,oneRequired:()=>V,required:()=>p,url:()=>x});module.exports=w(y);var u=require("react-intl");var f=q(require("validator/lib/isEmail"));var d=require("./url-helpers");const s=(0,u.defineMessages)({required:{id:"validation.required",defaultMessage:"{field} is required"},email:{id:"validation.email",defaultMessage:"{field} is not valid"},url:{id:"validation.url",defaultMessage:"{field} is not a valid URL"},minLength:{id:"validation.minLength",defaultMessage:"{field} should be at least {length} characters long"},oneRequired:{id:"validation.oneRequired",defaultMessage:"At least one is required"}});const p=l(({field:e})=>{const i=e.value.trim()!=="";return[i,window.ferdium.intl.formatMessage(s.required,{field:e.label})]},"required");const b=l(({field:e})=>{const i=e.value.trim();const a=(0,f.default)(i);return[a,window.ferdium.intl.formatMessage(s.email,{field:e.label})]},"email");const x=l(({field:e})=>{const i=e.value.trim();let a=true;if(i!==""){if(i.startsWith("http")){a=(0,d.isValidExternalURL)(i)}else if(i.startsWith("file")){a=(0,d.isValidFileUrl)(i)}else{a=false}}return[a,window.ferdium.intl.formatMessage(s.url,{field:e.label})]},"url");const L=l(e=>{return({field:i})=>{let a=true;if(i.touched){a=i.value.length>=e}return[a,window.ferdium.intl.formatMessage(s.minLength,{field:i.label,length:e})]}},"minLength");const V=l(e=>{return({field:i,form:a})=>{const n=e.filter(t=>a.$(t).value==="");return[e.length!==n.length,window.ferdium.intl.formatMessage(s.required,{field:i.label})]}},"oneRequired");
