// Code generated by templ - DO NOT EDIT.

// templ: version: v0.3.943
package form

//lint:file-ignore SA4006 This context is only used if a nested component is present.

import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"

func Init() templ.ComponentScript {
	return templ.ComponentScript{
		Name: `__templ_Init_f45c`,
		Function: `function __templ_Init_f45c(){const Form = {
        Settings: {
            on: "blur",
            inline: true,
            preventLeaving: true,
            keyboardShortcuts: false,
        },
        Rules: {
            Email: [
                {
                    type: "email"
                }
            ],
            Username: [
                {
                    type: "size[2..20]"
                },
                {
                    type: "regExp[/^[A-Za-z0-9]+$/]",
                    prompt: "{name} must be alphanumeric only"
                },
                {
                    type: "regExp[/^.*[^0-9].*$/]",
                    prompt: "{name} cannot be only numbers"
                }
            ],
            Password: [
                {
                    type: "size[8..64]"
                },
                {
                    type: "regExp[/^.*[^0-9].*$/]",
                    prompt: "{name} cannot be only numbers"
                }
            ],
            Terms: [
                {
                    type: "checked",
                    prompt: "Terms and Conditions must be checked"
                }
            ],
            NotEmpty: [
                {
                    type: "notEmpty"
                }
            ],
            Match(target) {
                return [
                    {
                        type: ` + "`" + `match[${target}]` + "`" + `
                    }
                ];
            }
        },
        Captcha: {
            Encode(settings, captcha) {
                settings.data[captcha] = settings.data[captcha].toString();

                settings.data = JSON.stringify(settings.data);

                return settings;
            }
        },
        Token: {
            Encode(settings, token) {
                const params = new URLSearchParams(window.location.search);

                settings.data[token] = params.get("token");

                settings.data.ID = params.get("id");

                settings.data = JSON.stringify(settings.data);
        
                return settings;
            }
        },
        Toast: {
            Success(response) {
                $.toast({
                    class: "success",
                    message: response.Message,
                    showProgress: "top"
                });
            },
            Failure(response) {
                response.Data.forEach((error) => {
                    $.toast({
                        class: "error",
                        message: error.Message,
                        showProgress: "top"
                    });
                });
            }
        }
    };

    window.Form = Form;
}`,
		Call:       templ.SafeScript(`__templ_Init_f45c`),
		CallInline: templ.SafeScriptInline(`__templ_Init_f45c`),
	}
}

func Form() templ.Component {
	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
			return templ_7745c5c3_CtxErr
		}
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
		if !templ_7745c5c3_IsBuffer {
			defer func() {
				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
				if templ_7745c5c3_Err == nil {
					templ_7745c5c3_Err = templ_7745c5c3_BufErr
				}
			}()
		}
		ctx = templ.InitializeContext(ctx)
		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var1 == nil {
			templ_7745c5c3_Var1 = templ.NopComponent
		}
		ctx = templ.ClearChildren(ctx)
		return nil
	})
}

var _ = templruntime.GeneratedTemplate
