@forms.expert/sdk 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var w=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var s in e)w(t,s,{get:e[s],enumerable:!0})},O=(t,e,s,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of U(e))!M.call(t,i)&&i!==s&&w(t,i,{get:()=>e[i],enumerable:!(m=A(e,i))||m.enumerable});return t};var B=t=>O(w({},"__esModule",{value:!0}),t);var J={};I(J,{FormWidget:()=>y,autoInit:()=>N,errorsToRecord:()=>F,generateFormStyles:()=>E,renderField:()=>L,renderForm:()=>v,renderSuccess:()=>k});module.exports=B(J);var R={theme:"light",primaryColor:"#3b82f6",backgroundColor:"#ffffff",textColor:"#1f2937",borderRadius:"md",fontSize:"md",buttonStyle:"filled",labelPosition:"top"};function H(t){switch(t){case"none":return"0";case"sm":return"0.125rem";case"md":return"0.375rem";case"lg":return"0.5rem";default:return"0.375rem"}}function V(t){switch(t){case"none":return"0";case"small":return"4px";case"medium":return"8px";case"large":return"12px";case"full":return"9999px";default:return"8px"}}function q(t){switch(t){case"sm":return"0.875rem";case"md":return"1rem";case"lg":return"1.125rem";default:return"1rem"}}function W(t){switch(t){case"small":return"0.75rem";case"large":return"1rem";default:return"0.875rem"}}function D(t){switch(t){case"compact":return"0.5rem";case"relaxed":return"1.5rem";case"spacious":return"2rem";default:return"1rem"}}function K(t){switch(t){case"none":return"0";case"compact":return"1rem";case"relaxed":return"2.5rem";case"spacious":return"3.5rem";default:return"1.5rem"}}function j(t){switch(t){case"compact":return"0.125rem";case"relaxed":return"0.75rem";default:return"0.25rem"}}function _(t){switch(t){case"narrow":return"28rem";case"wide":return"48rem";case"full":return"100%";default:return"36rem"}}function G(t){switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}}function E(t=R){let e={...R,...t},s=H(e.borderRadius),m=V(e.buttonRadius),i=q(e.fontSize),c=W(e.placeholderFontSize),o=D(e.fieldSpacing),n=K(e.formPadding),d=j(e.labelSpacing),a=_(e.formWidth),l=e.primaryColor,r=e.buttonColor,p=e.fontFamily?e.fontFamily.includes(",")?e.fontFamily:`${e.fontFamily}, sans-serif`:"system-ui, -apple-system, sans-serif",u=G(e.buttonAlign),S={small:{px:"0.75rem",py:"0.375rem",fs:"0.875rem"},medium:{px:"1.25rem",py:"0.625rem",fs:"1rem"},large:{px:"1.75rem",py:"0.875rem",fs:"1.125rem"}}[e.buttonSize||"medium"],C=e.buttonPaddingX!=null?`${e.buttonPaddingX}px`:S.px,z=e.buttonPaddingY!=null?`${e.buttonPaddingY}px`:S.py,T=e.buttonFontSize!=null?`${e.buttonFontSize}px`:S.fs,P=e.buttonGradient||(e.buttonStyle==="filled"?l:"transparent");return`
1
+ "use strict";var w=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var s in e)w(t,s,{get:e[s],enumerable:!0})},O=(t,e,s,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of U(e))!M.call(t,i)&&i!==s&&w(t,i,{get:()=>e[i],enumerable:!(m=A(e,i))||m.enumerable});return t};var B=t=>O(w({},"__esModule",{value:!0}),t);var J={};I(J,{FormWidget:()=>y,autoInit:()=>N,errorsToRecord:()=>F,generateFormStyles:()=>E,renderField:()=>L,renderForm:()=>v,renderSuccess:()=>k});module.exports=B(J);var R={theme:"light",primaryColor:"#3b82f6",backgroundColor:"#ffffff",textColor:"#1f2937",borderRadius:"md",fontSize:"md",buttonStyle:"filled",labelPosition:"top"};function H(t){switch(t){case"none":return"0";case"sm":return"0.125rem";case"md":return"0.375rem";case"lg":return"0.5rem";default:return"0.375rem"}}function V(t){switch(t){case"none":return"0";case"small":return"4px";case"medium":return"8px";case"large":return"12px";case"full":return"9999px";default:return"8px"}}function q(t){switch(t){case"sm":return"0.875rem";case"md":return"1rem";case"lg":return"1.125rem";default:return"1rem"}}function W(t){switch(t){case"small":return"0.75rem";case"large":return"1rem";default:return"0.875rem"}}function D(t){switch(t){case"compact":return"0.5rem";case"relaxed":return"1.5rem";case"spacious":return"2rem";default:return"1rem"}}function K(t){switch(t){case"none":return"0";case"compact":return"1rem";case"relaxed":return"2.5rem";case"spacious":return"3.5rem";default:return"1.5rem"}}function j(t){switch(t){case"compact":return"0.125rem";case"relaxed":return"0.75rem";default:return"0.25rem"}}function _(t){switch(t){case"narrow":return"28rem";case"wide":return"48rem";case"full":return"100%";default:return"36rem"}}function G(t){switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}}function E(t=R){let e={...R,...t},s=H(e.borderRadius),m=V(e.buttonRadius),i=q(e.fontSize),c=W(e.placeholderFontSize),o=D(e.fieldSpacing),n=K(e.formPadding),d=j(e.labelSpacing),a=_(e.formWidth),l=e.primaryColor,r=e.buttonColor,p=e.fontFamily?e.fontFamily.includes(",")?e.fontFamily:`${e.fontFamily}, sans-serif`:"inherit",u=G(e.buttonAlign),S={small:{px:"0.75rem",py:"0.375rem",fs:"0.875rem"},medium:{px:"1.25rem",py:"0.625rem",fs:"1rem"},large:{px:"1.75rem",py:"0.875rem",fs:"1.125rem"}}[e.buttonSize||"medium"],C=e.buttonPaddingX!=null?`${e.buttonPaddingX}px`:S.px,z=e.buttonPaddingY!=null?`${e.buttonPaddingY}px`:S.py,T=e.buttonFontSize!=null?`${e.buttonFontSize}px`:S.fs,P=e.buttonGradient||(e.buttonStyle==="filled"?l:"transparent");return`
2
2
  .forms-expert-wrapper {
3
3
  ${e.backgroundImageUrl?`background-image: url(${e.backgroundImageUrl}); background-size: cover; background-position: center;`:""}
4
4
  ${e.backgroundImageUrl?"":`background-color: ${e.backgroundColor};`}
@@ -339,7 +339,7 @@ ${e.customCss||""}
339
339
  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
340
340
  </svg>
341
341
  <div class="forms-expert-success-message">${h(t)}</div>
342
- `,e}function F(t){return t.reduce((e,s)=>({...e,[s.field]:s.message}),{})}var g=class extends Error{constructor(s,m,i,c){super(s);this.code=m;this.statusCode=i;this.retryAfter=c;this.name="FormsError"}},f=class extends Error{constructor(s){super("Validation failed");this.errors=s;this.name="FormValidationError"}};var b=class{constructor(e){this.apiKey=e.apiKey,this.resourceId=e.resourceId,this.baseUrl=(e.baseUrl||"https://api.forms.expert/api/v1").replace(/\/$/,"")}buildUrl(e){let s=e.includes("?")?"&":"?";return`${this.baseUrl}${e}${s}token=${encodeURIComponent(this.apiKey)}`}async request(e,s,m){let i=this.buildUrl(s),c=await fetch(i,{method:e,headers:{"Content-Type":"application/json"},body:m?JSON.stringify(m):void 0}),o=await c.json();if(!c.ok)throw new g(o.message||"Request failed",o.code||"UNKNOWN_ERROR",c.status,o.retryAfter);return o}async isActive(e,s){let m=s?`?lang=${encodeURIComponent(s)}`:"";return this.request("GET",`/f/${this.resourceId}/${e}/is-active${m}`)}async validate(e,s){return this.request("POST",`/f/${this.resourceId}/${e}/validate`,{data:s})}async submit(e,s,m){let i=this.buildUrl(`/f/${this.resourceId}/${e}`);return Object.values(s).some(o=>o instanceof File||o instanceof FileList&&o.length>0)||m?.onProgress?this.submitWithFormData(i,s,m):this.request("POST",`/f/${this.resourceId}/${e}`,{data:s,pageUrl:m?.pageUrl||(typeof window<"u"?window.location.href:void 0),captchaToken:m?.captchaToken})}submitWithFormData(e,s,m){return new Promise((i,c)=>{let o=new FormData;for(let[a,l]of Object.entries(s))l instanceof File?o.append(a,l):l instanceof FileList?Array.from(l).forEach(r=>o.append(a,r)):l!=null&&o.append(`data[${a}]`,String(l));let n=m?.pageUrl||(typeof window<"u"?window.location.href:"");n&&o.append("pageUrl",n),m?.captchaToken&&o.append("captchaToken",m.captchaToken);let d=new XMLHttpRequest;m?.onProgress&&d.upload.addEventListener("progress",a=>{a.lengthComputable&&m.onProgress({loaded:a.loaded,total:a.total,percentage:Math.round(a.loaded/a.total*100)})}),d.addEventListener("load",()=>{try{let a=JSON.parse(d.responseText);d.status>=200&&d.status<300?i(a):c(new g(a.message||"Submission failed",a.code||"UNKNOWN_ERROR",d.status,a.retryAfter))}catch{c(new g("Invalid response","PARSE_ERROR",d.status))}}),d.addEventListener("error",()=>{c(new g("Network error","NETWORK_ERROR",0))}),d.addEventListener("abort",()=>{c(new g("Request aborted","ABORTED",0))}),d.open("POST",e),d.send(o)})}async trackView(e){let s=this.buildUrl(`/f/${this.resourceId}/${e}/view`);await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"}}).catch(()=>{})}getResourceId(){return this.resourceId}getBaseUrl(){return this.baseUrl}};var $=class{constructor(e,s,m={}){this.config=null;this.apiClient=e,this.slug=s,this.options=m}async initialize(e){return this.config=await this.apiClient.isActive(this.slug,e),this.options.trackViews&&this.apiClient.trackView(this.slug),this.config}getConfig(){return this.config}isActive(){return this.config?.active??!1}requiresCaptcha(){return this.config?.settings?.captcha?.enabled??!1}getCaptchaProvider(){return this.config?.settings?.captcha?.provider}getSchema(){return this.config?.schema}async validate(e){return this.apiClient.validate(this.slug,e)}async submit(e,s){this.options.onSubmitStart?.();try{if(this.config?.mode==="schema"){let i=await this.validate(e);if(!i.valid)throw this.options.onValidationError?.(i.errors),new f(i.errors)}let m=await this.apiClient.submit(this.slug,e,s);return this.options.onSubmitSuccess?.(m),m}catch(m){throw m instanceof g&&this.options.onSubmitError?.(m),m}}getSuccessMessage(){return this.config?.settings?.successMessage||"Form submitted successfully!"}getRedirectUrl(){return this.config?.settings?.redirectUrl}},x=class{constructor(e){this.apiClient=new b(e)}async isActive(e,s){return this.apiClient.isActive(e,s)}async validate(e,s){return this.apiClient.validate(e,s)}async submit(e,s,m){return this.apiClient.submit(e,s,m)}form(e,s){return new $(this.apiClient,e,s)}async trackView(e){return this.apiClient.trackView(e)}async submitWithRetry(e,s,m){let i=m?.maxRetries??3,c=null;for(let o=0;o<i;o++)try{return await this.submit(e,s,m)}catch(n){if(c=n,n instanceof g){if(["VALIDATION_ERROR","CAPTCHA_REQUIRED","ORIGIN_NOT_ALLOWED"].includes(n.code))throw n;if(n.code.includes("RATE_LIMIT")){let d=n.retryAfter||Math.pow(2,o)*1e3;await new Promise(a=>setTimeout(a,d));continue}}await new Promise(d=>setTimeout(d,Math.pow(2,o)*1e3))}throw c}};var y=class{constructor(e,s){this.config=null;this.values={};this.errors={};this.isLoading=!1;this.isSubmitted=!1;this.styleEl=null;this.sdk=new x(e),this.options=s;let m=s.target;if(typeof m=="string"){let i=document.querySelector(m);if(!i)throw new Error(`Element not found: ${m}`);this.container=i}else this.container=m}async init(){try{if(this.renderLoading(),this.config=await this.sdk.isActive(this.options.slug,this.options.lang),!this.config.active){this.renderError("This form is not available");return}this.options.trackViews&&this.sdk.trackView(this.options.slug),this.injectStyles(),this.render()}catch(e){this.renderError("Failed to load form"),this.options.onError?.(e)}}injectStyles(){if(this.styleEl)return;this.styleEl=document.createElement("style"),this.styleEl.id=`forms-expert-styles-${this.options.slug}`;let e={...this.config?.schema?.styling,...this.config?.styling};this.styleEl.textContent=E(e),document.head.appendChild(this.styleEl)}render(){if(!this.config?.schema)return;if(this.isSubmitted){this.container.innerHTML="";let i=this.config.settings?.successMessage||"Form submitted successfully!";this.container.appendChild(k(i));return}let e={...this.config.schema.styling,...this.config.styling},s={...this.config.schema,styling:e},m=v(s,this.values,this.errors,{honeypot:this.config.settings?.honeypot,showBranding:this.config.branding?.enabled!==!1,brandingText:this.config.branding?.text,brandingUrl:this.config.branding?.url,submitText:e.buttonText||this.options.submitText,isLoading:this.isLoading,hideRequiredAsterisk:e.hideRequiredAsterisk,formName:this.config.hostedConfig?.pageTitle||this.config.name,showFormName:this.config.settings?.showFormName,secondaryButton:e.secondaryButton,buttonAlign:e.buttonAlign,formNameFontSize:e.formNameFontSize,formNameFontWeight:e.formNameFontWeight});m.addEventListener("input",i=>{let c=i.target;c.name&&c.name!=="_hp"&&c.name!=="pageUrl"&&(c.type==="checkbox"?this.values[c.name]=c.checked:c.type==="file"?this.values[c.name]=c.multiple?c.files:c.files?.[0]:this.values[c.name]=c.value,this.errors[c.name]&&(delete this.errors[c.name],this.render()))}),m.addEventListener("submit",i=>{i.preventDefault(),this.handleSubmit()}),this.container.innerHTML="",this.container.appendChild(m)}async handleSubmit(){if(!(this.isLoading||!this.config)){this.isLoading=!0,this.errors={},this.render();try{let e=await this.sdk.submit(this.options.slug,this.values);this.isLoading=!1,this.isSubmitted=!0,this.render(),this.options.onSuccess?.(e);let s=this.options.redirectUrl||this.config.settings?.redirectUrl;s&&setTimeout(()=>{window.location.href=s},1500),this.options.resetOnSuccess&&setTimeout(()=>{this.reset()},3e3)}catch(e){this.isLoading=!1,e instanceof f?(this.errors=F(e.errors),this.options.onValidationError?.(e.errors)):this.options.onError?.(e),this.render()}}}reset(){this.values={},this.errors={},this.isLoading=!1,this.isSubmitted=!1,this.render()}renderLoading(){this.container.innerHTML=`
342
+ `,e}function F(t){return t.reduce((e,s)=>({...e,[s.field]:s.message}),{})}var g=class extends Error{constructor(s,m,i,c){super(s);this.code=m;this.statusCode=i;this.retryAfter=c;this.name="FormsError"}},f=class extends Error{constructor(s){super("Validation failed");this.errors=s;this.name="FormValidationError"}};var b=class{constructor(e){this.apiKey=e.apiKey,this.resourceId=e.resourceId,this.baseUrl=(e.baseUrl||"https://api.forms.expert/api/v1").replace(/\/$/,"")}buildUrl(e){let s=e.includes("?")?"&":"?";return`${this.baseUrl}${e}${s}token=${encodeURIComponent(this.apiKey)}`}async request(e,s,m){let i=this.buildUrl(s),c=await fetch(i,{method:e,headers:{"Content-Type":"application/json"},body:m?JSON.stringify(m):void 0}),o=await c.json();if(!c.ok)throw new g(o.message||"Request failed",o.code||"UNKNOWN_ERROR",c.status,o.retryAfter);return o}async isActive(e,s){let m=s?`?lang=${encodeURIComponent(s)}`:"";return this.request("GET",`/f/${this.resourceId}/${e}/is-active${m}`)}async validate(e,s){return this.request("POST",`/f/${this.resourceId}/${e}/validate`,{data:s})}async submit(e,s,m){let i=this.buildUrl(`/f/${this.resourceId}/${e}`);return Object.values(s).some(o=>o instanceof File||o instanceof FileList&&o.length>0)||m?.onProgress?this.submitWithFormData(i,s,m):this.request("POST",`/f/${this.resourceId}/${e}`,{data:s,pageUrl:m?.pageUrl||(typeof window<"u"?window.location.href:void 0),captchaToken:m?.captchaToken})}submitWithFormData(e,s,m){return new Promise((i,c)=>{let o=new FormData;for(let[a,l]of Object.entries(s))l instanceof File?o.append(a,l):l instanceof FileList?Array.from(l).forEach(r=>o.append(a,r)):l!=null&&o.append(`data[${a}]`,String(l));let n=m?.pageUrl||(typeof window<"u"?window.location.href:"");n&&o.append("pageUrl",n),m?.captchaToken&&o.append("captchaToken",m.captchaToken);let d=new XMLHttpRequest;m?.onProgress&&d.upload.addEventListener("progress",a=>{a.lengthComputable&&m.onProgress({loaded:a.loaded,total:a.total,percentage:Math.round(a.loaded/a.total*100)})}),d.addEventListener("load",()=>{try{let a=JSON.parse(d.responseText);d.status>=200&&d.status<300?i(a):c(new g(a.message||"Submission failed",a.code||"UNKNOWN_ERROR",d.status,a.retryAfter))}catch{c(new g("Invalid response","PARSE_ERROR",d.status))}}),d.addEventListener("error",()=>{c(new g("Network error","NETWORK_ERROR",0))}),d.addEventListener("abort",()=>{c(new g("Request aborted","ABORTED",0))}),d.open("POST",e),d.send(o)})}async trackView(e){let s=this.buildUrl(`/f/${this.resourceId}/${e}/view`);await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"}}).catch(()=>{})}getResourceId(){return this.resourceId}getBaseUrl(){return this.baseUrl}};var $=class{constructor(e,s,m={}){this.config=null;this.apiClient=e,this.slug=s,this.options=m}async initialize(e){return this.config=await this.apiClient.isActive(this.slug,e),this.options.trackViews&&this.apiClient.trackView(this.slug),this.config}getConfig(){return this.config}isActive(){return this.config?.active??!1}requiresCaptcha(){return this.config?.settings?.captcha?.enabled??!1}getCaptchaProvider(){return this.config?.settings?.captcha?.provider}getSchema(){return this.config?.schema}async validate(e){return this.apiClient.validate(this.slug,e)}async submit(e,s){this.options.onSubmitStart?.();try{if(this.config?.mode==="schema"){let i=await this.validate(e);if(!i.valid)throw this.options.onValidationError?.(i.errors),new f(i.errors)}let m=await this.apiClient.submit(this.slug,e,s);return this.options.onSubmitSuccess?.(m),m}catch(m){throw m instanceof g&&this.options.onSubmitError?.(m),m}}getSuccessMessage(){return this.config?.settings?.successMessage||"Form submitted successfully!"}getRedirectUrl(){return this.config?.settings?.redirectUrl}},x=class{constructor(e){this.apiClient=new b(e)}async isActive(e,s){return this.apiClient.isActive(e,s)}async validate(e,s){return this.apiClient.validate(e,s)}async submit(e,s,m){return this.apiClient.submit(e,s,m)}form(e,s){return new $(this.apiClient,e,s)}async trackView(e){return this.apiClient.trackView(e)}async submitWithRetry(e,s,m){let i=m?.maxRetries??3,c=null;for(let o=0;o<i;o++)try{return await this.submit(e,s,m)}catch(n){if(c=n,n instanceof g){if(["VALIDATION_ERROR","CAPTCHA_REQUIRED","ORIGIN_NOT_ALLOWED"].includes(n.code))throw n;if(n.code.includes("RATE_LIMIT")){let d=n.retryAfter||Math.pow(2,o)*1e3;await new Promise(a=>setTimeout(a,d));continue}}await new Promise(d=>setTimeout(d,Math.pow(2,o)*1e3))}throw c}};var y=class{constructor(e,s){this.config=null;this.values={};this.errors={};this.isLoading=!1;this.isSubmitted=!1;this.styleEl=null;this.sdk=new x(e),this.options=s;let m=s.target;if(typeof m=="string"){let i=document.querySelector(m);if(!i)throw new Error(`Element not found: ${m}`);this.container=i}else this.container=m}async init(){try{if(this.renderLoading(),this.config=await this.sdk.isActive(this.options.slug,this.options.lang),!this.config.active){this.renderError("This form is not available");return}this.options.trackViews&&this.sdk.trackView(this.options.slug),this.injectStyles(),this.render()}catch(e){this.renderError("Failed to load form"),this.options.onError?.(e)}}injectStyles(){if(this.styleEl)return;this.styleEl=document.createElement("style"),this.styleEl.id=`forms-expert-styles-${this.options.slug}`;let e={...this.config?.schema?.styling,...this.config?.styling};this.styleEl.textContent=E(e),document.head.appendChild(this.styleEl),this.injectGoogleFont(e?.fontFamily)}injectGoogleFont(e){if(!e)return;let s=["Inter","Roboto","Open Sans","Lato","Poppins","Montserrat","Nunito","Source Sans Pro","Raleway","Ubuntu","Playfair Display","Merriweather"],m=e.split(",")[0]?.trim();if(!m||!s.includes(m))return;let i=`forms-expert-font-${this.options.slug}`;if(document.getElementById(i))return;let c=document.createElement("link");c.id=i,c.rel="stylesheet",c.href=`https://fonts.googleapis.com/css2?family=${m.replace(/ /g,"+")}:wght@400;500;600;700&display=swap`,document.head.appendChild(c)}render(){if(!this.config?.schema)return;if(this.isSubmitted){this.container.innerHTML="";let i=this.config.settings?.successMessage||"Form submitted successfully!";this.container.appendChild(k(i));return}let e={...this.config.schema.styling,...this.config.styling},s={...this.config.schema,styling:e},m=v(s,this.values,this.errors,{honeypot:this.config.settings?.honeypot,showBranding:this.config.branding?.enabled!==!1,brandingText:this.config.branding?.text,brandingUrl:this.config.branding?.url,submitText:e.buttonText||this.options.submitText,isLoading:this.isLoading,hideRequiredAsterisk:e.hideRequiredAsterisk,formName:this.config.hostedConfig?.pageTitle||this.config.name,showFormName:this.config.settings?.showFormName,secondaryButton:e.secondaryButton,buttonAlign:e.buttonAlign,formNameFontSize:e.formNameFontSize,formNameFontWeight:e.formNameFontWeight});m.addEventListener("input",i=>{let c=i.target;c.name&&c.name!=="_hp"&&c.name!=="pageUrl"&&(c.type==="checkbox"?this.values[c.name]=c.checked:c.type==="file"?this.values[c.name]=c.multiple?c.files:c.files?.[0]:this.values[c.name]=c.value,this.errors[c.name]&&(delete this.errors[c.name],this.render()))}),m.addEventListener("submit",i=>{i.preventDefault(),this.handleSubmit()}),this.container.innerHTML="",this.container.appendChild(m)}async handleSubmit(){if(!(this.isLoading||!this.config)){this.isLoading=!0,this.errors={},this.render();try{let e=await this.sdk.submit(this.options.slug,this.values);this.isLoading=!1,this.isSubmitted=!0,this.render(),this.options.onSuccess?.(e);let s=this.options.redirectUrl||this.config.settings?.redirectUrl;s&&setTimeout(()=>{window.location.href=s},1500),this.options.resetOnSuccess&&setTimeout(()=>{this.reset()},3e3)}catch(e){this.isLoading=!1,e instanceof f?(this.errors=F(e.errors),this.options.onValidationError?.(e.errors)):this.options.onError?.(e),this.render()}}}reset(){this.values={},this.errors={},this.isLoading=!1,this.isSubmitted=!1,this.render()}renderLoading(){this.container.innerHTML=`
343
343
  <div class="forms-expert" style="display: flex; align-items: center; justify-content: center; padding: 2rem;">
344
344
  <svg width="24" height="24" viewBox="0 0 24 24" style="animation: fe-spin 1s linear infinite; color: #9ca3af;">
345
345
  <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="3" fill="none" stroke-dasharray="31.4 31.4" stroke-linecap="round"/>