From 2028ffb0d70f85a362a8190e88569f7205883840 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Wed, 11 Dec 2024 01:16:05 +0200 Subject: [PATCH] updated AUTH Recaptcha Init fix 2 --- scripts/__dropins__/storefront-auth/chunks/Button2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/__dropins__/storefront-auth/chunks/Button2.js b/scripts/__dropins__/storefront-auth/chunks/Button2.js index cb3d903e9..4228eb868 100644 --- a/scripts/__dropins__/storefront-auth/chunks/Button2.js +++ b/scripts/__dropins__/storefront-auth/chunks/Button2.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as h,Fragment as P,jsxs as Z}from"@dropins/tools/preact-jsx-runtime.js";import{useState as O,useCallback as L,useRef as U,useEffect as W}from"@dropins/tools/preact-hooks.js";import*as N from"@dropins/tools/preact-compat.js";import{memo as C,useCallback as _}from"@dropins/tools/preact-compat.js";import{initReCaptcha as G}from"@dropins/tools/recaptcha.js";import{useText as j}from"@dropins/tools/i18n.js";import{classes as M}from"@dropins/tools/lib.js";import{Field as w,Picker as q,Input as X,InputDate as z,Checkbox as B,TextArea as g,Button as J}from"@dropins/tools/components.js";/* empty css */const Ie=e=>{if(!e)return null;const t=new FormData(e);if(t&&typeof t.entries=="function"){const o=t.entries();if(o&&typeof o[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(o)))||{}}return{}},De=e=>typeof e=="function",Y=e=>N.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},N.createElement("g",{clipPath:"url(#clip0_841_1324)"},N.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),N.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),N.createElement("defs",null,N.createElement("clipPath",{id:"clip0_841_1324"},N.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),K=e=>N.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},N.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),N.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Q=e=>N.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},N.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),N.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),ee={success:h(K,{}),warning:h(Y,{}),error:h(Q,{})},be=()=>{const[e,t]=O({}),o=L(l=>{if(!l||!l.type){t({});return}const c=ee[l.type];t({...l,icon:c})},[]);return{inLineAlertProps:e,handleSetInLineAlertProps:o}};var v=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(v||{});const re=C(({loading:e,values:t,fields:o=[],errors:l,className:c="",onChange:u,onBlur:p,onFocus:A})=>{const s=`${c}__field`,f=_((r,a,n)=>{var T;const E=(T=r.options.find($=>$.isDefault))==null?void 0:T.value;return h(w,{error:n,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e||r.disabled,children:h(q,{name:r.customUpperCode,floatingLabel:`${r.label} ${r.required?"*":""}`,placeholder:r.label,"aria-label":r.label,options:r.options,onBlur:p,handleSelect:u,defaultValue:E??a??r.defaultValue,value:E??a??r.defaultValue})},r.id)},[c,e,s,p,u]),x=_((r,a,n)=>h(w,{error:n,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e,children:h(X,{type:"text",name:r.customUpperCode,value:a??r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:p,onChange:u,onFocus:A})},r.id),[c,e,s,p,u,A]),I=_((r,a,n)=>h(w,{error:n,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e||r.disabled,children:h(z,{type:"text",name:r.customUpperCode,value:a||r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:p,onChange:u,disabled:e||r.disabled})},r.id),[c,e,s,p,u]),b=_((r,a,n)=>h(w,{error:n,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e,children:h(B,{name:r.customUpperCode,checked:a||r.defaultValue,placeholder:r.label,label:`${r.label} ${r.required?"*":""}`,onBlur:p,onChange:u})},r.id),[c,e,s,p,u]),D=_((r,a,n)=>h(w,{error:n,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e,children:h(g,{type:"text",name:r.customUpperCode,value:a??r.defaultValue,label:`${r.label} ${r.required?"*":""}`,onBlur:p,onChange:u})},r.id),[c,e,s,p,u]);return o.length?h(P,{children:o.map(r=>{const a=l==null?void 0:l[r.customUpperCode],n=t==null?void 0:t[r.customUpperCode];switch(r.fieldType){case v.TEXT:return r.options.length?f(r,n,a):x(r,n,a);case v.MULTILINE:return x(r,n,a);case v.SELECT:return f(r,n,a);case v.DATE:return I(r,n,a);case v.BOOLEAN:return b(r,n,a);case v.TEXTAREA:return D(r,n,a);default:return null}})}):null}),te=e=>e.reduce((t,{customUpperCode:o,required:l,defaultValue:c})=>(l&&o&&(t.initialData[o]=c||"",t.errorList[o]=""),t),{initialData:{},errorList:{}}),ae=e=>e.reduce((t,o)=>({...t,[o.name]:o.value}),{}),ne=e=>/^\d+$/.test(e),oe=e=>/^[a-zA-Z0-9\s]+$/.test(e),le=e=>/^[a-zA-Z0-9]+$/.test(e),se=e=>/^[a-zA-Z]+$/.test(e),ce=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),de=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),ue=(e,t,o)=>{const l=new Date(e).getTime()/1e3;return!(isNaN(l)||l<0||typeof t<"u"&&lo)},S=e=>{if(!e||e.trim()==="")return"";const t=parseInt(e,10);if(!isNaN(t)){const c=new Date(t*1e3);return isNaN(c.getTime())?"":c.toISOString().split("T")[0]}const o=new Date(e);if(isNaN(o.getTime()))return"";const l=parseInt(e.split("-")[1],10);return l>12||l<1?"":o.toISOString().split("T")[0]},ie=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),pe=(e,t,o)=>{const l=e.length;return l>=t&&l<=o},F=(e,t,o,l)=>{var y,H;const{requiredFieldError:c,lengthTextError:u,numericError:p,alphaNumWithSpacesError:A,alphaNumericError:s,alphaError:f,emailError:x,dateError:I,urlError:b,dateLengthError:D,dateMaxError:r,dateMinError:a}=o,n=t==null?void 0:t.customUpperCode,E={[n]:""};if(l[n]&&delete l[n],t!=null&&t.required&&!e)return{[n]:c};if(!(t!=null&&t.required)&&!e||!((y=t==null?void 0:t.validateRules)!=null&&y.length))return E;const T=ae(t==null?void 0:t.validateRules),$=T.MIN_TEXT_LENGTH??1,m=T.MAX_TEXT_LENGTH??255,d=T.DATE_RANGE_MIN,i=T.DATE_RANGE_MAX;if(!pe(e,+$,+m)&&!(d||i))return{[n]:u.replace("{min}",$).replace("{max}",m)};if(!ue(e,+d,+i)&&(d||i)){if(d&&d)return{[n]:D.replace("{min}",S(d)).replace("{max}",S(i))};if(typeof d>"u"||typeof i>"u")return{[n]:i?r.replace("{max}",S(i)):a.replace("{min}",S(d))}}const V={numeric:{validate:ne,error:p},"alphanum-with-spaces":{validate:oe,error:A},alphanumeric:{validate:le,error:s},alpha:{validate:se,error:f},email:{validate:ce,error:x},date:{validate:de,error:I},url:{validate:ie,error:b}}[T.INPUT_VALIDATION];return V&&!V.validate(e)&&!((H=l[n])!=null&&H.length)?{[n]:V.error}:E},R=["auth-reset-password-form__buttons--back"],he=({fieldsConfig:e,onSubmit:t})=>{const o=j({requiredFieldError:"Auth.FormText.requiredFieldError",lengthTextError:"Auth.FormText.lengthTextError",numericError:"Auth.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Auth.FormText.alphaNumericError",alphaError:"Auth.FormText.alphaError",emailError:"Auth.FormText.emailError",dateError:"Auth.FormText.dateError",dateLengthError:"Auth.FormText.dateLengthError",dateMaxError:"Auth.FormText.dateMaxError",dateMinError:"Auth.FormText.dateMinError",urlError:"Auth.FormText.urlError"}),l=U(null),c=U(!1),[u,p]=O({}),[A,s]=O({}),f=L(()=>{let r=!0;const a={...A};let n=null;for(const[E,T]of Object.entries(u)){const $=e==null?void 0:e.find(d=>{var i;return(i=d==null?void 0:d.customUpperCode)==null?void 0:i.includes(E)}),m=F(T.toString(),$,o,a);m[E]&&(Object.assign(a,m),r=!1),n||(n=Object.keys(a).find(d=>a[d])??null)}if(s(a),n&&l.current){const E=l.current.elements.namedItem(n);E==null||E.focus()}return r},[A,e,u,o]);W(()=>{if(e!=null&&e.length){const{initialData:r,errorList:a}=te(e);p(n=>({...r,...n})),s(a)}},[JSON.stringify(e)]);const x=L(async r=>{const a=r.target;console.log("target.className",a.className),console.log("excludedFocusClasses.includes(target.className)",R.includes(a.className)),console.log("!excludedFocusClasses.includes(target.className)",!R.includes(a.className)),console.log("!focusExecutedRef.current &&",!c.current&&!R.includes(a.className)),!c.current&&!R.includes(a.className)&&(await G(0),c.current=!0)},[]),I=L(r=>{const{name:a,value:n,type:E,checked:T}=r==null?void 0:r.target,$=E==="checkbox"?T:n;p(i=>({...i,[a]:$}));const m=e==null?void 0:e.find(i=>{var k;return(k=i==null?void 0:i.customUpperCode)==null?void 0:k.includes(a)});let d={...A};if(m){const i=F($.toString(),m,o,d);i&&Object.assign(d,i),s(d)}},[e,A,o]),b=L(r=>{const{name:a,value:n,type:E,checked:T}=r==null?void 0:r.target,$=E==="checkbox"?T:n,m=e==null?void 0:e.find(d=>d.customUpperCode===a);if(m){const d={...A},i=F($.toString(),m,o,d);i&&Object.assign(d,i),s(d)}},[A,e,o]),D=L(r=>{r.preventDefault();const a=f();t==null||t(r,a)},[f,t]);return{formData:u,errors:A,formRef:l,handleChange:I,handleBlur:b,handleSubmit:D,handleFocus:x}},ve=({name:e,loading:t,children:o,className:l="defaultForm",fieldsConfig:c=[],onSubmit:u,...p})=>{const{formData:A,errors:s,formRef:f,handleChange:x,handleBlur:I,handleSubmit:b,handleFocus:D}=he({onSubmit:u,fieldsConfig:c});return Z("form",{className:l,onSubmit:b,name:e,ref:f,onFocus:D,...p,children:[h(re,{className:l,onFocus:D,fields:c,onChange:x,onBlur:I,errors:s,values:A,loading:t}),o]})},Le=({type:e,buttonText:t,variant:o,className:l="",enableLoader:c=!1,onClick:u,style:p,icon:A,...s})=>{const f=L(I=>{u==null||u(I)},[u]);return Z(J,{icon:A,style:p,type:e,variant:o,className:M(["auth-button",l,c?"enableLoader":""]),onClick:f,...s,children:[h("span",{className:"auth-button__text",children:t}),c?h("div",{className:"auth-button__wrapper",children:h("span",{className:"auth-button__loader"})}):null]})};export{Le as B,ve as F,De as c,Ie as g,be as u}; +import{jsx as E,Fragment as Z,jsxs as U}from"@dropins/tools/preact-jsx-runtime.js";import{useState as R,useCallback as L,useRef as H,useEffect as P}from"@dropins/tools/preact-hooks.js";import*as f from"@dropins/tools/preact-compat.js";import{memo as W,useCallback as _}from"@dropins/tools/preact-compat.js";import{initReCaptcha as G}from"@dropins/tools/recaptcha.js";import{useText as j}from"@dropins/tools/i18n.js";import{classes as M}from"@dropins/tools/lib.js";import{Field as w,Picker as q,Input as C,InputDate as X,Checkbox as z,TextArea as B,Button as J}from"@dropins/tools/components.js";/* empty css */const be=e=>{if(!e)return null;const t=new FormData(e);if(t&&typeof t.entries=="function"){const o=t.entries();if(o&&typeof o[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(o)))||{}}return{}},xe=e=>typeof e=="function",Y=e=>f.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},f.createElement("g",{clipPath:"url(#clip0_841_1324)"},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),f.createElement("defs",null,f.createElement("clipPath",{id:"clip0_841_1324"},f.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),K=e=>f.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Q=e=>f.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),g={success:E(K,{}),warning:E(Y,{}),error:E(Q,{})},me=()=>{const[e,t]=R({}),o=L(l=>{if(!l||!l.type){t({});return}const c=g[l.type];t({...l,icon:c})},[]);return{inLineAlertProps:e,handleSetInLineAlertProps:o}};var v=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(v||{});const ee=W(({loading:e,values:t,fields:o=[],errors:l,className:c="",onChange:u,onBlur:p,onFocus:A})=>{const s=`${c}__field`,$=_((r,n,a)=>{var T;const h=(T=r.options.find(N=>N.isDefault))==null?void 0:T.value;return E(w,{error:a,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e||r.disabled,children:E(q,{name:r.customUpperCode,floatingLabel:`${r.label} ${r.required?"*":""}`,placeholder:r.label,"aria-label":r.label,options:r.options,onBlur:p,handleSelect:u,defaultValue:h??n??r.defaultValue,value:h??n??r.defaultValue})},r.id)},[c,e,s,p,u]),D=_((r,n,a)=>E(w,{error:a,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e,children:E(C,{type:"text",name:r.customUpperCode,value:n??r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:p,onChange:u,onFocus:A})},r.id),[c,e,s,p,u,A]),b=_((r,n,a)=>E(w,{error:a,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e||r.disabled,children:E(X,{type:"text",name:r.customUpperCode,value:n||r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:p,onChange:u,disabled:e||r.disabled})},r.id),[c,e,s,p,u]),m=_((r,n,a)=>E(w,{error:a,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e,children:E(z,{name:r.customUpperCode,checked:n||r.defaultValue,placeholder:r.label,label:`${r.label} ${r.required?"*":""}`,onBlur:p,onChange:u})},r.id),[c,e,s,p,u]),x=_((r,n,a)=>E(w,{error:a,className:M([s,`${s}--${r.id}`,[`${s}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${c}--${r.id}`,disabled:e,children:E(B,{type:"text",name:r.customUpperCode,value:n??r.defaultValue,label:`${r.label} ${r.required?"*":""}`,onBlur:p,onChange:u})},r.id),[c,e,s,p,u]);return o.length?E(Z,{children:o.map(r=>{const n=l==null?void 0:l[r.customUpperCode],a=t==null?void 0:t[r.customUpperCode];switch(r.fieldType){case v.TEXT:return r.options.length?$(r,a,n):D(r,a,n);case v.MULTILINE:return D(r,a,n);case v.SELECT:return $(r,a,n);case v.DATE:return b(r,a,n);case v.BOOLEAN:return m(r,a,n);case v.TEXTAREA:return x(r,a,n);default:return null}})}):null}),re=e=>e.reduce((t,{customUpperCode:o,required:l,defaultValue:c})=>(l&&o&&(t.initialData[o]=c||"",t.errorList[o]=""),t),{initialData:{},errorList:{}}),te=e=>e.reduce((t,o)=>({...t,[o.name]:o.value}),{}),ae=e=>/^\d+$/.test(e),ne=e=>/^[a-zA-Z0-9\s]+$/.test(e),oe=e=>/^[a-zA-Z0-9]+$/.test(e),le=e=>/^[a-zA-Z]+$/.test(e),se=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ce=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),de=(e,t,o)=>{const l=new Date(e).getTime()/1e3;return!(isNaN(l)||l<0||typeof t<"u"&&lo)},S=e=>{if(!e||e.trim()==="")return"";const t=parseInt(e,10);if(!isNaN(t)){const c=new Date(t*1e3);return isNaN(c.getTime())?"":c.toISOString().split("T")[0]}const o=new Date(e);if(isNaN(o.getTime()))return"";const l=parseInt(e.split("-")[1],10);return l>12||l<1?"":o.toISOString().split("T")[0]},ue=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),ie=(e,t,o)=>{const l=e.length;return l>=t&&l<=o},O=(e,t,o,l)=>{var F,y;const{requiredFieldError:c,lengthTextError:u,numericError:p,alphaNumWithSpacesError:A,alphaNumericError:s,alphaError:$,emailError:D,dateError:b,urlError:m,dateLengthError:x,dateMaxError:r,dateMinError:n}=o,a=t==null?void 0:t.customUpperCode,h={[a]:""};if(l[a]&&delete l[a],t!=null&&t.required&&!e)return{[a]:c};if(!(t!=null&&t.required)&&!e||!((F=t==null?void 0:t.validateRules)!=null&&F.length))return h;const T=te(t==null?void 0:t.validateRules),N=T.MIN_TEXT_LENGTH??1,I=T.MAX_TEXT_LENGTH??255,d=T.DATE_RANGE_MIN,i=T.DATE_RANGE_MAX;if(!ie(e,+N,+I)&&!(d||i))return{[a]:u.replace("{min}",N).replace("{max}",I)};if(!de(e,+d,+i)&&(d||i)){if(d&&d)return{[a]:x.replace("{min}",S(d)).replace("{max}",S(i))};if(typeof d>"u"||typeof i>"u")return{[a]:i?r.replace("{max}",S(i)):n.replace("{min}",S(d))}}const V={numeric:{validate:ae,error:p},"alphanum-with-spaces":{validate:ne,error:A},alphanumeric:{validate:oe,error:s},alpha:{validate:le,error:$},email:{validate:se,error:D},date:{validate:ce,error:b},url:{validate:ue,error:m}}[T.INPUT_VALIDATION];return V&&!V.validate(e)&&!((y=l[a])!=null&&y.length)?{[a]:V.error}:h},pe=["auth-reset-password-form__buttons--back"],he=({fieldsConfig:e,onSubmit:t})=>{const o=j({requiredFieldError:"Auth.FormText.requiredFieldError",lengthTextError:"Auth.FormText.lengthTextError",numericError:"Auth.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Auth.FormText.alphaNumericError",alphaError:"Auth.FormText.alphaError",emailError:"Auth.FormText.emailError",dateError:"Auth.FormText.dateError",dateLengthError:"Auth.FormText.dateLengthError",dateMaxError:"Auth.FormText.dateMaxError",dateMinError:"Auth.FormText.dateMinError",urlError:"Auth.FormText.urlError"}),l=H(null),c=H(!1),[u,p]=R({}),[A,s]=R({}),$=L(()=>{let r=!0;const n={...A};let a=null;for(const[h,T]of Object.entries(u)){const N=e==null?void 0:e.find(d=>{var i;return(i=d==null?void 0:d.customUpperCode)==null?void 0:i.includes(h)}),I=O(T.toString(),N,o,n);I[h]&&(Object.assign(n,I),r=!1),a||(a=Object.keys(n).find(d=>n[d])??null)}if(s(n),a&&l.current){const h=l.current.elements.namedItem(a);h==null||h.focus()}return r},[A,e,u,o]);P(()=>{if(e!=null&&e.length){const{initialData:r,errorList:n}=re(e);p(a=>({...r,...a})),s(n)}},[JSON.stringify(e)]);const D=L(async r=>{const n=r.target,a=!pe.some(h=>n.classList.contains(h));!c.current&&a&&(await G(0),c.current=!0)},[]),b=L(r=>{const{name:n,value:a,type:h,checked:T}=r==null?void 0:r.target,N=h==="checkbox"?T:a;p(i=>({...i,[n]:N}));const I=e==null?void 0:e.find(i=>{var k;return(k=i==null?void 0:i.customUpperCode)==null?void 0:k.includes(n)});let d={...A};if(I){const i=O(N.toString(),I,o,d);i&&Object.assign(d,i),s(d)}},[e,A,o]),m=L(r=>{const{name:n,value:a,type:h,checked:T}=r==null?void 0:r.target,N=h==="checkbox"?T:a,I=e==null?void 0:e.find(d=>d.customUpperCode===n);if(I){const d={...A},i=O(N.toString(),I,o,d);i&&Object.assign(d,i),s(d)}},[A,e,o]),x=L(r=>{r.preventDefault();const n=$();t==null||t(r,n)},[$,t]);return{formData:u,errors:A,formRef:l,handleChange:b,handleBlur:m,handleSubmit:x,handleFocus:D}},ve=({name:e,loading:t,children:o,className:l="defaultForm",fieldsConfig:c=[],onSubmit:u,...p})=>{const{formData:A,errors:s,formRef:$,handleChange:D,handleBlur:b,handleSubmit:m,handleFocus:x}=he({onSubmit:u,fieldsConfig:c});return U("form",{className:l,onSubmit:m,name:e,ref:$,onFocus:x,...p,children:[E(ee,{className:l,onFocus:x,fields:c,onChange:D,onBlur:b,errors:s,values:A,loading:t}),o]})},Le=({type:e,buttonText:t,variant:o,className:l="",enableLoader:c=!1,onClick:u,style:p,icon:A,...s})=>{const $=L(b=>{u==null||u(b)},[u]);return U(J,{icon:A,style:p,type:e,variant:o,className:M(["auth-button",l,c?"enableLoader":""]),onClick:$,...s,children:[E("span",{className:"auth-button__text",children:t}),c?E("div",{className:"auth-button__wrapper",children:E("span",{className:"auth-button__loader"})}):null]})};export{Le as B,ve as F,xe as c,be as g,me as u};